Esempio n. 1
0
        private void PLANADD(int item)
        {
            DataRow           dr                = gv_DDFA.GetDataRow(item);
            int               count             = bll_TRP_PLAN_ROLL.GetFACount("", "");//该方案下该工位计划数量
            Mod_TRP_PLAN_ROLL mod_TRP_PLAN_ROLL = new Mod_TRP_PLAN_ROLL();

            mod_TRP_PLAN_ROLL.N_SORT       = count + 1;
            mod_TRP_PLAN_ROLL.C_SPEC       = dr["C_SPEC"].ToString();
            mod_TRP_PLAN_ROLL.C_STD_CODE   = dr["C_STD_CODE"].ToString();
            mod_TRP_PLAN_ROLL.C_STL_GRD    = dr["C_STL_GRD"].ToString();
            mod_TRP_PLAN_ROLL.C_ORDER_NO   = dr["C_ORDER_NO"].ToString();
            mod_TRP_PLAN_ROLL.C_MAT_NAME   = dr["C_MAT_NAME"].ToString();
            mod_TRP_PLAN_ROLL.C_MAT_CODE   = dr["C_MAT_CODE"].ToString();
            mod_TRP_PLAN_ROLL.C_FREE_TERM  = dr["C_FREE1"].ToString();
            mod_TRP_PLAN_ROLL.C_FREE_TERM2 = dr["C_FREE2"].ToString();
            mod_TRP_PLAN_ROLL.N_WGT        = Convert.ToDecimal(dr["N_WGT"]);
            if (dr["C_LINE_NO"] == null || dr["C_LINE_NO"].ToString() == "")
            {
                MessageBox.Show(mod_TRP_PLAN_ROLL.C_STL_GRD + "未分配产线!");
                return;
            }
            mod_TRP_PLAN_ROLL.C_STA_ID = dr["C_LINE_NO"].ToString();

            if (txt_wgt1.Enabled == true)
            {
                mod_TRP_PLAN_ROLL.N_ROLL_PROD_WGT = Convert.ToDecimal(txt_wgt1.Text);
            }
            else
            {
                mod_TRP_PLAN_ROLL.N_ROLL_PROD_WGT = Convert.ToDecimal(dr["N_WGT"]) - Convert.ToDecimal(dr["N_ROLL_PROD_WGT"]);
            }
            if (mod_TRP_PLAN_ROLL.N_WGT <= 0)
            {
                return;
            }
            if (count > 0)
            {
                DataTable bdt = bll_TRP_PLAN_ROLL.GetList(Convert.ToInt32(mod_TRP_PLAN_ROLL.N_SORT - 1), "", mod_TRP_PLAN_ROLL.C_STA_ID).Tables[0];
                if (bdt.Rows.Count > 0)
                {
                    DateTime enddt = Convert.ToDateTime(bdt.Rows[0]["D_P_END_TIME"]);//上一计划结束时间

                    DataTable hggdt = bll_TPB_CHANGESPEC_TIME.GetList(1, mod_TRP_PLAN_ROLL.C_STA_ID, bdt.Rows[0]["C_SPEC"].ToString(), mod_TRP_PLAN_ROLL.C_SPEC).Tables[0];

                    if (hggdt.Rows.Count > 0)
                    {
                        mod_TRP_PLAN_ROLL.D_P_START_TIME = enddt.AddMinutes(Convert.ToDouble(hggdt.Rows[0]["N_TIME"]));
                    }
                    else
                    {
                        mod_TRP_PLAN_ROLL.D_P_START_TIME = enddt;
                    }
                }
            }
            else
            {
                mod_TRP_PLAN_ROLL.D_P_START_TIME = RV.UI.ServerTime.timeNow();
            }

            int cn = 0;

            if (!string.IsNullOrEmpty(dr["N_MACH_WGT"].ToString()))
            {
                cn = Convert.ToInt32(dr["N_MACH_WGT"].ToString());
            }

            if (cn == 0)
            {
                cn = 50;
            }

            double   db = Convert.ToDouble(mod_TRP_PLAN_ROLL.N_WGT) / Convert.ToDouble(cn);
            DateTime dt = Convert.ToDateTime(mod_TRP_PLAN_ROLL.D_P_START_TIME);

            dt = dt.AddHours(Convert.ToDouble(db));
            mod_TRP_PLAN_ROLL.D_P_END_TIME = dt;

            Mod_TMO_ORDER modOrder = bll_order.GetModelByORDERNO(dr["C_ORDER_NO"].ToString());

            modOrder.N_ROLL_PROD_WGT = Convert.ToDecimal(dr["N_WGT"]);

            bll_order.Update(modOrder);

            bll_TRP_PLAN_ROLL.Add(mod_TRP_PLAN_ROLL);//变更计划表
        }