using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; using System.Collections; using System.Reflection; using CoreFS.CA06; namespace Core.StlMes.Client.Sale.UI.Balance.BalanceAccount { public partial class FrmBalPriceInput : Core.StlMes.Client.Sale.Common.FrmStyleBase.FrmUIBase { public FrmBalPriceInput() { InitializeComponent(); } Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Order.SlmOrderBll slmOrderBll = null; private DataSet dsMain = new DataSet(); private DataSet combaseinfo = null; private void FrmBalPriceInput_Load(object sender, EventArgs e) { this.checkBox1.Checked = true; this.dateTimePicker1.Value = System.DateTime.Now.AddDays(-30); combaseinfo = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.BaseData.ComBaseInfoBll(this.ob).GetComBaseInfo(); slmOrderBll = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Order.SlmOrderBll(this.ob); dsMain = base.GetDataSetByColumnName(GetDataStruct(), GetColumnDataType(), GetColumnCaption()); this.ultraGrid1.DataSource = dsMain; base.SetGridStyle(ref this.ultraGrid1); InitGrid(); this.radioButton2.Checked = true; InitEditCell(); } private void InitGrid() { try { this.ultraGrid1.DisplayLayout.Bands[0].Columns["CONTAIN_TAX"].ValueList = GetContainTaxValueList(); } catch { } } private Hashtable GetHashTableByImpExcel() { Hashtable hs = new Hashtable(); string fileName = Util.UtilExcel.GetExcelFileName(); if (fileName.Length == 0) return hs; DataSet ds = Util.UtilExcel.ToDataSet(fileName); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) return hs; foreach (DataRow dr in ds.Tables[0].Rows) { try { hs.Add(dr[0].ToString(), dr[1].ToString()); } catch { } } return hs; } private void BatchUpdateOrderLinBalPrice() { if (this.ultraGrid1.Rows.Count == 0) return; Hashtable hsOrderPrice = GetHashTableByImpExcel(); if (hsOrderPrice.Count == 0) return; string orderNoSeq = ""; string orderLiPk = ""; double price = 0; string errMsg = ""; string userName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["BALNCE_PRICE_STS"].Value.ToString() == "1") continue; orderNoSeq = ugr.Cells["ORDER_NO"].Value.ToString() + ugr.Cells["ORDER_SEQ"].Value.ToString(); orderLiPk = ugr.Cells[this.ORD_LN_PK].Value.ToString(); if (hsOrderPrice.ContainsKey(orderNoSeq)) { price = Util.ConverObject.ConvertToDouble(hsOrderPrice[orderNoSeq]); if (price == 0) continue; this.slmOrderBll.UpdateFinallBalPrice(orderLiPk, price + "", userName, out errMsg ); } } this.Query(); } private void InitEditCell() { if (this.CustomInfo == "1" || this.CustomInfo == "2") { if (this.GetOrgDiv() == "1") { this.ultraGrid1.DisplayLayout.Bands[0].Columns["BALNCE_PRICE"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BALNCE_PRICE"].CellAppearance.BackColor = base.GetEditColor(); } else { this.ultraGrid1.DisplayLayout.Bands[0].Columns["BALNCE_PRICE_ORG"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BALNCE_PRICE_ORG"].CellAppearance.BackColor = base.GetEditColor(); } } } private Infragistics.Win.ValueList GetContainTaxValueList() { Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList(); lit.ValueListItems.Add("0", "不含税"); lit.ValueListItems.Add("", "不含税"); lit.ValueListItems.Add("1", "含税"); return lit; } // 区分内部价格维护和外部价格维护 private string GetOrgDiv() { if (this.CustomInfo == "1" || this.CustomInfo == "3") return "1"; else return "2"; } public override void ToolBar_Click(object sender, string ToolbarKey) { if (ToolbarKey == "Query") this.Query(); if (ToolbarKey == "QueryOrg") this.QueryOrgPrice(); if (ToolbarKey == "Update") this.UpdatePrice(); if (ToolbarKey == "UpdateOrg") this.UpdateOrgPrice(); if (ToolbarKey == "Exit") this.Close(); if (ToolbarKey == "Affrim") this.AffrimPrice(); if (ToolbarKey == "AffrimOrg") this.AffrimOrgPrice(); if (ToolbarKey == "UnAffrim") this.UnAffrimPrice(); if (ToolbarKey == "UnAffrimOrg") this.UnAffrimOrgPrice(); if (ToolbarKey == "ImpPrice") this.BatchUpdateOrderLinBalPrice(); } private void SetOrderLnStatus() { if (this.combaseinfo == null) return; if (this.combaseinfo.Tables.Count == 0 || this.combaseinfo.Tables[0].Rows.Count == 0) return; foreach (DataRow dr in this.dsMain.Tables[0].Rows) { DataRow[] drs = combaseinfo.Tables[0].Select(string.Format(" BASECODE = '{0}' ", dr["ORDER_LN_STATUS"].ToString())); try { dr["ORDER_LN_STATUS"] = drs[0]["BASENAME"]; } catch { } } } private void QueryOrgPrice() { DataSet ds = null; if (this.checkBox1.Checked) { ds = this.slmOrderBll.GetSlmOrderLineByCreateTime(this.dateTimePicker1.Value, this.dateTimePicker2.Value); } else { ds = this.slmOrderBll.GetSlmOrderLineByCreateTime(System.DateTime.Now.AddYears(-100), System.DateTime.Now.AddYears(100)); } if (this.textBox1.Text.Length > 0) { ds = this.slmOrderBll.GetSlmOrderLineByOrderNoWithApproximateMatch(this.textBox1.Text.Trim()); // ds = Util.UtilDataSet.GetDataSetWithRowFilterWithApproximateMatch(ds, "ORDER_NO", this.textBox1.Text.Trim()); } // 数据权限 ds = base.GetDataSetByFilterDeptId(ds, "CREATE_DEPT"); if (this.radioButton2.Checked) { ds = Util.UtilDataSet.GetDataSetWithRowFilter(ds, "BALNCE_PRICE_ORG_STS", new string[] { "", "0" }); } if (this.radioButton1.Checked) { ds = Util.UtilDataSet.GetDataSetWithRowFilter(ds, "BALNCE_PRICE_ORG_STS", new string[] { "1" }); } Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMain, ds); SetOrderLnStatus(); } private void Query() { DataSet ds = null; if (this.checkBox1.Checked) { ds = this.slmOrderBll.GetSlmOrderLineByCreateTime(this.dateTimePicker1.Value, this.dateTimePicker2.Value); } else { ds = this.slmOrderBll.GetSlmOrderLineByCreateTime(System.DateTime.Now.AddYears(-100), System.DateTime.Now.AddYears(100)); } if (this.textBox1.Text.Length > 0) { ds = this.slmOrderBll.GetSlmOrderLineByOrderNoWithApproximateMatch(this.textBox1.Text.Trim()); // ds = Util.UtilDataSet.GetDataSetWithRowFilterWithApproximateMatch(ds, "ORDER_NO", this.textBox1.Text.Trim()); } // 数据权限 ds = base.GetDataSetByFilterDeptId(ds, "CREATE_DEPT"); if (this.radioButton2.Checked) { ds = Util.UtilDataSet.GetDataSetWithRowFilter(ds, "BALNCE_PRICE_STS", new string[] { "", "0" }); } if (this.radioButton1.Checked) { ds = Util.UtilDataSet.GetDataSetWithRowFilter(ds, "BALNCE_PRICE_STS", new string[] { "1" }); } if (!this.UserInfo.GetUserName().Equals("admin")) ds = base.GetDataSetByFilterDeptId(ds); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMain, ds); SetOrderLnStatus(); } protected override List GetGridColumnListHidden() { if (GetOrgDiv() == "1") return new List(GetBalPriceHIddenColumn()); else return new List(GetOrgBalPriceHIddenColumn()); } private string[] GetBalPriceHIddenColumn() { return new string[] {ORD_PK ,this.ORD_LN_PK, "BALNCE_PRICE_STS", "BALNCE_PRICE_ORG_STS","BALNCE_PRICE_ORG" }; } private string[] GetOrgBalPriceHIddenColumn() { return new string[] {ORD_PK ,this.ORD_LN_PK, "BALNCE_PRICE_STS", "BALNCE_PRICE_ORG_STS","BALNCE_PRICE" }; } private string ORD_PK = "ORD_PK"; private string ORD_LN_PK = "ORD_LN_PK"; private void UpdatePrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择修改的行"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定修改合同行价格?") == DialogResult.No) return; if (Util.ConverObject.ConvertToDouble(ugr.Cells["BALNCE_PRICE"].Value) == 0) { MessageBox.Show("请输入正确价格"); return; } string errMsg = ""; this.slmOrderBll.UpdateFinallBalPrice(ugr.Cells[this.ORD_LN_PK].Value.ToString(), ugr.Cells["BALNCE_PRICE"].Value.ToString(), CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg ); if (errMsg.Length == 0) { MessageBox.Show("操作成功"); } } private void UpdateOrgPrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { Util.MessageUtil.ShowError("请选择修改的行"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定修改合同行价格?") == DialogResult.No) return; if (Util.ConverObject.ConvertToDouble(ugr.Cells["BALNCE_PRICE_ORG"].Value) == 0) { Util.MessageUtil.ShowError("请输入正确价格"); return; } string errMsg = ""; this.slmOrderBll.UpdateFinallBalPriceOrg(ugr.Cells[this.ORD_LN_PK].Value.ToString(), ugr.Cells["BALNCE_PRICE_ORG"].Value.ToString(), CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg ); if (errMsg.Length == 0) { MessageBox.Show("操作成功"); } } private void AffrimPrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择确认的合同"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定通过所选合同价格?") == DialogResult.No) return; ugr.Selected = true; ArrayList listorderno = new ArrayList(); ArrayList listorderCanNotAffrim = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Selected.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (!listorderno.Contains(ord)) { listorderno.Add(ord); } if (Util.ConverObject.ConvertToDouble(ugrf.Cells["BALNCE_PRICE"].Value) == 0) { if (!listorderCanNotAffrim.Contains(ord)) { listorderCanNotAffrim.Add(ord); } } } foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (listorderno.Contains(ord)) { if (Util.ConverObject.ConvertToDouble(ugrf.Cells["BALNCE_PRICE"].Value) == 0) { MessageBox.Show("所选合同中有结算价格为0的行,请重新确认"); return; } } } string msg = ""; foreach (string sorder in listorderno) { if (listorderCanNotAffrim.Contains(sorder)) continue; try { string errMsg = ""; this.slmOrderBll.AffrimFinallBalPrice(sorder, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length > 0) { msg += sorder + errMsg + "/"; } } catch { } } if (msg.Length == 0) { MessageBox.Show("确认成功"); } else { MessageBox.Show(msg); } this.Query(); } private void UnAffrimPrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择取消确认的合同"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定取消所选合同价格?") == DialogResult.No) return; ugr.Selected = true; ArrayList listorderno = new ArrayList(); ArrayList listorderCanNotAffrim = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Selected.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (!listorderno.Contains(ord)) { listorderno.Add(ord); } } string msg = ""; foreach (string sorder in listorderno) { try { string errMsg = ""; this.slmOrderBll.UnAffrimFinallBalPrice(sorder, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length > 0) { msg += sorder + errMsg + "/"; } } catch { } } if (msg.Length == 0) { MessageBox.Show("取消确认成功"); } else { MessageBox.Show(msg); } this.Query(); } private void AffrimOrgPrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择取消确认的合同"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定取消所选合同价格?") == DialogResult.No) return; ugr.Selected = true; ArrayList listorderno = new ArrayList(); ArrayList listorderCanNotAffrim = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Selected.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (!listorderno.Contains(ord)) { listorderno.Add(ord); } } string msg = ""; foreach (string sorder in listorderno) { try { string errMsg = ""; this.slmOrderBll.AffrimFinallBalPriceOrg(sorder, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length > 0) { msg += sorder + errMsg + "/"; } } catch { } } if (msg.Length == 0) { this.Query(); MessageBox.Show("确认成功"); } else { MessageBox.Show(msg); } } private void UnAffrimOrgPrice() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { Util.MessageUtil.ShowTips("请选择确认的合同"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定通过所选合同价格?") == DialogResult.No) return; ugr.Selected = true; ArrayList listorderno = new ArrayList(); ArrayList listorderCanNotAffrim = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Selected.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (!listorderno.Contains(ord)) { listorderno.Add(ord); } if (Util.ConverObject.ConvertToDouble(ugrf.Cells["BALNCE_PRICE_ORG"].Value) == 0) { if (!listorderCanNotAffrim.Contains(ord)) { listorderCanNotAffrim.Add(ord); } } } foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrf in this.ultraGrid1.Rows) { string ord = ugrf.Cells[this.ORD_PK].Value.ToString(); if (listorderno.Contains(ord)) { if (Util.ConverObject.ConvertToDouble(ugrf.Cells["BALNCE_PRICE_ORG"].Value) == 0) { Util.MessageUtil.ShowTips("所选合同中有结算价格为0的行,请重新确认"); return; } } } string msg = ""; foreach (string sorder in listorderno) { if (listorderCanNotAffrim.Contains(sorder)) continue; try { string errMsg = ""; this.slmOrderBll.UnAffrimFinallBalPriceOrg(sorder, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length > 0) { msg += sorder + errMsg + "/"; } } catch { } } if (msg.Length == 0) { this.Query(); Util.MessageUtil.ShowTips("确认成功"); } else { Util.MessageUtil.ShowError(msg); } } private string[] GetDataStruct() { return new string[] { "BALNCE_PRICE", "BALNCE_PRICE_ORG", "BLA_PRICE", "CONTAIN_TAX", "ORDER_NO", "ORDER_SEQ", "ORDER_SPEC_DESC", "STEELNAME", "MODEL_DESC", "STD_NAME", "ORDER_LN_STATUS", "SPEC_NAME", "CUSTOMER_NM", "STLMT_UNIT_NM", "SALE_ORG_DESC", "SALE_AREA_DESC", "DIMATER", "HEIGHT", "LEN_DESC", "ORD_PK", "ORD_LN_PK", "BALNCE_PRICE_STS", "BALNCE_PRICE_ORG_STS" }; } private Hashtable GetColumnCaption() { Hashtable hs = new Hashtable(); hs.Add("BALNCE_PRICE", "结算价"); hs.Add("BALNCE_PRICE_ORG", "结算价"); hs.Add("BLA_PRICE", "订单价"); hs.Add("CUSTOMER_NM", "订货单位"); hs.Add("STLMT_UNIT_NM", "结算单位"); hs.Add("ORDER_LN_STATUS", "合同状态"); hs.Add("SALE_ORG_DESC", "销售组织"); hs.Add("SALE_AREA_DESC", "区域"); hs.Add("SPEC_NAME", "产品规格"); hs.Add("ORDER_SPEC_DESC", "订货规格"); hs.Add("STD_NAME", "标准"); hs.Add("DIMATER", "外径"); hs.Add("HEIGHT", "壁厚"); hs.Add("MODEL_DESC", "扣型"); hs.Add("LEN_DESC", "长度描述"); hs.Add("ORDER_NO", "合同号"); hs.Add("ORDER_SEQ", "行号"); hs.Add("STEELNAME", "牌号"); hs.Add("CONTAIN_TAX", "是否含税"); return hs; } private Hashtable GetColumnDataType() { Hashtable hs = new Hashtable(); hs.Add("FINAL_BALPRICE", "System.Decimal"); return hs; } private void groupBox1_Enter(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.BatchUpdateOrderLinBalPrice(); } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if(e.KeyChar == 13) { if (this.GetOrgDiv() == "1") this.Query(); else this.QueryOrgPrice(); } } } }