示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         ProductionPlan pp = new ProductionPlan();
         pp.Id             = text编号.Text;
         pp.ProductId      = com产品编号.Text;
         pp.CustomerId     = com客户编号.Text;
         pp.OrderTime      = date下单日期.Value;
         pp.Count          = Convert.ToInt32(text产品数量.Text);
         pp.PlanningTime   = date交付时间.Value;
         pp.FinishTime     = date实际完成时间.Value;
         pp.PlanType       = com计划类型.Text;
         pp.PlanState      = ProductionPlanStatus.PENDING;//com生产状态.Text;
         pp.RelatedOrderId = text相关订单编号.Text;
         pp.InChargePerson = com负责人.Text;
         if (ppm.AddNewPlan(pp))
         {
             MessageBox.Show("新计划建立成功!审核中");
             dataGridView1.DataSource = this.ppm.GetAllProductPlan();
             dataGridView1.Update();
         }
         else
         {
             MessageBox.Show("失败!");
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
示例#2
0
        private void button加入生产计划_Click(object sender, EventArgs e)//制定生产计划
        {
            try
            {
                // validation
                var invalidPid = "";
                for (int i = 0; i < dataGridView产品订单数据.Rows.Count; i++)
                {
                    var pId = dataGridView产品订单数据.Rows[i].Cells["产品编号"].Value.ToString();

                    if (!pm.HasProductMaterialRelation(pId))
                    {
                        invalidPid += pId + ",";
                    }
                }
                if (invalidPid != "")
                {
                    invalidPid = invalidPid.TrimEnd(',');
                    DialogResult dr = MessageBox.Show("产品[" + invalidPid + "]没有建立产品原料关系,你确定要制定生产计划?", "请确认", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.Cancel)
                    {
                        MessageBox.Show("操作终止,去维护产品原料关系");
                        return;
                    }
                }

                // do add
                bool planok = true;
                for (int i = 0; i < dataGridView产品订单数据.Rows.Count; i++)
                {
                    plan.RelatedOrderId = text订单编号.Text;
                    plan.ProductId      = dataGridView产品订单数据.Rows[i].Cells["产品编号"].Value.ToString();

                    // plan.CustomerId = l编号.Text;
                    plan.OrderTime      = DateTime.Now;
                    plan.Count          = Convert.ToInt16(dataGridView产品订单数据.Rows[i].Cells["数量"].Value);
                    plan.PlanningTime   = date交付时间.Value;
                    plan.FinishTime     = DateTime.Parse("2000-01-01");
                    plan.PlanState      = ProductionPlanStatus.PENDING;
                    plan.InChargePerson = Utils.GetCurrentUsername();

                    plan.finishedCount = int.Parse(textBox库存件数.Text == "" ? "0" : textBox库存件数.Text);
                    if (checkBox1.Checked && plan.finishedCount > 0)
                    {
                        plan.hasFromStore = "是";
                        // 扣除库存
                        pm.UpdateProductStoreCount(-plan.finishedCount, plan.ProductId);
                        //if (plan.finishedCount >= selectedProdCount)
                        //{
                        //    plan.PlanState = ProductionPlanStatus.STORED;
                        //}
                    }

                    if (!ppm.AddNewPlan(plan))
                    {
                        MessageBox.Show("插入计划失败");
                        planok = false;
                        // 恢复库存
                        pm.UpdateProductStoreCount(plan.finishedCount, plan.ProductId);
                        break;
                    }
                    ;
                }
                if (planok == true)
                {
                    if (odm.UpdateOrderStatus(OrderStatus.PROCESSING, text订单编号.Text))
                    {
                        MessageBox.Show("生产计划生成成功!"); this.Close();
                    }
                    else
                    {
                        MessageBox.Show("生产计划生成失败!");
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }