internal bool ReadList(Guid ProductGuid, out Model.AssemblyLineModuleModel d)
        {
            bool flag        = true;
            bool isFirstLine = true;

            d = new Model.AssemblyLineModuleModel();
            List <Model.AssemblyLineModuleProcessModel> ProcessList = new List <Model.AssemblyLineModuleProcessModel>();

            d.Guid = ProductGuid;
            string sql = " select "
                         + "   a.Number,"
                         + "   a.Name,"
                         + "   a.P1,"
                         + "   a.P2,"
                         + "   a.P3,"
                         + "   a.P4,"
                         + "   a.P5,"
                         + "   a.P6,"
                         + "   b.Process,"
                         + "   total(b.Number) as Quantity, "
                         + "   total(b.Break) as BreakNum "
                         + " from T_ProductInfo_Product a "
                         + " LEFT JOIN T_PM_ProductionSchedule b ON b.ProductID = a.GUID AND b.DeleteMark IS NULL"
                         + " where a.GUID='" + ProductGuid + "' "
                         + " GROUP BY b.Process";
            DataSet ds = new DataSet();

            flag = new Helper.SQLite.DBHelper().QueryData(sql, out ds);
            if (flag)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    d.Number = dr["Number"].ToString();
                    d.Name   = dr["Name"].ToString();
                    Model.AssemblyLineModuleProcessModel dp = new Model.AssemblyLineModuleProcessModel();
                    if (isFirstLine)
                    {
                        InitProcessList(dr, ref ProcessList);
                        isFirstLine = false;
                    }
                    for (int i = 0; i < ProcessList.Count; i++)
                    {
                        if (ProcessList[i].Process == dr["Process"].ToString())
                        {
                            ProcessList[i].Quantity = Convert.ToInt32(dr["Quantity"].ToString());
                            ProcessList[i].BreakNum = Convert.ToInt32(dr["BreakNum"].ToString());
                        }
                    }
                }
                CalculateProcessList(ProductGuid, ref ProcessList);
                d.ProcessList = ProcessList;
            }
            return(flag);
        }
 private void InitProcessList(DataRow dr, ref List <Model.AssemblyLineModuleProcessModel> d)
 {
     for (int i = 1; i < 7; i++)
     {
         if (dr["P" + i].ToString() != "无")
         {
             Model.AssemblyLineModuleProcessModel dp = new Model.AssemblyLineModuleProcessModel();
             dp.LastProcess = (i == 1) ? "" : dr["P" + (i - 1)].ToString();//赋值上一道工序,以供后面使用
             dp.Process     = dr["P" + i].ToString();
             dp.Quantity    = 0;
             d.Add(dp);
         }
     }
 }
        internal bool Add(Model.AssemblyLineModuleProcessModel d)
        {
            string        DateTimeNow  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Guid          TempGuid     = Guid.NewGuid();
            List <string> sqls         = new List <string>();
            string        sql_subtract = "Insert into T_PM_ProductionSchedule(Guid,Date,StaffID,ProductID,Process,Number,Remark,ParentGuid) "
                                         + "values('" + TempGuid + "','" + DateTimeNow + "','" + d.StaffID + "','" + d.ProductID + "','" + d.LastProcess + "'," + -(d.Quantity + d.BreakNum) + ",'自动扣半成品原料','" + d.Guid + "')";
            string sql_add = "Insert into T_PM_ProductionSchedule(Guid,Date,StaffID,ProductID,Process,Number,Break,ParentGuid) "
                             + "values('" + d.Guid + "','" + DateTimeNow + "','" + d.StaffID + "','" + d.ProductID + "','" + d.Process + "'," + d.Quantity + "," + d.BreakNum + ",'" + TempGuid + "')";

            if (d.LastProcess != "")
            {
                sqls.Add(sql_subtract);
            }
            sqls.Add(sql_add);
            return(new Helper.SQLite.DBHelper().Transaction(sqls));
        }
예제 #4
0
 private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     if (this.DataGrid.SelectedCells.Count > 0)
     {
         Model.AssemblyLineModuleProcessModel dp = this.DataGrid.SelectedCells[0].Item as Model.AssemblyLineModuleProcessModel;
         this.Label_Process.Content = dp.Process;
         if (dp.Process == "抛光")
         {
             this.Button_Add.IsEnabled = false;
         }
         else
         {
             this.Button_Add.IsEnabled = true;
             FunctionalLimitation();
         }
         this.TextBox_Quantity.Focus();
     }
 }
예제 #5
0
 /// <summary>
 /// 加工序的半成品数量
 /// </summary>
 private void ChangeQuantity()
 {
     if (this.DataGrid.SelectedCells.Count > 0)
     {
         int Quantity = 0;
         int Break    = 0;
         if (int.TryParse(this.TextBox_Quantity.Text, out Quantity))
         {
             if (Quantity == 0)
             {
                 return;
             }
             int.TryParse(this.TextBox_Break.Text, out Break);
             Model.AssemblyLineModuleProcessModel dp = this.DataGrid.SelectedCells[0].Item as Model.AssemblyLineModuleProcessModel;
             dp.Guid = Guid.NewGuid();
             if (this.ComboBox_StaffList.SelectedValue == null)
             {
                 MessageBox.Show("请至少录入一个员工", "错误");
                 return;
             }
             dp.StaffID   = (Guid)this.ComboBox_StaffList.SelectedValue;
             dp.ProductID = this.ProductGuid;
             dp.Quantity  = Quantity;
             dp.BreakNum  = Break;
             if (new ViewModel.ProductionManagement.AssemblyLineModuleConsole().Add(dp))
             {
                 if (dp.Process == d.ProcessList[d.ProcessList.Count - 1].Process)
                 {
                     Button_Storage_Click(null, null);
                 }
                 InitializeData();
             }
         }
         else
         {
             this.TextBox_Quantity.Clear();
             this.TextBox_Quantity.Focus();
         }
     }
 }