| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_TAT_0203.cs
- * 2.功能描述:工价策略产品关联
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/11/18 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
- namespace Dongke.IBOSS.PRD.Client.TATModule
- {
- /// <summary>
- /// 工价策略产品关联
- /// </summary>
- public partial class F_TAT_0203 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formType;
- // 主体信息ID
- private int? _WagesId;
- // 主体工种ID
- private int? _JobsId;
- // 数据源
- private DataSet _dsSourse;
- // 产品数据源
- private DataTable _dtGoodsSourse;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="formType">窗体开启模式</param>
- /// <param name="WagesId">策略ID</param>
- /// <param name="JobsId">工种ID</param>
- /// <param name="JobsName">工种名称</param>
- /// <param name="JobsCode">工种编码</param>
- public F_TAT_0203(Constant.FormMode formType,int WagesId,
- int JobsId,string JobsName,string JobsCode)
- {
- InitializeComponent();
- this._WagesId = WagesId;
- this._JobsId = JobsId;
- this._formType = formType;
- this.txtJobsName.Text = JobsName;
- this.txtJobsCode.Text = JobsCode;
- // 窗口标题
- this.Text = FormTitles.F_TAT_0203;
- // 按钮
- this.btnSubmit.Text = ButtonText.BTN_SAVE;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_TAT_0203_Load(object sender, EventArgs e)
- {
- try
- {
- //绑定列表信息
- this.BindPage();
- //获取全部产品信息
- this.GetGoods();
- if(this._formType == Constant.FormMode.Display || this._formType == Constant.FormMode.CopyAndAdd)
- {
- this.dgvGoods.ReadOnly = true;
- this.dgvGoods.IsSetInputColumnsColor = false;
- this.dgvGoods.AllowUserToDeleteRows = false;
- this.tsbtnCreateGoods.Enabled = false;
- this.btnSubmit.Visible = false;
- }
- }
- catch(Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 创建产品
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnCreateGoods_Click(object sender, EventArgs e)
- {
- try
- {
- //遍历产品明细添加该工种的所有明细信息
- foreach (DataRow drFor in this._dtGoodsSourse.Rows)
- {
- //首先查看该产品是否已存在
- int GoodsIsHave = 0;
- foreach (DataGridViewRow gvrFor in this.dgvGoods.Rows)
- {
- if (Convert.ToInt32(gvrFor.Cells["GoodsID"].Value)
- == Convert.ToInt32(drFor["GoodsID"]))
- {
- GoodsIsHave++;
- break;
- }
- }
- //如果不存在才进行添加
- if (GoodsIsHave == 0)
- {
- //向最终数据源添加扣罚明细信息
- DataRow drDetail = this._dsSourse.Tables[0].NewRow();
- drDetail["GoodsID"] = drFor["GoodsId"];
- drDetail["GoodsCode"] = drFor["GoodsCode"];
- drDetail["GoodsName"] = drFor["GoodsName"];
- drDetail["PieceNum"] = 1;
- drDetail["Wages"] = 0;
- drDetail["PublicWages"] = 0;
- this._dsSourse.Tables[0].Rows.Add(drDetail);
- }
- }
- this.dgvGoods.IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 自适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSubmit_Click(object sender, EventArgs e)
- {
- try
- {
- //提交操作
- ServiceResultEntity srEntity =
- (ServiceResultEntity)DoAsync(() =>
- {
- return TATModuleProxy.Service.EditWagesGoodsDetail(
- Convert.ToInt32(this._WagesId), Convert.ToInt32(this._JobsId), this._dsSourse);
- });
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- catch(Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- }
- #endregion
- #region 私有方法和函数
- /// <summary>
- /// 绑定列表
- /// </summary>
- private void BindPage()
- {
- try
- {
- //绑定某工种对应的产品信息
- if (this._WagesId != null && this._JobsId != null)
- {
- ServiceResultEntity srEntity =
- TATModuleProxy.Service.GetWagesGoodsDetail(Convert.ToInt32(this._WagesId), Convert.ToInt32(this._JobsId));
- if(srEntity != null && srEntity.Data != null && srEntity.Data.Tables.Count != 0)
- {
- this.dgvGoods.AutoGenerateColumns = false;
- this.dgvGoods.DataSource = srEntity.Data.Tables[0];
- this.dgvGoods.IsSetInputColumnsColor = true;
- this._dsSourse = srEntity.Data;
- }
- }
- }
- catch(Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取全部产品信息
- /// </summary>
- private void GetGoods()
- {
- try
- {
- GoodsEntity goods = new GoodsEntity();
- goods.ValueFlag = 1;
- DataSet dsGoods = SystemModuleProxy.Service.SerachGoods(goods);
- if (dsGoods != null && dsGoods.Tables.Count != 0)
- {
- this._dtGoodsSourse = dsGoods.Tables[0];
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|