using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; 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; namespace Core.StlMes.Client.PnCost { public partial class frmSaleCostCountZG : FrmBase { #region 初始化 public frmSaleCostCountZG() { InitializeComponent(); } private void frmSaleCostCountZG_Load(object sender, EventArgs e) { for (int i = 2000; i < 2051; i++) { yeardrop.Items.Add(i); } string str1 = ""; for (int i = 1; i < 10; i++) { str1 = "0" + i.ToString2(); monthdrop.Items.Add(str1); } monthdrop.Items.Add(10); monthdrop.Items.Add(11); monthdrop.Items.Add(12); yeardrop.Value = System.DateTime.Now.Year.ToString2(); monthdrop.Value = System.DateTime.Now.Month.ToString2(); } #endregion #region 方法 public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": Query(); break; case "Refresh": Refresh(); break; case "Close": this.Close(); break; } } /// 查询方法 /// /// 查询方法 /// private void Query() { #region 条件验证 //年月 string year = yeardrop.Value.ToString2(); string month = monthdrop.Value.ToString2(); if (Convert.ToDecimal(month) < 10) { month = month.Substring(1); } string mon = "CBT.MONTH_" + month; #endregion DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComSaleCostCountZG.query", new object[] { year + "-" + monthdrop.Value.ToString2(), year, mon }, ob); GridHelper.CopyDataToDatatable(dt, dataTable1, true); if (ultraGrid1.Rows.Count == 0) { return; } for (int i = 0; i < ultraGrid1.Rows.Count; i++)//根据产线,投入产出物料取小时能力 { string chanxian = ultraGrid1.Rows[i].Cells["PLINE_CODE"].Value.ToString2(); string zhebiao = ""; string zonge = "";//分摊总额 #region 说明4(折标加工费) string monthyue = ultraGrid1.Rows[i].Cells["PRO_MONTH"].Value.ToString2().Substring(5, 2);//取出有产线的月份 string one = monthyue + "one"; string weight = ""; string all = ""; DataTable dtjiage = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscost.queryjiage", new object[] { ultraGrid1.Rows[i].Cells["PLINE_CODE"].Value.ToString2(), ultraGrid1.Rows[i].Cells["WEIGTH_S"].Value.ToString2() }, ob); if (dtjiage.Rows.Count == 0) { one = "0"; } else { one = dtjiage.Rows[0][0].ToString3(); } for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["PLINE_CODE"].ToString2() == chanxian) { weight = (Convert.ToDecimal(dt.Rows[j]["WEIGTH_S"].ToString3()) + Convert.ToDecimal(weight.ToString3())).ToString3(); } } all = ultraGrid1.Rows[i].Cells["MONTH"].Value.ToString3(); zonge = (Convert.ToDecimal(one) * Convert.ToDecimal(weight) + Convert.ToDecimal(all)).ToString3(); for (int j = 0; j < dt.Rows.Count; j++) { //&& touru ==dt.Rows[j]["INWL_ID"].ToString2() // && chanchu == dt.Rows[j]["OUTWL_ID"].ToString2() if (dt.Rows[j]["PLINE_CODE"].ToString2() == chanxian) { zhebiao = (Convert.ToDecimal(dt.Rows[j]["WEIGTH_S"].ToString3()) + Convert.ToDecimal(zhebiao.ToString3())).ToString3(); } } ultraGrid1.Rows[i].Cells["EXPLAIN4"].Value = (Convert.ToDecimal(zonge.ToString3()) * Convert.ToDecimal(ultraGrid1.Rows[i].Cells["WEIGTH_S"].Value.ToString3()) / Convert.ToDecimal(zhebiao.ToString3())).ToString2(); #endregion #region 说明1(返回总额赋值) DataTable changhui = ServerHelper.GetData("com.steering.pss.pncost.base.ComSaleCostCountZG.querychanghui", new object[] { year, chanxian }, ob); string say1 = "0"; string chengcai = ((100 - Convert.ToDecimal(ultraGrid1.Rows[i].Cells["PRD_RATE"].Value.ToString3()))/100).ToString2();//1-成材率 for (int j = 0; j < changhui.Rows.Count; j++) { string yuefen = "MONTH_" + month; say1 = (Convert.ToDecimal(say1) + Convert.ToDecimal(chengcai) * Convert.ToDecimal(changhui.Rows[j][yuefen].ToString3()) * Convert.ToDecimal(changhui.Rows[j]["PERCENT"].ToString3())/100).ToString2(); } ultraGrid1.Rows[i].Cells["EXPLAIN1"].Value = say1.ToString2(); #endregion } ultraGrid1.UpdateData(); ultraGrid1.ActiveRow = ultraGrid1.Rows[0]; } #endregion #region 事件 #endregion } }