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.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using System.Collections; namespace Core.StlMes.Client.SaleBase { public partial class FrmBuyerSend : FrmBase { OpeBase ob = new OpeBase(); bool blValidating = false; // 验证状态返回 LX string customer_no = "";//客户编码 public string Customer_no { get { return customer_no; } set { customer_no = value; } } string sale_org = "";//销售组织 public string Sale_org { get { return sale_org; } set { sale_org = value; } } string custm_use = "";//用途类型 public string Custm_use { get { return custm_use; } set { custm_use = value; } } string region_no = "";//省市区域 public string Region_no { get { return region_no; } set { region_no = value; } } string strOperator = "";//登录名称 public string StrOperator { get { return strOperator; } set { strOperator = value; } } //收货单位扩展信息。 private DataTable _dtBuyerSend; public FrmBuyerSend(OpeBase ops) { this.ob = ops; InitializeComponent(); ExceptionHelper.RegistException(); } private void ultraToolbarsSend_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { ultraGridOrder.UpdateData(); //customer_no, sale_org, custm_use, region_no, address, consignee, phone, zip_code, fax, memo switch (e.Tool.Key) { case "Save": if (_dtBuyerSend.Rows.Count > 0) { if (_dtBuyerSend.Rows[0]["SALE_ORG"].ToString() != UserInfo.SaleOrg) { MessageUtil.ShowWarning("该条记录不是您所在的销售组织创建,无法进行修改!"); return; } } ultraExpandableGroupBox1.Focus(); if (blValidating == true) return; int countTable = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerSend.GetQueryBuyerSend", new Object[] { customer_no, sale_org, custm_use }, this.ob).Rows.Count; //保存 地址address,收货人名称consignee,电话phone,邮编zip_code,传真Fax,备注memo string address = this.editorAddress.Text.Trim(); string consignee = this.editorConsignee.Text.Trim(); string phone = this.editorPhone.Text.Trim(); string zipcode = this.editorZipcode.Text.Trim(); string fax = this.editorFax.Text.Trim(); string memo = this.editorMemo.Text.Trim(); if (string.IsNullOrEmpty(address)) { MessageUtil.ShowWarning("地址不能为空!"); return; } if (string.IsNullOrEmpty(consignee) && sale_org != "100102") { MessageUtil.ShowWarning("收货人名称不能为空!"); return; } //if (string.IsNullOrEmpty(phone)) //{ // MessageUtil.ShowTips("电话不能为空!"); // return; //} //if (string.IsNullOrEmpty(zipcode)) //{ // MessageUtil.ShowTips("邮编不能为空!"); // return; //} //if (string.IsNullOrEmpty(fax)) //{ // MessageUtil.ShowTips("传真不能为空!"); // return; //} ArrayList parmCustmUse = new ArrayList(); parmCustmUse.Add(customer_no); parmCustmUse.Add(sale_org); parmCustmUse.Add(custm_use); parmCustmUse.Add(strOperator); ArrayList parmRcvUnit = new ArrayList(); parmRcvUnit.Add(custm_use); parmRcvUnit.Add(region_no); parmRcvUnit.Add(address); parmRcvUnit.Add(consignee); parmRcvUnit.Add(phone); parmRcvUnit.Add(zipcode); parmRcvUnit.Add(fax); parmRcvUnit.Add(memo); parmRcvUnit.Add(strOperator); parmRcvUnit.Add(customer_no); parmRcvUnit.Add(sale_org); ArrayList listDeleteFreight = new ArrayList(); ArrayList listFreight = new ArrayList(); foreach (UltraGridRow ugr in this.ultraGridOrder.Rows) { if (ugr.Cells["CD"].Value.ToString().ToLower() == "true") { if (ugr.Cells["TRANS_TYP"].Value.ToString() == "") { MessageUtil.ShowWarning("请选择运输方式!"); ugr.Cells["TRANS_TYP"].Activate(); return; } else if (cmbTrainType.IsItemInList(ugr.Cells["TRANS_TYP"].Value.ToString()) == false) { MessageUtil.ShowWarning("输入的运输方式不存在,请选择运输方式!"); ugr.Cells["TRANS_TYP"].Activate(); return; } else { if (ugr.Cells["ADDRESS"].Value.ToString() == "") { MessageUtil.ShowWarning("请输入货运地址!"); ugr.Cells["ADDRESS"].Activate(); return; } //火运 if (ugr.GetValue("TRANS_TYP") == "110502") { if (ugr.Cells["STATION_NO"].Value.ToString() == "") { MessageUtil.ShowWarning("请选择到站!"); ugr.Cells["STATION_NO"].Activate(); return; } else if (cmbStationName.IsItemInList(ugr.Cells["STATION_NO"].Value.ToString()) == false) { MessageUtil.ShowWarning("输入的到站不存在,请选择到站!"); ugr.Cells["STATION_NO"].Activate(); return; } if (ugr.Cells["SPCL_LN_NO"].Value.ToString() == "") { MessageUtil.ShowWarning("请选择专用线!"); ugr.Cells["SPCL_LN_NO"].Activate(); return; } else if (cmbCollege.IsItemInList(ugr.Cells["SPCL_LN_NO"].Value.ToString()) == false) { MessageUtil.ShowWarning("输入的专线不存在,请选择专线!"); ugr.Cells["SPCL_LN_NO"].Activate(); return; } } //船舶 if (ugr.GetValue("TRANS_TYP") == "110503") { if (ugr.Cells["PORT_NO"].Value.ToString() == "") { MessageUtil.ShowWarning("请选择港口/码头!"); ugr.Cells["PORT_NO"].Activate(); return; } else if (ultraComPort.IsItemInList(ugr.Cells["PORT_NO"].Value.ToString()) == false) { MessageUtil.ShowWarning("输入的港口/码头不存在,请选择港口/码头!"); ugr.Cells["PORT_NO"].Activate(); return; } } //航运 if (ugr.GetValue("TRANS_TYP") == "110504") { if (ugr.Cells["SPCL_LN_NO"].Value.ToString() == "") { MessageUtil.ShowWarning("请选择专用线!"); ugr.Cells["SPCL_LN_NO"].Activate(); return; } else if (cmbCollege.IsItemInList(ugr.Cells["SPCL_LN_NO"].Value.ToString()) == false) { MessageUtil.ShowWarning("输入的专线不存在,请选择专线!"); ugr.Cells["SPCL_LN_NO"].Activate(); return; } } } /*customer_no, freight_no, address, station_no, spcl_ln_no, trans_typ, memo, create_name, create_time */ listDeleteFreight.Add(ugr.Cells["FREIGHT_NO"].Value.ToString()); ArrayList parm = new ArrayList(); parm.Add(customer_no); parm.Add(sale_org); parm.Add(customer_no); parm.Add(customer_no); parm.Add(ugr.Cells["ADDRESS"].Value.ToString()); parm.Add(ugr.Cells["STATION_NO"].Value.ToString()); parm.Add(ugr.Cells["SPCL_LN_NO"].Value.ToString()); parm.Add(ugr.Cells["TRANS_TYP"].Value.ToString()); parm.Add(ugr.Cells["MEMO"].Value.ToString()); parm.Add(strOperator); parm.Add(ugr.Cells["PORT_NO"].Value.ToString()); parm.Add(ugr.Cells["PORT_NO"].Text.ToString()); listFreight.Add(parm); } else { if (ugr.Cells["FREIGHT_NO"].Value.ToString().Length > 0) listDeleteFreight.Add(ugr.Cells["FREIGHT_NO"].Value.ToString()); } } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No) return; ServerHelper.SetData("com.steering.pss.sale.base.CoreBuyerSend.saveBuyerSend", new object[] { parmCustmUse, parmRcvUnit, listDeleteFreight, listFreight }, ob); MessageUtil.ShowTips("保存成功!"); this.Close(); break; case "Esc": this.Close(); break; } } /// /// 专用线 /// private void bindCmbCollege() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetSpclNo", null, this.ob); cmbCollege.DataSource = dt; cmbCollege.DisplayMember = "SPCL_LN_NM"; cmbCollege.ValueMember = "SPCL_LN_NO"; ClsBaseInfo.SetComboItemHeight(cmbCollege); if (cmbCollege.Items.Count > 0) cmbCollege.SelectedIndex = 0; } /// /// 铁路到站 /// private void bindCmbStation() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.base.CoreSpeclLine.GetStation", null, this.ob); cmbStationName.DataSource = dt; cmbStationName.DisplayMember = "STATION_NM"; cmbStationName.ValueMember = "STATION_NO"; ClsBaseInfo.SetComboItemHeight(cmbStationName); if (cmbStationName.Items.Count > 0) cmbStationName.SelectedIndex = 0; } /// /// 运输方式 /// private void bindYsfs() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetYsfs", null, this.ob); cmbTrainType.DataSource = dt; cmbTrainType.DisplayMember = "BASENAME"; cmbTrainType.ValueMember = "BASECODE"; ClsBaseInfo.SetComboItemHeight(cmbTrainType); if (cmbTrainType.Items.Count > 0) cmbTrainType.SelectedIndex = 0; } /// /// 获取港口/码头 /// private void bindCmPort() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetPort", null, this.ob); ultraComPort.DataSource = dt; ultraComPort.DisplayMember = "BASENAME"; ultraComPort.ValueMember = "BASECODE"; ClsBaseInfo.SetComboItemHeight(ultraComPort); if (ultraComPort.Items.Count > 0) ultraComPort.SelectedIndex = 0; } private void FrmBuyerSend_Load(object sender, EventArgs e) { //到站 bindCmbStation(); //专用线 bindCmbCollege(); //运输方式 bindYsfs(); //港口/码头 bindCmPort(); DataTable table = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerSend.GetQueryBuyerSend", new Object[] { customer_no, sale_org, custm_use }, this.ob); _dtBuyerSend = table; if (table.Rows.Count > 0) { //主界面点击修改查询该条数据加载到对应控件文本内。 //customer_no, sale_org, custm_use, region_no, address, consignee, phone, zip_code, fax, memo this.editorAddress.Text = table.Rows[0]["ADDRESS"].ToString(); this.editorConsignee.Text = table.Rows[0]["CONSIGNEE"].ToString(); this.editorPhone.Text = table.Rows[0]["PHONE"].ToString(); this.editorZipcode.Text = table.Rows[0]["ZIP_CODE"].ToString(); this.editorFax.Text = table.Rows[0]["FAX"].ToString(); this.editorMemo.Text = table.Rows[0]["MEMO"].ToString(); } else { table = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerBase.GetQueyPubuleCustomer", new Object[] { customer_no, sale_org }, this.ob); if (table.Rows.Count > 0) { this.editorPhone.Text = table.Rows[0]["PHONE"].ToString(); this.editorFax.Text = table.Rows[0]["FAX"].ToString(); this.editorZipcode.Text = table.Rows[0]["ZIP_CODE"].ToString(); this.editorConsignee.Text = table.Rows[0]["CONSIGNEE"].ToString(); this.editorAddress.Text = table.Rows[0]["ADDRESS"].ToString(); } } table = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerOrder.GetQueryFreight", new Object[] { customer_no, sale_org }, this.ob); if (table.Rows.Count > 0) { //赋值给Datatable运货地址 GridHelper.CopyDataToDatatable(ref table, ref this.dataTableFREIGHT, true); foreach (UltraGridRow ugr in this.ultraGridOrder.Rows) { ugr.Cells["CD"].Value = true; } ultraGridOrder.UpdateData(); } } private void ultraGridOrder_InitializeLayout(object sender, InitializeLayoutEventArgs e) { } private void editorConsignee_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorConsignee.Text) > 20) { MessageBox.Show("录入收货人【中文名不能大于10个字符/英文名不能大于20个字符】数据验证失败,请重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } private void editorAddress_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorAddress.Text) > 1000) { MessageBox.Show("录入地址数据验证失败【中文地址不能大于500个字符/英文地址不能大于1000个字符】,请重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } private void editorPhone_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.IsChinese(editorPhone.Text)) { MessageBox.Show("录入电话号码数据验证失败【电话号码不能为中文】,请按国内/国际电话规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } else { if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorPhone.Text) > 20) { MessageBox.Show("录入电话号码数据验证失败【不能大于20个字符】,请按国内/国际电话规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } } private void editorZipcode_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.IsChinese(editorZipcode.Text)) { MessageBox.Show("录入邮编数据验证失败【邮编不能为中文】,请按国内/国际邮编规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } else { if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorZipcode.Text) > 20) { MessageBox.Show("录入邮编数据验证失败【不能大于20个字符】,请按国内/国际邮编规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } } private void editorFax_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.IsChinese(editorFax.Text)) { MessageBox.Show("录入传真号码数据验证失败【传真号码不能为中文】,请按国内/国际传真号码规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } else { if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorFax.Text) > 20) { MessageBox.Show("录入传真号码数据验证失败【不能大于20个字符】,请按国内/国际传真号码规则重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } } private void editorMemo_Validating(object sender, CancelEventArgs e) { blValidating = false; if (Core.Mes.Client.Comm.Globals.GetStrBytesLength(editorMemo.Text) > 200) { MessageBox.Show("录入备注【中文名不能大于100个字符/英文名不能大于200个字符】数据验证失败,请重新录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); blValidating = true; e.Cancel = true; } } private void ultraGridOrder_CellChange(object sender, CellEventArgs e) { UltraGridRow ultrow = e.Cell.Row; ultraGridOrder.UpdateData(); if (ultrow.GetValue("CD") == "False") { if (ultrow.Cells["FREIGHT_NO"].Value != null && ultrow.Cells["FREIGHT_NO"].Value.ToString().Length > 0) { if (MessageBox.Show("是否确认要删除所选货运地址?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { ultrow.Cells["CD"].Value = true; return; } } } ControlGrid2Edit(e.Cell.Row); ControlGridEditByTransitTyp(e.Cell); SetColor(e.Cell.Row); ultraGridOrder.UpdateData(); } /// /// 设置GRID是否可编辑 /// /// private void ControlGrid2Edit(UltraGridRow row) { if (row.GetValue("CD") == "True") { foreach (UltraGridCell cell in row.Cells) { cell.Activation = Activation.AllowEdit; } } else { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.Key == "CD") continue; cell.Activation = Activation.ActivateOnly; } } } /// /// 根据运输方式设置是否可编辑 /// /// private void ControlGridEditByTransitTyp(UltraGridCell cell) { UltraGridRow row = cell.Row; if (row.GetValue("CD") == "False") return; switch (row.GetValue("TRANS_TYP")) { case "110501": row.Cells["ADDRESS"].Activation = Activation.AllowEdit; //地址 row.Cells["STATION_NO"].Activation = Activation.ActivateOnly;//到站 row.Cells["PORT_NO"].Activation = Activation.ActivateOnly;//码头 row.Cells["SPCL_LN_NO"].Activation = Activation.ActivateOnly;//专线 row.Cells["STATION_NO"].Value = ""; row.Cells["PORT_NO"].Value = ""; row.Cells["STATION_NO"].Value = ""; break; case "110502": row.Cells["ADDRESS"].Activation = Activation.AllowEdit; row.Cells["STATION_NO"].Activation = Activation.AllowEdit; row.Cells["PORT_NO"].Activation = Activation.ActivateOnly; row.Cells["SPCL_LN_NO"].Activation = Activation.AllowEdit; //row.Cells["Destination"].Value = ""; row.Cells["PORT_NO"].Value = ""; //row.Cells["SpclLnNo"].Value = ""; break; case "110503": row.Cells["ADDRESS"].Activation = Activation.AllowEdit; row.Cells["STATION_NO"].Activation = Activation.ActivateOnly; row.Cells["PORT_NO"].Activation = Activation.AllowEdit; row.Cells["SPCL_LN_NO"].Activation = Activation.ActivateOnly; //row.Cells["Destination"].Value = ""; row.Cells["STATION_NO"].Value = ""; row.Cells["SPCL_LN_NO"].Value = ""; break; case "110504": row.Cells["ADDRESS"].Activation = Activation.AllowEdit; row.Cells["STATION_NO"].Activation = Activation.ActivateOnly; row.Cells["PORT_NO"].Activation = Activation.ActivateOnly; row.Cells["SPCL_LN_NO"].Activation = Activation.AllowEdit; //row.Cells["Destination"].Value = ""; row.Cells["STATION_NO"].Value = ""; row.Cells["PORT_NO"].Value = ""; break; } } /// /// 设置对应的颜色 /// /// private void SetColor(UltraGridRow row) { switch (row.GetValue("TRANS_TYP")) { case "110501": row.Cells["ADDRESS"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["STATION_NO"].Appearance.BackColor = Color.White; row.Cells["PORT_NO"].Appearance.BackColor = Color.White; row.Cells["SPCL_LN_NO"].Appearance.BackColor = Color.White; break; case "110502": row.Cells["ADDRESS"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["STATION_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["PORT_NO"].Appearance.BackColor = Color.White; row.Cells["SPCL_LN_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); break; case "110503": row.Cells["ADDRESS"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["STATION_NO"].Appearance.BackColor = Color.White; row.Cells["PORT_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["SPCL_LN_NO"].Appearance.BackColor = Color.White; break; case "110504": row.Cells["ADDRESS"].Appearance.BackColor = Color.FromArgb(255, 255, 128); row.Cells["STATION_NO"].Appearance.BackColor = Color.White; row.Cells["PORT_NO"].Appearance.BackColor = Color.White; row.Cells["SPCL_LN_NO"].Appearance.BackColor = Color.FromArgb(255, 255, 128); break; } } } }