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.SaleOrder; using System.Collections; using Core.Mes.Client.Comm.Control; using Core.StlMes.Client.SaleComm; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.SaleOrder.ReviewForm; using Core.StlMes.Client.SaleOrder.Dialog; using Core.Mes.Client.Comm; using Infragistics.Win; using System.Text.RegularExpressions; namespace Core.StlMes.Client.SaleOrder { public partial class frmOrderInsidePrice : FrmBase { public frmOrderInsidePrice() { InitializeComponent(); this.IsLoadUserView = true; } private void frmOrderInsidePrice_Load(object sender, EventArgs e) { DateTime Today = DateTime.Now; this.date_starte.DateTime = Today.Date.AddMonths(-1); this.date_end.DateTime = DateTime.Today; ValueList list = new ValueList(); Infragistics.Win.ValueListItem[] items = new Infragistics.Win.ValueListItem[] { new Infragistics.Win.ValueListItem("0", "元"), new Infragistics.Win.ValueListItem("1", "‰"), }; //设置下拉框等高 foreach (Infragistics.Win.ValueListItem item in items) { if (Regex.IsMatch(item.DisplayText.ToString2(), @"[\u4e00-\u9fa5]+")) { item.Appearance.FontData.SizeInPoints = 9.0F; } else { item.Appearance.FontData.SizeInPoints = 10.5F; } } list.ValueListItems.AddRange(items); efforder_seq.DisplayLayout.Bands[0].Columns["PRICE_UNIT"].ValueList = list; GridHelper.SetColumnsActivateAndColor(efforder_seq.Rows.Band, "INSIDE_PRICE", "BALNCE_PRICE_ORG", "PRICE_UNIT"); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": doQuery(); break; case "doSavePrice": doSavePrice(); break; case "doClose": this.Close(); break; } } private void doSavePrice() { if (gffect_oder.ActiveRow == null) return; string ordPk = gffect_oder.ActiveRow.Cells["ORD_PK"].Value.ToString(); ArrayList parm = new ArrayList(); foreach (UltraGridRow row in efforder_seq.Rows) { double price = 0; if (!double.TryParse(row.Cells["BALNCE_PRICE_ORG"].Value.ToString(), out price)) { MessageUtil.ShowTips("内部结算价填写错误或未填写"); return; } ArrayList list = new ArrayList(); list.Add(row.Cells["BALNCE_PRICE_ORG"].Value.ToString()); list.Add(row.Cells["ORD_LN_PK"].Value.ToString()); parm.Add(list); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.frmOrderEffect"; ccp.MethodName = "saveInsidePrice"; ccp.ServerParams = new object[] { parm }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("保存成功!"); doQuery(); foreach (UltraGridRow row in gffect_oder.Rows) { if (ordPk.Equals(row.Cells["ORD_PK"].Value.ToString())) { row.Activate(); break; } } } } public void doQuery() { //签约时间 string date = ""; String orderStart = ""; String orderEnd = ""; if (che_date.Checked) { orderStart = Convert.ToDateTime(date_starte.Value).ToString("yyyy-MM-dd") + " 00:00:01"; orderEnd = Convert.ToDateTime(date_end.Value).ToString("yyyy-MM-dd") + " 23:59:59"; } else { orderStart = "1000-01-01 00:00:01"; orderEnd = "9999-12-31 23:59:59"; } //合同号 string order = ""; if (ord_no.Checked) order = orde_cho.Text.Trim(); DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderInsidePriceQuery", new Object[] { order,orderStart, orderEnd }, this.ob); gffect_oder.DataSource = dt; //列自适应 GridHelper.RefreshAndAutoSizeExceptColumns(gffect_oder, new UltraGridColumn[] { }); } private void che_date_CheckedChanged(object sender, EventArgs e) { date_starte.Enabled = che_date.Checked; date_end.Enabled = che_date.Checked; } private void ord_no_CheckedChanged(object sender, EventArgs e) { orde_cho.Enabled = ord_no.Checked; } private void gffect_oder_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = gffect_oder.ActiveRow; if (ugr == null) return; this.doQueryeffect(gffect_oder.ActiveRow.Cells["ORD_PK"].Text); this.doQueryeffect_mol(gffect_oder.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString()); this.queryPriceInfo(gffect_oder.ActiveRow.Cells["ORD_PK"].Text); } private void queryPriceInfo(string ordPk) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.frmOrderEffect.queryPriceInfo", new object[] { ordPk }, this.ob); if (dt != null && dt.Rows.Count > 0) { txtPrice.Text = dt.Rows[0][0].ToString(); } } private void doQueryeffect_mol(string ordermodel) { DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderEffectinfo", new Object[] { ordermodel }, this.ob); efforder_mol.DataSource = dt; //列自适应 GridHelper.RefreshAndAutoSizeExceptColumns(efforder_mol, new UltraGridColumn[] { }); } private void doQueryeffect(string order) { DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderInsideSqeQuery", new Object[] { order }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.orderLineDt, true); //列自适应 GridHelper.RefreshAndAutoSizeExceptColumns(efforder_seq, new UltraGridColumn[] { }); } private void gffect_oder_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { string acustom = gffect_oder.ActiveCell.Value.ToString(); dlgBuyerInfo spt = new dlgBuyerInfo(); spt.oPbd = this.ob; spt.customer = acustom; spt.FilePath = "checker"; spt.ShowDialog(); } private void efforder_seq_AfterRowActivate(object sender, EventArgs e) { if (efforder_seq.ActiveRow != null) { //DataRow orderLine = dataSet1.Tables["orderLineDt"].Rows[efforder_seq.ActiveRow.Index]; //ctrlOrderLineChild1.loadOrderLineChild(this.ob, orderLine); } } private void orde_cho_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) doQuery(); } private void efforder_seq_CellDataError(object sender, CellDataErrorEventArgs e) { e.RaiseErrorEvent = false; // 阻止弹出错误提示窗口 e.RestoreOriginalValue = true; // 恢复原始值 e.StayInEditMode = true; // 继续保留在编辑模式 } private void efforder_seq_CellChange(object sender, CellEventArgs e) { try { efforder_seq.UpdateData(); } catch { } //if (e.Cell.Column.Key.Equals("INSIDE_PRICE")&& !Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Value)) //{ // if (e.Cell.Value.ToString() == "") // return; // int rCount = e.Cell.Row.Index; // for (int i = rCount + 1; i < efforder_seq.Rows.Count; i++) // { // UltraGridRow row = efforder_seq.Rows[i]; // if (!Convert.ToBoolean(row.Cells["CHK"].Value)) // row.Cells["INSIDE_PRICE"].Value = e.Cell.Value; // } //} //else if (e.Cell.Column.Key.Equals("PRICE_UNIT") ) //{ // if (e.Cell.Value.ToString() == "") // return; // int rCount = e.Cell.Row.Index; // for (int i = rCount + 1; i < efforder_seq.Rows.Count; i++) // { // UltraGridRow row = efforder_seq.Rows[i]; // row.Cells["PRICE_UNIT"].Value = e.Cell.Value; // } //} if (e.Cell.Column.Key.Equals("INSIDE_PRICE") || e.Cell.Column.Key.Equals("PRICE_UNIT")) { double insidePrice = 0; double balancePrice = 0; UltraGridRow row = efforder_seq.ActiveRow; if (!double.TryParse(row.Cells["INSIDE_PRICE"].Value.ToString(), out insidePrice)) return; if (!double.TryParse(row.Cells["BALNCE_PRICE"].Value.ToString(), out balancePrice)) return; if (row.Cells["PRICE_UNIT"].Value.ToString() == "0") { row.Cells["BALNCE_PRICE_ORG"].Value = Math.Round(balancePrice - insidePrice, 2); } else if (row.Cells["PRICE_UNIT"].Value.ToString() == "1") { row.Cells["BALNCE_PRICE_ORG"].Value = Math.Round(balancePrice * (1000 - insidePrice) / 1000, 2); } else { return; } } } } }