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.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinGrid; using System.Collections; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Core.StlMes.Client.PipeLeaveFactory.YdmObject; using Infragistics.Win; using Core.Mes.Client.Comm.Format; using Core.StlMes.Client.YdmPipeManage.Tool; using Core.StlMes.Client.PipeLeaveFactory.Tool; using Core.StlMes.Client.YdmPipeManage; using Core.StlMes.Client.PipeLeaveFactory.Dialog; using Core.StlMes.Client.SaleOrder.ReviewForm; namespace Core.StlMes.Client.PipeLeaveFactory { public partial class frmPipeEntruck : FrmBase { /// /// 获取仓库权限 /// private string[] _storagerPur; ArrayList pram = new ArrayList(); private string departid;//对应部门ID private string departname;//对应部门 private string management_no;//对应科室id private string management_name;//对应科室 private string carrierCode = ""; private string carrierName = ""; string index = "";//定位 public frmPipeEntruck() { InitializeComponent(); this.IsLoadUserView = true; } private void frmPipeEntruck_Load(object sender, EventArgs e) { doCar(); DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 ultStartDate.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); ultEndDate.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); ClsBaseInfo.SetComboItemHeight(cmbStatus); _storagerPur = BaseMethod.WarehousePermissions("", this.ValidDataPurviewIds, ob); BaseMethod.InitStorage(cmbStorager, "", this.ValidDataPurviewIds, ob); BaseHelper.InitCellPosition(ultraGrid2, new string[] { "ACT_COUNT", "ACT_WEIGHT", "BEEN_COUNT", "BEEN_WEIGHT", "PREP_COUNT", "PREP_WEIGHT", "ACT_THEORY_WEIGHT" }); BaseHelper.InitCellPosition(ultraGrid3, new string[] { "STACKING_PIECE", "STACKING_WT" }); BaseHelper.InitCellPosition(ultraGrid4, new string[] { "ACT_COUNT", "ACT_WEIGHT", }); management_no = this.UserInfo.GetDeptid(); management_name = this.UserInfo.GetDepartment(); departid = ClsBaseInfo.GetDepartIdBySectionId(UserInfo.GetDeptid(), this.ob); departname = ClsBaseInfo.GetDepartBySectionId(UserInfo.GetDeptid(), this.ob); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": doAdd(); break; case "Delete":// 作废 doDelete(); break; case "TallyClose"://理货关闭 doTallyClose(); break; case "LoadPrint"://装车单打印 doLoadPrint(); break; case "Refresh"://刷新 doRefresh(); break; case "Export"://导出 GridHelper.ulGridToExcel(ultraGrid3, "装车实绩信息"); break; case "Close": this.Close(); break; } } private void doLoadPrint() { string LoadNo = ""; UltraGridRow ugr = this.ultraGrid3.ActiveRow; if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; } int count = 0; foreach (UltraGridRow row in ultraGrid3.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=RepYdmLoadTH.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 doCar() { UltraGridRow ugrList = this.ultraGrid1.ActiveRow; if (ugrList == null) return; ArrayList list = new ArrayList(); //list.Add(ugrList.Cells["BILL_NO"].Text.Trim()); list.Add(ugrList.Cells["TALLYSHEET_NO"].Text.Trim()); DataTable dtCar = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryTallyIn", new object[] { list }, ob); cmbCar.DataSource = dtCar; cmbCar.ValueMember="VEHICLE_NO"; cmbCar.SelectedIndex =0; ClsBaseInfo.SetComboItemHeight(cmbCar); } /// /// 查询 /// private void doQuery() { if (!ValidQuery()) return; string strStartTime = ""; string strEntTime = ""; string strBill = ""; string strSend = ""; string strLoadFlag = ""; string strStorage = ""; string strLoad = "";//装车单号 string strAff = "";//确认标志 string carNo = ""; //车号 if (chkStrong.Checked) { strStorage = cmbStorager.Value.ToString(); } if (chkDate.Checked) { strStartTime = ultStartDate.Value.ToString(); strEntTime = ultEndDate.Value.ToString(); } if(chkBillList.Checked) { strBill = txtBillList.Text.Trim(); } if(chkSendList.Checked) { strSend = txtSendList.Text.Trim(); } if (chkLand.Checked) { strLoadFlag = cmbStatus.Value.ToString(); } if (chkLoad.Checked) { strLoad = txtLoad.Text.Trim(); } if (chkAffirm.Checked) { strAff = cmbAffirm.Value.ToString(); } if (chkCar.Checked) { carNo = Car_text.Text.Trim(); } pram.Clear(); pram.Add(strBill); pram.Add(strSend); pram.Add(strStartTime); pram.Add(strStartTime); pram.Add(strStartTime); pram.Add(strEntTime); pram.Add(strEntTime); if (ultraTabControl1.SelectedTab.Key.Equals("0")) { DataTable dtBill = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryTallyInfo", new object[] { pram, strLoadFlag, _storagerPur, strStorage }, ob); GridHelper.CopyDataToDatatable(dtBill, this.dataBiList, true); GridHelper.RefreshAndAutoSize(ultraGrid1); if (dtBill.Rows.Count <= 0) { DataTable dtTa = new DataTable(); GridHelper.CopyDataToDatatable(dtTa, this.dataOut, true); } else { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { string strindex = ultraGrid1.Rows[i].Cells["BILL_NO"].Value.ToString() + ultraGrid1.Rows[i].Cells["TALLYSHEET_NO"].Value.ToString(); if (strindex == index) { UltraGridRow row = ultraGrid1.Rows[i]; row.Activate(); } } } index = ""; } else { pram.Add(strLoad); pram.Add(strAff); pram.Add(carNo); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryDelivery", new object[] { pram, _storagerPur, strStorage}, ob); GridHelper.CopyDataToDatatable(dt, this.dataLoad, true); if (dt.Rows.Count <= 0) { DataTable dtTa = new DataTable(); GridHelper.CopyDataToDatatable(dtTa, this.dataTable1, true); } } } /// /// 新增 /// private void doAdd() { UltraGridRow ugrList = this.ultraGrid1.ActiveRow; if (ugrList == null) { MessageUtil.ShowTips("无理货信息,不能进行此操作!"); return; } //string LoadNo = ""; //if (txtLoadList.Text.Trim() == "") //{ doLoadNo(); } //LoadNo = txtLoadList.Text.Trim(); //if (txtLoadList.Text.Length<16) { MessageUtil.ShowTips("您输入的装车单不符合要求,请输入16位!"); return; } if (cmbCar.SelectedIndex == -1) { MessageUtil.ShowTips("请选择车船信息!"); return; } //if (txtLoadList.Text.Trim() == "") { MessageUtil.ShowTips("请选择装车单号!"); return; } int isSelect = 0;//新增 foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { isSelect += 1; } } if (isSelect == 0) { MessageUtil.ShowTips("请选择炉批信息!"); return; } DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryCar", new object[] { ugrList.Cells["BILL_NO"].Text.Trim(), ugrList.Cells["TALLYSHEET_NO"].Text.Trim(), cmbCar.Text.Trim() }, ob); if (dt.Rows.Count > 0) { if (dt.Rows[0]["AFFIRM_FLAG"].ToString() == "1") { MessageUtil.ShowWarning("您选择的车号已装车确认,请重新选择车号!"); return; } } DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryCarTally", new object[] { txtLoadList.Text.Trim()}, ob); if (dt1.Rows.Count > 0) { if (dt1.Rows[0]["VEHICLE_NO"].ToString() != cmbCar.Text.Trim()) { MessageUtil.ShowWarning("您输入的装车单号在[" + dt1.Rows[0]["VEHICLE_NO"].ToString() + "]该车号下存在,请重新输入!"); return; } } DataTable dtBill = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryBillType", new object[] { ugrList.Cells["BILL_NO"].Text.Trim() }, ob); if (dtBill.Rows.Count > 0) { if (dtBill.Rows[0]["BILL_STATUS"].ToString() == "提单关闭" && dtBill.Rows[0]["BILL_STATUS"].ToString() == "结算接收")//判断订单状态是否关闭,是否有效 { MessageUtil.ShowTips("该条记录已" + dtBill.Rows[0]["BILL_STATUS"].ToString() + ",不能进行此操作!"); return; } } else { MessageUtil.ShowTips("提单主表没有对应的提单信息!"); return; } DataTable dtTall = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryTallType", new object[] { ugrList.Cells["BILL_NO"].Text.Trim(), ugrList.Cells["TALLYSHEET_NO"].Text.Trim() }, ob); if (dtTall.Rows.Count > 0) { if (dtTall.Rows[0]["LOADVEHICLE_FLAG"].ToString() == "2") { MessageUtil.ShowWarning("您选择理货单号为[" + ugrList.Cells["TALLYSHEET_NO"].Text.Trim() + "]已理货关闭,不能进行此操作!"); return; } } string strCarryNo = ""; string strCarryNmae = ""; DataTable dtcy = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryTallyCar", new object[] {ugrList.Cells["TALLYSHEET_NO"].Text.Trim(),cmbCar.Text.Trim() }, ob); if (dtcy.Rows.Count > 0) { strCarryNo = dtcy.Rows[0]["CARRY_COMPANY_CODE"].ToString(); strCarryNmae = dtcy.Rows[0]["CARRY_COMPANY_NAME"].ToString(); } #region 新增到装车材料表 ArrayList listAll = new ArrayList(); string strEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//装车时间 foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true) { if (double.Parse(uRow.Cells["PREP_WEIGHT"].Text.Trim()) <0) { MessageUtil.ShowTips("您选择的数据计算错误,不能进行此操作!"); return; } if (double.Parse(uRow.Cells["PREP_COUNT"].Value.ToString()) <= 0) { MessageUtil.ShowTips("可装车量为零,不能进行此操作!"); uRow.Cells["CHOOSE"].Value = false; return; } ArrayList list = new ArrayList(); list.Add(uRow.Cells["PREP_COUNT"].Value.ToString()); list.Add(ugrList.Cells["BILL_NO"].Text.Trim()); list.Add(ugrList.Cells["TALLYSHEET_NO"].Text.Trim()); list.Add(uRow.Cells["ORDER_NO"].Text.Trim()); list.Add(uRow.Cells["ORDER_SEQ"].Text.Trim()); list.Add(uRow.Cells["DELIVERY_NO"].Text.Trim()); list.Add(uRow.Cells["JUDGE_STOVE_NO"].Text.Trim()); list.Add(uRow.Cells["BATCH_NO"].Text.Trim()); list.Add(cmbCar.Text.Trim()); list.Add(txtLoadList.Text.Trim()); list.Add(this.UserInfo.GetUserName()); list.Add(this.UserInfo.GetUserOrder()); list.Add(this.UserInfo.GetUserGroup()); list.Add(uRow.Cells["PREP_WEIGHT"].Text.Trim()); list.Add(uRow.Cells["PREP_LEN"].Text.Trim()); list.Add(strEndTime); list.Add(strCarryNo); list.Add(strCarryNmae); list.Add(uRow.Cells["ORD_PK"].Text.Trim()); list.Add(uRow.Cells["ORD_LN_PK"].Text.Trim()); list.Add(uRow.Cells["ORD_LN_DLY_PK"].Text.Trim()); list.Add(uRow.Cells["STORAGE_NO"].Text.Trim()); list.Add(management_no);//科室id list.Add(management_name);//科室 list.Add(departid);//部门id list.Add(departname);//部门 list.Add(uRow.Cells["GROUP_NO"].Text.Trim()); list.Add(uRow.Cells["LOCATION_NO"].Text); list.Add(uRow.Cells["MEMO"].Text); //list.Add(uRow.Cells["VSTEL"].Text.Trim()); //list.Add(uRow.Cells["VSTEL_DESC"].Text.Trim()); listAll.Add(list); } } #endregion #region 新增到装车实绩表 pram.Clear(); pram.Add(strCarryNo); pram.Add(strCarryNmae); pram.Add(""); pram.Add(""); pram.Add(ugrList.Cells["BILL_NO"].Text.Trim()); pram.Add(ugrList.Cells["TALLYSHEET_NO"].Text.Trim()); pram.Add(""); pram.Add("");//LoadNo pram.Add(cmbCar.Text.Trim()); pram.Add(this.UserInfo.GetUserName()); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(strEndTime); pram.Add(management_no);//科室id pram.Add(management_name);//科室 pram.Add(departid);//部门id pram.Add(departname);//部门 ArrayList craneList = new ArrayList(); craneList.Add(carrierCode); craneList.Add(carrierName); craneList.Add(cmCraneNo.Text.ToString2()); craneList.Add(cmbCraneUser.Tag.ToString2()); craneList.Add(cmbCraneUser.Text.ToString2()); //count = ServerHelper.SetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.addTallyLoad", new object[] { pram }, ob); #endregion if (MessageUtil.ShowYesNoAndQuestion("是否确认装车?") == DialogResult.No) return; try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck"; ccp.MethodName = "addTallyInfo"; ccp.ServerParams = new object[] { listAll, pram, ugrList.Cells["TALLYSHEET_NO"].Text.Trim(), txtLoadList.Text.Trim(), craneList }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); 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("装车成功!")) { index = ugrList.Cells["BILL_NO"].Text.Trim() + ugrList.Cells["TALLYSHEET_NO"].Text.Trim(); txtLoadList.Text = ""; doQuery(); } } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } } /// /// 作废 /// private void doDelete() { UltraGridRow ugr = this.ultraGrid3.ActiveRow; int count = 0; int isDelete = 0;//废除 ArrayList listpram = new ArrayList(); string strTime = DateTime.Now.ToString(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid3.Rows) { if (Convert.ToBoolean(uRow.Cells["CHK"].Text) == true) { isDelete += 1; pram.Clear(); pram.Add(uRow.Cells["LOADVEHICLE_NO"].Value.ToString()); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryAppFlag", new object[] { pram }, ob); if (dt.Rows.Count > 0) { if (dt.Rows[0]["AFFIRM_FLAG"].ToString().Equals("1")) { MessageUtil.ShowTips("您选择的记录已确认,不能进行此操作!"); return; } } DataTable dtBill = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryBillType", new object[] { uRow.Cells["BILL_NO"].Text.Trim() }, ob); if (dtBill.Rows.Count > 0) { if (dtBill.Rows[0]["BILL_STATUS"].ToString() == "提单关闭" || dtBill.Rows[0]["BILL_STATUS"].ToString() == "结算接收") { MessageUtil.ShowWarning("您选择记录已" + dtBill.Rows[0]["BILL_STATUS"].ToString() + ",不能进行此操作!"); return; } } ArrayList list = new ArrayList(); list.Add(uRow.Cells["LOADVEHICLE_NO"].Text.Trim()); list.Add(uRow.Cells["BILL_NO"].Text.Trim()); list.Add(uRow.Cells["TALLYSHEET_NO"].Text.Trim()); list.Add(uRow.Cells["VEHICLE_NO"].Text.Trim()); list.Add(this.UserInfo.GetUserName()); list.Add(strTime); listpram.Add(list); } } if (isDelete == 0) { MessageUtil.ShowTips("请选择要删除的装车信息!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销装车?") == DialogResult.No) return; try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck"; ccp.MethodName = "upDateInfo"; ccp.ServerParams = new object[] { listpram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); 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(); } } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } } /// /// 理货关闭 /// private void doTallyClose() { UltraGridRow ugrList = this.ultraGrid1.ActiveRow; if (ugrList == null) { MessageUtil.ShowTips("无理货信息,不能进行此操作!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否关闭理货单号为:" + ugrList.Cells["TALLYSHEET_NO"].Text.Trim() + "该理货单") == DialogResult.No) return; ArrayList listm = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid2.Rows) { if (uRow == null) return; ArrayList listc = new ArrayList(); listc.Add(ugrList.Cells["TALLYSHEET_NO"].Text.Trim()); listc.Add(ugrList.Cells["BILL_NO"].Text.Trim()); listc.Add(uRow.Cells["JUDGE_STOVE_NO"].Text.Trim()); listc.Add(uRow.Cells["BATCH_NO"].Text.Trim()); listc.Add(uRow.Cells["GROUP_NO"].Text.Trim()); listc.Add(uRow.Cells["ORD_PK"].Text.Trim()); listc.Add(uRow.Cells["ORD_LN_PK"].Text.Trim()); listc.Add(uRow.Cells["ORD_LN_DLY_PK"].Text.Trim()); listm.Add(listc); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck"; ccp.MethodName = "tallyClose"; ccp.ServerParams = new object[] { listm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("关闭成功!")) { index = ugrList.Cells["BILL_NO"].Text.Trim() + ugrList.Cells["TALLYSHEET_NO"].Text.Trim(); doQuery(); } } /// /// 刷新 /// private void doRefresh() { doCar(); txtLoadList.Text = ""; } /// /// 查询时验证必填项 /// /// private bool ValidQuery() { if (chkDate.Checked) { if (DataTimeUtil.JudgeTime(DateTime.Parse(ultStartDate.Value.ToString()), DateTime.Parse(ultEndDate.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 (chkSendList.Checked && string.IsNullOrEmpty(txtSendList.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; } 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 (chkSendList.Checked) { txtSendList.Enabled = true; } else { txtSendList.Enabled = false; } if (chkDate.Checked) { ultStartDate.Enabled = true; ultEndDate.Enabled = true; } else { ultStartDate.Enabled = false; ultEndDate.Enabled = false; } if (chkAffirm.Checked) { cmbAffirm.Enabled = true; } else { cmbAffirm.Enabled = false; } if (chkLoad.Checked) { txtLoad.Enabled = true; } else { txtLoad.Enabled = false; } if (chkLand.Checked) { cmbStatus.Enabled = true; } else { cmbStatus.Enabled = false; } if (chkCar.Checked) { Car_text.Enabled = true; } else { Car_text.Enabled = false; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { LoadMat(); } /// /// 绑定车船号和炉批信息 /// private void LoadMat() { UltraGridRow ugr = this.ultraGrid1.ActiveRow; UltraGridRow aRow = this.ultraGrid1.GetRow(ChildRow.First); if (this.ultraGrid1.Rows.Count <= 0) return; if (ugr == null) return; if (ugr.IsFilterRow) return; string strLoadFlag = ""; if (chkLand.Checked) { strLoadFlag = cmbStatus.Value.ToString(); } ArrayList list = new ArrayList(); list.Add(ugr.Cells["BILL_NO"].Text.Trim()); list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim()); DataTable dtTa = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryTallyInfoMat", new object[] { list,strLoadFlag }, ob); GridHelper.CopyDataToDatatable(dtTa, this.dataOut, true); this.dataOut.AcceptChanges(); cmbCar.Clear(); doCar(); txtBillListEdi.Text = ugr.Cells["BILL_NO"].Text.Trim(); txtSendListEdi.Text = ugr.Cells["TALLYSHEET_NO"].Text.Trim(); } /// /// 选择下一车时自动获取装车单号 /// /// /// private void doLoadNo() { if (txtSendListEdi.Text.Trim() == "") return; string strTallyLoad = ""; pram.Clear(); pram.Add(txtSendListEdi.Text.Trim()); //pram.Add(DateTime.Now.ToString("yyyy-MM-dd")); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.querySendList", new object[] { pram }, ob); if (dt.Rows.Count <= 0)//没有:理货单号+2位流水 有:获取装车单号+1 { strTallyLoad = txtSendListEdi.Text.Trim() + "01"; } else { string dtSendList = dt.Rows[0]["LOADVEHICLE_NO"].ToString(); string SendListlsh = dtSendList.Substring(dtSendList.Length-2, 2); string strLsh = "";//流水号 if (double.Parse(SendListlsh) < 9) { strLsh = "0" + Convert.ToDouble(double.Parse(SendListlsh) + 1).ToString(); } else { strLsh = Convert.ToDouble(double.Parse(SendListlsh) + 1).ToString(); } strTallyLoad = txtSendListEdi.Text.Trim() + strLsh; } DataTable dt2 = (DataTable)txtLoadList.DataSource; Object[] obj = new Object[] { strTallyLoad }; DataRow dr = dt2.NewRow(); dr.ItemArray = obj; if (dt2.Rows.Count > 0) { if (strTallyLoad != dt2.Rows[0]["LOADVEHICLE_NO"].ToString()) { dt2.Rows.InsertAt(dr, 0); } } else { dt2.Rows.InsertAt(dr, 0); } txtLoadList.SelectedIndex = 0; } private void frmPipeStow_Shown(object sender, EventArgs e) { if (toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (e.Tab.TabControl.SelectedTab.Key.Equals("0")) { if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Add")) { toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("TallyClose")) { toolMenu.Toolbars[0].Tools["TallyClose"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("LoadPrint")) { toolMenu.Toolbars[0].Tools["LoadPrint"].InstanceProps.Visible = DefaultableBoolean.False; } chkLand.Visible = true; cmbStatus.Visible = true; chkLoad.Visible = false; txtLoad.Visible = false; chkAffirm.Visible = false; cmbAffirm.Visible = false; chkCar.Visible = false; Car_text.Visible = false; } else { if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Add")) { toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("TallyClose")) { toolMenu.Toolbars[0].Tools["TallyClose"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("LoadPrint")) { toolMenu.Toolbars[0].Tools["LoadPrint"].InstanceProps.Visible = DefaultableBoolean.True; } chkLand.Visible = false; cmbStatus.Visible = false; chkLoad.Visible = true; txtLoad.Visible = true; chkAffirm.Visible = true; cmbAffirm.Visible = true; chkCar.Visible = true; Car_text.Visible = true; } } /// /// Grid 列改变事件 /// /// /// private void ultraGrid2_CellChange(object sender, CellEventArgs e) { ultraGrid2.UpdateData(); UltraGridRow ugr1 = ultraGrid1.ActiveRow; UltraGridRow ugr = ultraGrid2.ActiveRow; string actcount = ugr.Cells["ACT_COUNT"].Value.ToString();//理货量 string plannum = ugr.Cells["PREP_COUNT"].Value.ToString();//未装车量 string beencount = ugr.Cells["BEEN_COUNT"].Value.ToString();//已装车量 if (plannum == "") { plannum = "0"; ugr.Cells["PREP_COUNT"].Value = "0"; } if (e.Cell.Column.Key.Equals("PREP_COUNT")) { if (plannum != "" && plannum != "0") { if (Convert.ToInt32(plannum) > Convert.ToInt32(actcount) - Convert.ToInt32(beencount)) { MessageUtil.ShowWarning("可装车量不能大于理货量与已装车量之差!"); ugr.Cells["PREP_COUNT"].Value = (double.Parse(ugr.Cells["ACT_COUNT"].Value.ToString()) - double.Parse(ugr.Cells["BEEN_COUNT"].Value.ToString())).ToString(); ugr.Cells["PREP_WEIGHT"].Value = (double.Parse(ugr.Cells["ACT_WEIGHT"].Value.ToString()) - double.Parse(ugr.Cells["BEEN_WEIGHT"].Value.ToString())).ToString("f3"); ugr.Cells["PREP_LEN"].Value = (double.Parse(ugr.Cells["ACT_LEN"].Value.ToString()) - double.Parse(ugr.Cells["BEEN_LEN"].Value.ToString())).ToString("f2"); return; } } #region 获取库存每一支的重量 ArrayList list = new ArrayList(); list.Add(ugr1.Cells["BILL_NO"].Text.Trim()); list.Add(ugr1.Cells["TALLYSHEET_NO"].Text.Trim()); list.Add(ugr.Cells["JUDGE_STOVE_NO"].Text.Trim()); list.Add(ugr.Cells["BATCH_NO"].Text.Trim()); list.Add(ugr.Cells["STORAGE_NO"].Text.Trim()); //list.Add(ugr.Cells["ORD_PK"].Text.Trim()); //list.Add(ugr.Cells["ORD_LN_PK"].Text.Trim()); list.Add(ugr.Cells["ORD_LN_DLY_PK"].Text.Trim()); list.Add(ugr.Cells["GROUP_NO"].Text.Trim()); list.Add((double.Parse(ugr.Cells["PREP_COUNT"].Value.ToString()) + 1).ToString()); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryMatTallyC", new object[] { list }, ob); ugr.Cells["PREP_WEIGHT"].Value = dt.Rows[0]["ACT_WEIGHT"].ToString(); ugr.Cells["PREP_LEN"].Value = dt.Rows[0]["ACT_LEN"].ToString(); #endregion } } /// /// 托选 /// /// /// private void ultraGrid2_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { //try //{ // ultraGrid2.UpdateData(); // foreach (UltraGridRow r in ultraGrid2.Rows) // { // r.Cells["CHOOSE"].Value = r.Selected; // } //} //catch { } foreach (UltraGridRow uRow in ultraGrid2.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHOOSE"].Value = true; } } } private void ultraGrid3_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid3.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } private void cmbCar_ValueChanged(object sender, EventArgs e) { UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; ArrayList list = new ArrayList(); list.Add(ugr.Cells["BILL_NO"].Text.Trim()); list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim()); list.Add(cmbCar.Text.Trim()); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.queryCarLoad", new object[] { list }, ob); txtLoadList.DataSource = dt; txtLoadList.ValueMember = "LOADVEHICLE_NO"; Object[] obj = new Object[] { "" }; DataRow dr = dt.NewRow(); dr.ItemArray = obj; dt.Rows.Add(dr); } /// /// 按回车键触发查询按钮 /// /// /// private void ContPublic_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { doQuery(); } } private void ultraGrid1_BeforeRowDeactivate(object sender, CancelEventArgs e) { int changeCnt = dataOut.Rows.Cast().Where(a => a.RowState == DataRowState.Modified).Count(); if (changeCnt > 0) { if (MessageUtil.ShowYesNoAndQuestion("是否放弃当前编辑?") == DialogResult.No) { e.Cancel = true; } } } private void ultraGrid3_AfterRowActivate(object sender, EventArgs e) { ultraGrid3.UpdateData(); UltraGridRow ugr = ultraGrid3.ActiveRow; if (this.ultraGrid3.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); } private void cmbCar_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow ugrList = this.ultraGrid1.ActiveRow; if (ugrList == null) { MessageUtil.ShowTips("无数据!"); return; } FrmTallCar fBug = new FrmTallCar(this.ob, ugrList.Cells["BILL_NO"].Text.Trim(), ugrList.Cells["TALLYSHEET_NO"].Text.Trim(), ugrList.Cells["SUPPLY_UNIT"].Text.Trim()); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.Text = "增加车号"; fBug.ShowDialog(); doCar(); } private void cmCraneNo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) { return; } this.ultraGrid3.UpdateData(); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.doQueryCrane", new object[] { }, ob); dt.Columns["CAR_LICENSE"].Caption = "吊车车牌号"; dt.Columns["CARRIER_CODE"].Caption = "承运商代码"; dt.Columns["CARRIER_NAME"].Caption = "承运商"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "CAR_LICENSE", "CAR_NO", "CARRIER_CODE", "CARRIER_NAME"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("CAR_NO") == this.cmCraneNo.Tag.ToString2()).FirstOrDefault(); if (actRow != null) actRow.Activate(); }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { cmCraneNo.Tag = baseInfo.ChoicedRow.GetValue("CAR_NO"); cmCraneNo.Text = baseInfo.ChoicedRow.GetValue("CAR_LICENSE"); carrierCode = baseInfo.ChoicedRow.GetValue("CARRIER_CODE"); carrierName = baseInfo.ChoicedRow.GetValue("CARRIER_NAME"); } } private void cmbCraneUser_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) { return; } this.ultraGrid3.UpdateData(); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeEntruck.doQueryDrive", new object[] { }, ob); dt.Columns["DRIVER_NAME"].Caption = "司机"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "DRIVER_NAME", "DRIVER_CODE"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("DRIVER_CODE") == this.cmbCraneUser.Tag.ToString2()).FirstOrDefault(); if (actRow != null) actRow.Activate(); }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { cmbCraneUser.Tag = baseInfo.ChoicedRow.GetValue("DRIVER_CODE"); cmbCraneUser.Text = baseInfo.ChoicedRow.GetValue("DRIVER_NAME"); } } private void ultraButton1_Click(object sender, EventArgs e) { this.cmCraneNo.Tag = ""; this.cmCraneNo.Text = ""; this.cmbCraneUser.Tag = ""; this.cmbCraneUser.Text = ""; carrierCode = ""; carrierName = ""; } private void ultraGrid4_ClickCellButton(object sender, CellEventArgs e) { if (ultraGrid3.ActiveRow == null) return; if (ultraGrid4.ActiveRow == null) return; string locNo = ultraGrid3.ActiveRow.Cells["LOADVEHICLE_NO"].Value.ToString(); string judgeNo = ultraGrid4.ActiveRow.Cells["JUDGE_STOVE_NO"].Value.ToString(); string batchNo = ultraGrid4.ActiveRow.Cells["BATCH_NO"].Value.ToString(); string groupNo = ultraGrid4.ActiveRow.Cells["GROUP_NO"].Value.ToString(); string ordLnDlyPk = ultraGrid4.ActiveRow.Cells["ORD_LN_DLY_PK"].Value.ToString(); FrmLocInfo loc = new FrmLocInfo(locNo, judgeNo, batchNo, groupNo, ordLnDlyPk, this.ob); loc.ob = this.ob; loc.ShowDialog(); } } }