using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.StlMes.Client.YdmBase; using Core.Mes.Client.Comm.Tool; using System.Collections; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using System.Text.RegularExpressions; using Core.StlMes.Client.YdmPipeManage.Tool; using Core.StlMes.Client.SaleOrder.ReviewForm; using Core.StlMes.Client.YdmPipeManage; using Core.Mes.Client.Comm; namespace Core.StlMes.Client.PipeLeaveFactory { public partial class frmPipeLoad : FrmBase { /// /// 获取仓库权限 /// private string[] _storagerPur; private string strBill = "";//提货单号 private string strLoad = "";//装车单号 private string strCar = "";//车号 private string strReceiv = "";//收货单位 string index = "";//定位 public frmPipeLoad() { InitializeComponent(); this.IsLoadUserView = true; } private void frmPipeLoad_Load(object sender, EventArgs e) { //收货单位 YdmBaseClass.InitComboEditor(cmbReceiv, "com.steering.pss.ydm.pipeleavefactory.FrmPipeSendList.queryCustomer", "CUSTOMER_NO", ob, true); DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 OutEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); OutStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); _storagerPur = BaseMethod.WarehousePermissions("", this.ValidDataPurviewIds, ob); BaseMethod.InitStorage(cmbStorager, "", this.ValidDataPurviewIds, ob); ClsBaseInfo.FillComBaseInfo(ucType, "8021", ob, false); ultraExpandableGroupBox3.Visible = false; GridHelper.SetColumnsActivateAndColor(ultraGrid3.Rows.Band, "HOOK_WEIGHT"); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Update": doUpdate(); break; case "GetUpdateNetWeight": GetUpdateNetWeight(); break; case "Confirm"://确认有效 doConfirm(); break; case "CancelConfirm"://取消确认 doCancelConfirm(); break; case "Refresh": doRefresh(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "理货单信息"); break; case "LoadPrint"://装车单打印 doLoadPrint(); break; case "LoadPrint2"://装车单二维码打印 doLoadPrint2(); break; case "Close": this.Close(); break; case "Zbs"://随车质保书 doZbsPrint(); break; } } private void GetUpdateNetWeight() { UltraGridRow ugr = this.ultraGrid1.ActiveRow; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad"; ccp.MethodName = "GetUpdateNetWeight"; ccp.ServerParams = new object[] { ugr.Cells["BILL_NO"].Value.ToString(), ugr.Cells["TALLYSHEET_NO"].Value.ToString(), ugr.Cells["VEHICLE_NO"].Value.ToString(), this.UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("获取成功!")) { doQuery(); } } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "doConfirm_HW": doConfirm_HW(sender,e); break; } } private void doConfirm_HW(object sender, EventArgs e) { this.ultraGrid3.UpdateData(); if (ultraGrid3.Rows.Count == 0) { MessageBox.Show("请选择操作记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //foreach (UltraGridRow row in ultraGrid2.Rows) //{ // if (!row.Cells["PONDER_NO"].Text.Trim().Equals("")) // { // MessageUtil.ShowTips("已过磅,不能确认钩子称!"); // return; // } //} foreach (UltraGridRow row in ultraGrid3.Rows) { if (row.Cells["HOOK_WEIGHT"].Value.ToString().Trim() == "") { MessageUtil.ShowTips("炉号:"+row.Cells["JUDGE_STOVE_NO"].Text.Trim()+"钩子称重量不能为空,请输入!"); return; } //if (double.Parse(row.Cells["HOOK_WEIGHT"].Value.ToString().Trim()) == 0) { // MessageUtil.ShowTips("炉号:"+row.Cells["JUDGE_STOVE_NO"].Text.Trim()+ "钩子称重量为零,请重新输入!"); // return; } } foreach (UltraGridRow row in ultraGrid3.Rows) { ArrayList all = new ArrayList(); all.Add(row.Cells["BILL_NO"].Value.ToString().Trim()); all.Add(row.Cells["TALLYSHEET_NO"].Value.ToString().Trim()); all.Add(row.Cells["LOADVEHICLE_NO"].Value.ToString().Trim()); all.Add(row.Cells["JUDGE_STOVE_NO"].Value.ToString().Trim()); all.Add(row.Cells["BATCH_NO"].Value.ToString().Trim()); all.Add(row.Cells["GROUP_NO"].Value.ToString().Trim()); all.Add(row.Cells["SEND_NUM"].Value.ToString().Trim()); all.Add(row.Cells["THEORY_WEIGHT"].Value.ToString().Trim()); all.Add(row.Cells["HOOK_WEIGHT"].Value.ToString().Trim()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad"; ccp.MethodName = "insertHookWeight"; ccp.ServerParams = new object[] { all }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); } MessageBox.Show("增加成功!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraGrid2_AfterRowActivate(sender,e); } /// /// 装车单二维码打印 /// private void doLoadPrint2() { string LoadNo = ""; UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; } int count = 0; foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) { count += 1; LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim(); } } if (count == 0) { MessageUtil.ShowTips("请选择要打印的装车单号!"); return; } if (count > 1) { MessageUtil.ShowTips("请勾选一个装车单打印!"); return; } string LOADVEHICLE_NO = "T:" + LoadNo; string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpOutList2.cpt&OUTSTOCK_DOC=" + LOADVEHICLE_NO; FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); //fBug.WindowState = FormWindowState.Maximized; fBug.Text = "二维码"; fBug.ShowDialog(); doQuery(); } private void doZbsPrint() { string LoadNo = ""; string metricSystemNo = ""; string zbsEdition = ""; string isVehicleNo = ""; string tsMemo = ""; string address = ""; UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; } int count = 0; foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) { count += 1; LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim(); } } if (count == 0) { MessageUtil.ShowTips("请选择要打印的装车单号!"); return; } if (count > 1) { MessageUtil.ShowTips("请勾选一个装车单打印!"); return; } ArrayList list = new ArrayList(); list.Add(ugr.Cells["LOADVEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["BILL_NO"].Text.Trim()); list.Add(ugr.Cells["VEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim()); DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryMativery", new object[] { list }, ob); if (dt1.Rows.Count == 0) { MessageUtil.ShowTips("发货实绩无数据,不能打印!"); return; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepCertificateOfProductQualityTHOutBill.cpt&" + "&OUT_BILLNO=" + LoadNo + "&ORD_LN_PK=" + dt1.Rows[0]["ORD_LN_PK"].ToString() + "&ASK_ITEM_NO=" + 1210070400000001 + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ZBS_EDITION=" + zbsEdition + "&TYPE=ZB&ORD_LN_DLY_PK=" + dt1.Rows[0]["ORD_LN_DLY_PK"].ToString() + "&IS_VEHICLE_NO=" + isVehicleNo + "&TS_MEMO=" + tsMemo + "&ADDRESS=" + address; FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); //fBug.WindowState = FormWindowState.Maximized; fBug.Text = "随车质保书打印"; fBug.ShowDialog(); doQuery(); } private void doLoadPrint() { string LoadNo = ""; UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; } int count = 0; foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) { count += 1; LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim(); } } if (count == 0) { MessageUtil.ShowTips("请选择要打印的装车单号!"); return; } if (count >1) { MessageUtil.ShowTips("请勾选一个装车单打印!"); return; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepYdmLoad.cpt&op=view"+"&no="+LoadNo; string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ServerHelper.SetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.updatePintFlag", new object[] { time, LoadNo }, ob); FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); //fBug.WindowState = FormWindowState.Maximized; fBug.Text = "装车单打印"; fBug.ShowDialog(); doQuery(); } //确认有效 private void doConfirm() { ArrayList list = new ArrayList(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("请选择要操作的记录数!"); return; } UltraGridRow ugr2 = this.ultraGrid2.ActiveRow; if (ugr2 != null && ugr2.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120504")) { string billNo = ""; string tallysheetNo = ""; string loadvehicleNo = ""; string judgeStoveNo = ""; string batchNo = ""; string groupNo = ""; int i = 0; int countHW = 0; foreach (UltraGridRow row in ultraGrid2.Rows) { //if (row.Cells["PONDER_NO"].Text.Trim().Equals("")) { // MessageUtil.ShowTips("未过磅不能确认!"); // return; //} billNo = row.Cells["BILL_NO"].Text.Trim(); tallysheetNo = row.Cells["TALLYSHEET_NO"].Text.Trim(); loadvehicleNo = row.Cells["LOADVEHICLE_NO"].Text.Trim(); judgeStoveNo = row.Cells["JUDGE_STOVE_NO"].Text.Trim(); batchNo = row.Cells["BATCH_NO"].Text.Trim(); groupNo = row.Cells["GROUP_NO"].Text.Trim(); ArrayList all = new ArrayList(); all.Add(billNo); all.Add(tallysheetNo); all.Add(loadvehicleNo); all.Add(judgeStoveNo); all.Add(batchNo); all.Add(groupNo); countHW += int.Parse(ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.selCountHookWeight", new Object[] { all }, this.ob).Rows[0][0].ToString()); i++; } //if (countHW != i) { // MessageUtil.ShowTips("未保存钩子称重量!"); // return; //} } string[] judgeStates; if (ucType.Value == null) { judgeStates = new string[0]; } else { judgeStates = ((List)ucType.Value).Select(a => a.ToString()).ToArray(); } //DateTime now = DateTime.Now; //DateTime d1 = new DateTime(now.Year, now.Month, 1); //DateTime dateFirst = now.Date; //TimeSpan ts = dateFirst.Subtract(d1); //if (ts.Days == 0) //{ DataTable dt=new DataTable(); //} int count = 0; string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); foreach (UltraGridRow row in ultraGrid1.Rows) { if(Convert.ToBoolean(row.Cells["CHK"].Text)==true) { //if (!doAddFlag(row)) return; //DataTable dtFlag = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBillCFlag", new object[] { row.Cells["BILL_NO"].Text.Trim() }, ob); //if (dtFlag.Rows[0]["PRT_FLAG"].ToString().Equals("1")) //{ // ArrayList pram = new ArrayList(); // pram.Add(row.Cells["LOADVEHICLE_NO"].Text.Trim()); // pram.Add(row.Cells["BILL_NO"].Text.Trim()); // pram.Add(row.Cells["TALLYSHEET_NO"].Text.Trim()); // pram.Add(row.Cells["VEHICLE_NO"].Text.Trim()); // DataTable dtPond = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryTallPond1", new object[] { pram }, ob); // if (dtPond.Rows.Count > 0) // { // if (dtPond.Rows[0]["PONDER_NO"].ToString() == "") // { // MessageUtil.ShowWarning("请输入过磅单号"); // return; // } // if (dtPond.Rows[0]["PONDER_GROSS_WT"].ToString() == "") // { // MessageUtil.ShowWarning("请输入过磅重量"); // return; // } // } //} DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBillType", new object[] { row.Cells["BILL_NO"].Text.Trim() }, ob); if (dt1.Rows.Count > 0) { if (int.Parse(dt1.Rows[0]["BILL_STATUS"].ToString()) >= 4) { MessageUtil.ShowWarning("您选择的提单不是执行状态,不能进行此操作!"); return; } if (dt1.Rows[0]["SUPPLY_UNIT"].ToString().Equals("120504")) { dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBaseInfo", new object[] { "800103" }, ob); } else if (dt1.Rows[0]["SALE_ORG"].ToString().Equals("100102")) { dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBaseInfo", new object[] { "800102" }, ob); } else { dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBaseInfo", new object[] { "800101" }, ob); } if (dt.Rows[0]["MEMO"].ToString().Equals("1")) { MessageUtil.ShowTips("当前正在结转确认,此功能暂停!"); return; } } count += 1; ArrayList list1 = new ArrayList(); list1.Add(row.Cells["LOADVEHICLE_NO"].Text.Trim()); list1.Add(row.Cells["BILL_NO"].Text.Trim()); list1.Add(row.Cells["TALLYSHEET_NO"].Text.Trim()); list1.Add(row.Cells["VEHICLE_NO"].Text.Trim()); list1.Add(this.UserInfo.GetUserName()); list1.Add(strTime); list1.Add(this.UserInfo.GetUserOrder()); list1.Add(this.UserInfo.GetUserGroup()); list1.Add(this.UserInfo.GetUserID()); list.Add(list1); } } if (count==0) { MessageUtil.ShowTips("请选择要要操作记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认有效?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); //if (Acasing.Checked) //{ // ccp.ServerName = "com.steering.pss.ydm.acasleavefactory.FrmCasLoad"; // ccp.MethodName = "updateDelConfirm"; //} //else //{ ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad"; ccp.MethodName = "updateDelConfirm"; //} ccp.ServerParams = new object[] { list, judgeStates }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("确认成功!")) { doQuery(); } } //查询 private void doQuery() { ArrayList pram = new ArrayList(); if (!CheckQuery()) return; string strStorage = ""; string prdcls = ""; if (chkStrong.Checked) { strStorage = cmbStorager.Value.ToString(); } if (!chkbillList.Checked) { strBill = ""; } else { strBill = txtBillList.Text.Trim(); } if (!chkLoad.Checked) { strLoad = ""; } else { strLoad = txtLoad.Value.ToString(); } if (!chkCarNo.Checked) { strCar = ""; } else { strCar = txtCar.Text.Trim(); } if (!chkReceiv.Checked) { strReceiv = ""; } else { strReceiv = cmbReceiv.Value.ToString(); } string strOutStart = ""; string strOutEnd = ""; if (OutTime.Checked) { strOutStart = OutStartTime.Value.ToString(); strOutEnd = OutEndTime.Value.ToString(); } string straff = ""; if (chkAffirm.Checked) { straff = cmbAffirm.Value.ToString(); } if (Acasing.Checked) { prdcls = "405005"; } string carNo = ""; if (chkCar.Checked) { carNo = Car_text.Text.Trim(); } pram.Add(strLoad); pram.Add(strBill); pram.Add(strCar); pram.Add(strReceiv); pram.Add(strOutStart); pram.Add(strOutStart); pram.Add(strOutStart); pram.Add(strOutEnd); pram.Add(strOutEnd); pram.Add(straff); pram.Add(carNo); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryDelivery", new object[] { pram, _storagerPur, strStorage, prdcls }, ob); GridHelper.CopyDataToDatatable(dt, this.dataLoad, true); this.ultraGrid1.DisplayLayout.Bands[0].Columns["INFACTORY_TIME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INFACTORY_TIME"].MaskInput = "yyyy-mm-dd hh:mm:ss"; this.ultraGrid1.DisplayLayout.Bands[0].Columns["DELIVY_TIME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime; this.ultraGrid1.DisplayLayout.Bands[0].Columns["DELIVY_TIME"].MaskInput = "yyyy-mm-dd hh:mm:ss"; if (dt.Rows.Count > 0) { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["LOADVEHICLE_NO"].Value.ToString() == index) { UltraGridRow row = ultraGrid1.Rows[i]; row.Activate(); } } } if (dt.Rows.Count <= 0) { DataTable dtTa = new DataTable(); GridHelper.CopyDataToDatatable(dtTa, this.dataTable1, true); } index = ""; } //取消确认 private void doCancelConfirm() { ArrayList list = new ArrayList(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("请选择要操作的记录数!"); return; } int count = 0; string moth = ""; string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBaseInfo", new object[] { "800101" }, ob); if (dt.Rows[0]["MEMO"].ToString().Equals("1")) { MessageUtil.ShowTips("当前正在结转确认,此功能暂停!"); return; } foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) { count += 1; DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryAppFlag", new object[] { row.Cells["loadvehicle_no"].Text.Trim() }, ob); if (dt1.Rows.Count > 0) { if (dt1.Rows[0]["AFFIRM_FLAG"].ToString().Equals("0")) { MessageUtil.ShowTips("您选择的记录未确认,请重新选择!"); return; } } DataTable dt2 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryBillType", new object[] { row.Cells["BILL_NO"].Text.Trim() }, ob); if (dt2.Rows.Count > 0) { if (dt2.Rows[0]["BILL_STATUS"].ToString() != "3") { MessageUtil.ShowWarning("您选择的该记录提单不是执行状态,不能进行此操作!"); return; } } ArrayList parm = new ArrayList(); parm.Add(row.Cells["BILL_NO"].Text.Trim()); parm.Add(row.Cells["TALLYSHEET_NO"].Text.Trim()); parm.Add(row.Cells["loadvehicle_no"].Text.Trim()); DataTable dg = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.selectYearMoth", new object[] { parm }, ob); if (int.Parse(dg.Rows[0]["ACOUNT"].ToString()) > 0) { MessageUtil.ShowTips("该提货单【" + row.Cells["BILL_NO"].Text.Trim() + "】对应的炉批信息已进行结转,不允许撤销!"); return; } ArrayList list1 = new ArrayList(); list1.Add(row.Cells["loadvehicle_no"].Text.Trim()); list1.Add(row.Cells["BILL_NO"].Text.Trim()); list1.Add(row.Cells["TALLYSHEET_NO"].Text.Trim()); list1.Add(row.Cells["VEHICLE_NO"].Text.Trim()); list1.Add(this.UserInfo.GetUserName()); list1.Add(strTime); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请选择要要操作记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); //if (Acasing.Checked) //{ // ccp.ServerName = "com.steering.pss.ydm.acasleavefactory.FrmCasLoad"; // ccp.MethodName = "updateDelCancel"; //} //else { ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad"; ccp.MethodName = "updateDelCancel"; //} ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("取消确认成功!")) { doQuery(); } //int upcount= ServerHelper.SetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.updateDelCancel", new object[] { list }, ob); //if (upcount>0) //{ // MessageUtil.ShowTips("取消确认成功!"); // doQuery(); //} } //修改 private void doUpdate() { ultraGrid1.UpdateData(); ultraGrid2.UpdateData(); ArrayList pram = new ArrayList(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; string inTime = "";//进厂时间 string outTime = "";//出厂时间 int intCount = 0;//判断选择是否打钩 int Iscount = 0;//打钩修改 if (ugr == null) { MessageUtil.ShowTips("请选择要操作的记录数!"); return; } foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) { intCount += 1; Iscount += 1; } } if (intCount > 1) { MessageUtil.ShowTips("请选择一条数据进行修改!"); return; } if (Iscount == 0) { MessageUtil.ShowTips("请选择要修改的记录!"); return; } string loadNo = ""; foreach (UltraGridRow row1 in ultraGrid1.Rows) { if (Convert.ToBoolean(row1.Cells["CHK"].Text) == true) { if (!doAddFlag(row1)) return; if (row1.Cells["INFACTORY_TIME"].Text != "" && row1.Cells["DELIVY_TIME"].Text != "") { DateTime dt1 = DateTime.Parse(row1.Cells["INFACTORY_TIME"].Text); DateTime dt2 = DateTime.Parse(row1.Cells["DELIVY_TIME"].Text); if (DateTime.Compare(dt1, dt2) >= 0) { MessageUtil.ShowTips("出厂时间不能小于进厂时间!"); return; } inTime = dt1.ToString();//进厂时间 outTime = dt2.ToString();//出厂时间 } pram.Clear(); pram.Add(row1.Cells["VEHICLE_NO"].Text.Trim()); pram.Add(inTime);//进厂时间 pram.Add(outTime);//出厂时间 pram.Add(row1.Cells["MEMO"].Text.Trim()); pram.Add(row1.Cells["LOADVEHICLE_NO"].Text.Trim()); loadNo = row1.Cells["LOADVEHICLE_NO"].Text.Trim(); } } ArrayList listAll = new ArrayList(); //从表数据 string strTime = DateTime.Now.ToString(); string strWeight = "";//过磅重量 string strBalNo = "";//过磅单号 foreach (UltraGridRow row2 in ultraGrid2.Rows) { if (loadNo != row2.Cells["LOADVEHICLE_NO"].Text.Trim()) { MessageUtil.ShowTips("不是勾选下的装车单信息!"); return; } if (row2.Cells["WEIGH_FLAG"].Text.Trim().Equals("否") && !row2.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120504")) { //if (row2.Cells["WEIGH_FLAG"].Text.Trim().Equals("铁运")) //{ //strWeight = row2.Cells["PONDER_GROSS_WT"].Value.ToString(); //strBalNo = row2.Cells["PONDER_NO"].Text.Trim(); //} //else //{ //strWeight = ""; //strBalNo = ""; //} if (!row2.Cells["PONDER_NO"].Text.Trim().Equals("") || !row2.Cells["PONDER_GROSS_WT"].Text.Trim().Equals("0.000")) { MessageUtil.ShowTips("不需要过磅,不能进行此操作!"); return; } } else { if (row2.Cells["PONDER_GROSS_WT"].Text.Trim() == "") { MessageUtil.ShowTips("过磅重量不能为空,请输入!"); return; } if (double.Parse(row2.Cells["PONDER_GROSS_WT"].Text.Trim()) == 0) { MessageUtil.ShowTips("过磅重量为零,请重新输入!"); return; } if (row2.Cells["PONDER_NO"].Text.Trim() == "") { MessageUtil.ShowTips("过磅单号不能为空,请输入!"); return; } strWeight = row2.Cells["PONDER_GROSS_WT"].Value.ToString(); strBalNo = row2.Cells["PONDER_NO"].Text.Trim(); #region 判断过磅单号是否重复 DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryTallPond", new object[] { row2.Cells["PONDER_NO"].Text.Trim() }, ob); if (dt.Rows.Count > 0) { if (dt.Rows[0]["LOADVEHICLE_NO"].ToString().Trim() != row2.Cells["LOADVEHICLE_NO"].Text.Trim()) { if (dt.Rows[0]["PONDER_NO"].ToString().Trim() == row2.Cells["PONDER_NO"].Text.Trim()) { MessageUtil.ShowTips("您输入的过磅单号存在,请重新输入!"); return; } } } #endregion double inabs = Math.Abs(double.Parse(strWeight) - double.Parse(row2.Cells["ACT_WEIGHT"].Text.Trim())); if (inabs >= 1) { if (MessageUtil.ShowYesNoAndQuestion("炉号:" + row2.Cells["JUDGE_STOVE_NO"].Text.Trim() + ",批号:" + row2.Cells["BATCH_NO"].Text.Trim() + ",组号:" + row2.Cells["GROUP_NO"].Text.Trim() + ",过磅重量:" + row2.Cells["PONDER_GROSS_WT"].Text.Trim() + "(t),与实际重量:" + row2.Cells["ACT_WEIGHT"].Text.Trim() + "(t),相差" + inabs + "吨,是否继续") == DialogResult.No) return; } } ArrayList list = new ArrayList(); list.Add(ugr.Cells["VEHICLE_NO"].Text.Trim()); list.Add(this.UserInfo.GetUserName()); list.Add(strTime); list.Add(row2.Cells["LOADVEHICLE_NO"].Text.Trim()); list.Add(row2.Cells["BILL_NO"].Text.Trim()); list.Add(row2.Cells["TALLYSHEET_NO"].Text.Trim()); list.Add(row2.Cells["VEHICLE_NO"].Text.Trim()); list.Add(row2.Cells["JUDGE_STOVE_NO"].Text.Trim()); list.Add(row2.Cells["BATCH_NO"].Text.Trim()); list.Add(row2.Cells["GROUP_NO"].Text.Trim()); list.Add(row2.Cells["ORD_PK"].Text.Trim()); list.Add(row2.Cells["ORD_LN_PK"].Text.Trim()); list.Add(row2.Cells["ORD_LN_DLY_PK"].Text.Trim()); list.Add(strWeight); list.Add(row2.Cells["ACT_COUNT"].Text.Trim()); list.Add(strBalNo); list.Add(row2.Cells["STD_CODE"].Text.Trim()); list.Add(row2.Cells["LENFW"].Text.Trim().Split('-')[0]); list.Add(row2.Cells["LENFW"].Text.Trim().Split('-')[1]); list.Add(row2.Cells["STD_NAME"].Text.Trim()); list.Add(row2.Cells["LOCATION_NO"].Text.Trim()); listAll.Add(list); } if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.No) return; //pram.Add(txt_askid.Text.Trim()); int count = ServerHelper.SetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.updateDelivery", new object[] { pram, listAll }, ob); if (count >=0) { MessageUtil.ShowTips("修改成功!"); index = ugr.Cells["LOADVEHICLE_NO"].Text; doQuery(); } } /// /// 判断确认标志 /// /// /// private bool doAddFlag(UltraGridRow ugr) { DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryAppFlag", new object[] { ugr.Cells["LOADVEHICLE_NO"].Value.ToString() }, ob); if (dt.Rows.Count > 0) { if (dt.Rows[0]["AFFIRM_FLAG"].ToString().Equals("1")) { MessageUtil.ShowTips("您选择的记录已确认,不能进行此操作!"); return false; } } return true; } //刷新 private void doRefresh() { //收货单位 YdmBaseClass.InitComboEditor(cmbReceiv, "com.steering.pss.ydm.pipeleavefactory.FrmPipeSendList.queryCustomer", "CUSTOMER_NO", ob, false); } //查询时验证必填项 private bool CheckQuery() { if (DataTimeUtil.JudgeTime(DateTime.Parse(OutStartTime.Value.ToString()), DateTime.Parse(OutEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!"); return false; } if (chkStrong.Checked && string.IsNullOrEmpty(cmbStorager.Text.Trim())) { MessageBox.Show("请选择仓库!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkbillList.Checked && string.IsNullOrEmpty(txtBillList.Text.Trim())) { MessageBox.Show("请输入理货单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkLoad.Checked && string.IsNullOrEmpty(txtLoad.Text.Trim())) { MessageBox.Show("请输入装车单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkCarNo.Checked && string.IsNullOrEmpty(txtCar.Text.Trim())) { MessageBox.Show("请输入提货单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkReceiv.Checked && string.IsNullOrEmpty(cmbReceiv.Text.Trim())) { MessageBox.Show("请选择收货单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkCar.Checked && string.IsNullOrEmpty(Car_text.Text.Trim())) { MessageBox.Show("请选择车号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 验证Checked是否勾选,显示控件可编辑 打勾表示可编辑,不打勾表示不可编辑 /// /// /// private void chk_CheckedChanged(object sender, EventArgs e) { if (chkStrong.Checked) { cmbStorager.Enabled = true; } else { cmbStorager.Enabled = false; } if (chkbillList.Checked) { txtBillList.Enabled = true; } else { txtBillList.Enabled = false; } if (chkLoad.Checked) { txtLoad.Enabled = true; } else { txtLoad.Enabled = false; } if (chkCarNo.Checked) { txtCar.Enabled = true; } else { txtCar.Enabled = false; } if (chkReceiv.Checked) { cmbReceiv.Enabled = true; } else { cmbReceiv.Enabled = false; } if (OutTime.Checked) { OutStartTime.Enabled = true; OutEndTime.Enabled = true; } else { OutStartTime.Enabled = false; OutEndTime.Enabled = false; } if (chkAffirm.Checked) { cmbAffirm.Enabled = true; } else { cmbAffirm.Enabled = false; } if (chkCar.Checked) { Car_text.Enabled = true; } else { Car_text.Enabled = false; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { ultraGrid1.UpdateData(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (this.ultraGrid1.Rows.Count <= 0) return; if (ugr == null) return; if (ugr.IsFilterRow) return; if (ugr.HasParent() == true) return; ArrayList list = new ArrayList(); list.Add(ugr.Cells["LOADVEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["BILL_NO"].Text.Trim()); list.Add(ugr.Cells["VEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim()); DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryMativery", new object[] { list }, ob); GridHelper.CopyDataToDatatable(dt1, this.dataTable1, true); foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120501")) { row.Cells["PONDER_GROSS_WT"].Activation = Activation.ActivateOnly; row.Cells["PONDER_NO"].Activation = Activation.ActivateOnly; } else if (row.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120504")) { row.Cells["PONDER_GROSS_WT"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["PONDER_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); } if (UserInfo.GetUserName() == "admin" || row.Cells["IS_OVERSTOCK"].Value.ToString2().Equals("1")) { row.Cells["PONDER_GROSS_WT"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["PONDER_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["PONDER_GROSS_WT"].Activation = Activation.AllowEdit; row.Cells["PONDER_NO"].Activation = Activation.AllowEdit; } } this.dataTable1.AcceptChanges(); } /// /// 托选 /// /// /// private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { //try //{ // ultraGrid1.UpdateData(); // foreach (UltraGridRow r in ultraGrid1.Rows) // { // r.Cells["CHK"].Value = r.Selected; // } //} //catch { } foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } /// /// 按回车键触发查询按钮 /// /// /// private void ContPublic_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { doQuery(); } } private void ultraGrid1_BeforeRowDeactivate(object sender, CancelEventArgs e) { int changeCnt = dataTable1.Rows.Cast().Where(a=> a.RowState == DataRowState.Modified).Count(); if (changeCnt > 0) { if (MessageUtil.ShowYesNoAndQuestion("是否放弃当前编辑?") == DialogResult.No) { e.Cancel = true; } } } private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e) { e.RaiseErrorEvent = false; } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { ArrayList list = new ArrayList(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; list.Add(ugr.Cells["LOADVEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["BILL_NO"].Text.Trim()); list.Add(ugr.Cells["VEHICLE_NO"].Text.Trim()); list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim()); if (ultraGrid2.ActiveRow.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120501")) { ultraExpandableGroupBox3.Visible = false; } else if (ultraGrid2.ActiveRow.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120504")) { ultraExpandableGroupBox3.Visible = true; DataTable dt2 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryMativery_Hw", new object[] { list }, ob); GridHelper.CopyDataToDatatable(dt2, this.dataTable2, true); } } } }