/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_2113.cs * 2.功能描述:批量清除在产临时表数据 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2015/08/11 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Reflection; using System.Text; 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; namespace Dongke.IBOSS.PRD.Client.PMModule { public partial class F_PM_2113 : DKFormBase { #region 构造函数 public F_PM_2113() { InitializeComponent(); this.btnClose.Text = ButtonText.BTN_CLOSE; this.btnSave.Text = ButtonText.BTN_SAVE; } #endregion #region 事件 /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体加载事件 /// /// /// private void F_PM_2113_Load(object sender, EventArgs e) { this.dtpUpdateTimeStart.Value = DateTime.Now.Date; this.dtpUpdateTimeEnd.Value = DateTime.Now.Date; this.dtpScrapDateStart.Value = DateTime.Now.Date; this.dtpScrapDateEnd.Value = DateTime.Now.Date; this.dtpScrapDateStart.Enabled = false; this.dtpScrapDateEnd.Enabled = false; BindComDataSource();//绑定数据来源 } /// /// 保存按钮事件 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show("确认是否清除符合条件的产品数据?清除后不可恢复.", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult.Equals(DialogResult.No)) { return; } FPM2112_SE se = new FPM2112_SE(); se.ProductionLineIDS = dkproductionLineSearchBox.ProductionLineIDS; se.ProcedureIDS = dkProcedureSearchBox.ProcedureIDS; if (Convert.ToInt32(this.cmbDataSource.SelectedValue) == 0) { se.UpdateTimeStart = DateTime.Parse(this.dtpUpdateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0"); se.UpdateTimeEnd = DateTime.Parse(this.dtpUpdateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59"); } else { //报废日期 se.ScrapDataStart = DateTime.Parse(this.dtpScrapDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0"); se.ScrapDataEnd = DateTime.Parse(this.dtpScrapDateEnd.Value.ToString("yyyy-MM-dd") + " 0:0:0"); } se.TrashFlag = Convert.ToInt32(cmbDataSource.SelectedValue); // 清除 int result = (int)DoAsync(() => { return PMModuleProxy.Service.SaveClearAllInproductionTmp(se); }); if (result > Constant.INT_IS_ZERO) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "在产临时表", "批量清除数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); // 刷新窗口数据 this.DialogResult = DialogResult.OK; } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "在产临时表", "批量清除数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 绑定数据来源 /// private void BindComDataSource() { DataTable dt = new DataTable(); dt.Columns.Add("DataSourceID"); dt.Columns.Add("DataSourceName"); DataRow dr = dt.NewRow(); dr["DataSourceID"] = 0; dr["DataSourceName"] = "在产"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["DataSourceID"] = 1; dr["DataSourceName"] = "回收站"; dt.Rows.Add(dr); this.cmbDataSource.DataSource = dt; this.cmbDataSource.DisplayMember = "DataSourceName"; this.cmbDataSource.ValueMember = "DataSourceID"; } /// /// 数据来原改变事件 /// /// /// private void cmbDataSource_SelectedIndexChanged(object sender, EventArgs e) { if (cmbDataSource.SelectedIndex == 0) { this.dtpUpdateTimeStart.Enabled = true; this.dtpUpdateTimeEnd.Enabled = true; this.dtpScrapDateStart.Enabled = false; this.dtpScrapDateEnd.Enabled = false; } else { this.dtpUpdateTimeStart.Enabled = false; this.dtpUpdateTimeEnd.Enabled = false; this.dtpScrapDateStart.Enabled = true; this.dtpScrapDateEnd.Enabled = true; } } #endregion } }