internal Model_ProductionManagement_OutsideProcessBatch ReadProductInfo(string ProductNumber)
        {
            Model_ProductionManagement_OutsideProcessBatch m = new Model_ProductionManagement_OutsideProcessBatch();
            string  sql  = "SELECT GUID,Name,Material,P1,P2,P3,P4,P5,P6 FROM T_ProductInfo_Product WHERE NUMBER='" + ProductNumber + "' AND DELETEMARK ISNULL";
            DataSet ds   = new DataSet();
            bool    flag = new Helper.SQLite.DBHelper().QueryData(sql, out ds);

            if (flag)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    m.ProductGuid   = (Guid)dr["GUID"];
                    m.ProductNumber = ProductNumber;
                    m.ProductName   = dr["Name"].ToString();
                    m.Material      = dr["Material"].ToString();
                    for (int i = 1; i < 7; i++)
                    {
                        if (dr["P" + i].ToString() == "抛光")
                        {
                            m.HasPolishing = true;
                        }
                    }
                }
            }
            return(m);
        }
        /// <summary>
        /// 编辑时读取记录明细
        /// </summary>
        /// <returns></returns>
        internal ObservableCollection <Model_ProductionManagement_OutsideProcessBatch> ReadDatas(Model_BatchInputOrder OrderData)
        {
            ObservableCollection <Model_ProductionManagement_OutsideProcessBatch> data = new ObservableCollection <Model_ProductionManagement_OutsideProcessBatch>();
            Model_ProductionManagement_OutsideProcessBatch m;
            DataSet ds  = new DataSet();
            string  sql = "Select a.*, "
                          + " b.Guid as PDGuid,b.Number as PDNumber,b.Name as PDName,b.Material, "
                          + " c.Guid as PCGuid,c.Number as PCNumber,c.Name as PCName "
                          + " from T_PM_ProcessSchedule a "
                          + " Left join T_ProductInfo_Product b ON b.Guid=a.ProductID "
                          + " Left Join T_UserInfo_Processors c ON c.Guid=a.ProcessorsID "
                          + " WHERE a.Obligate1='" + OrderData.Guid + "' "
                          //+ " AND a.DeleteMark ISNULL "
                          //+ " AND a.OrderType='" + ((OrderData.OrderType == "0") ? "出单" : "入单") + "'"
            ;

            if (new Helper.SQLite.DBHelper().QueryData(sql, out ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    m = new Model_ProductionManagement_OutsideProcessBatch();

                    //Product Info
                    m.ProductGuid   = (Guid)dr["PDGuid"];
                    m.ProductNumber = dr["PDNumber"].ToString();
                    m.ProductName   = dr["PDName"].ToString();
                    m.Material      = dr["Material"].ToString();
                    //Processors Info
                    m.ProcessorsGuid   = (Guid)dr["PCGuid"];
                    m.ProcessorsNumber = dr["PCNumber"].ToString();
                    m.ProcessorsName   = dr["PCName"].ToString();
                    //Input Info
                    m.Quantity      = int.Parse(dr["Quantity"].ToString());
                    m.MinorInjuries = int.Parse(dr["MinorInjuries"].ToString());
                    m.Injuries      = int.Parse(dr["Injuries"].ToString());
                    m.Lose          = int.Parse(dr["Lose"].ToString());
                    m.Remark        = dr["Remark"].ToString();

                    data.Add(m);
                }
            }
            if (data.Count < 20)
            {
                int COUNT = data.Count;
                for (int i = 0; i < 20 - COUNT; i++)
                {
                    data.Add(new Model_ProductionManagement_OutsideProcessBatch {
                        Id = i + 1
                    });
                }
            }
            return(data);
        }
        internal Model_ProductionManagement_OutsideProcessBatch ReadProcessorsInfo(string ProcessorsNumber)
        {
            Model_ProductionManagement_OutsideProcessBatch m = new Model_ProductionManagement_OutsideProcessBatch();
            string  sql  = "SELECT GUID,Name FROM T_UserInfo_Processors WHERE NUMBER='" + ProcessorsNumber + "' AND DELETEMARK ISNULL";
            DataSet ds   = new DataSet();
            bool    flag = new Helper.SQLite.DBHelper().QueryData(sql, out ds);

            if (flag)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    m.ProcessorsGuid   = (Guid)dr["GUID"];
                    m.ProcessorsNumber = ProcessorsNumber;
                    m.ProcessorsName   = dr["Name"].ToString();
                }
            }
            return(m);
        }
Example #4
0
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            Model_ProductionManagement_OutsideProcessBatch model = this.DataGrid.SelectedCells[0].Item as Model_ProductionManagement_OutsideProcessBatch;
            string newValue = (e.EditingElement as TextBox).Text.Trim();
            string Header   = e.Column.Header.ToString();

            if (Header == "产品编号")
            {
                Model_ProductionManagement_OutsideProcessBatch m = new OutsideProcessBatchInputConsole().ReadProductInfo(newValue);
                if (m.ProductGuid == new Guid())
                {
                    DataGrid.CurrentCell = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[0]);
                    data[data.IndexOf(model)].ProductGuid = new Guid();
                    data[data.IndexOf(model)].ProductName = "";
                    data[data.IndexOf(model)].Material    = "";
                }
                else if (m.HasPolishing == false)
                {
                    DataGrid.CurrentCell = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[0]);
                    data[data.IndexOf(model)].ProductGuid = new Guid();
                    data[data.IndexOf(model)].ProductName = "";
                    data[data.IndexOf(model)].Material    = "";
                    data[data.IndexOf(model)].Remark      = "该产品没有抛光工序,请重新录入。";
                }
                else
                {
                    data[data.IndexOf(model)].ProductGuid = m.ProductGuid;
                    data[data.IndexOf(model)].ProductName = m.ProductName;
                    data[data.IndexOf(model)].Material    = m.Material;
                    if (data[data.IndexOf(model)].Remark == "该产品没有抛光工序,请重新录入。")
                    {
                        data[data.IndexOf(model)].Remark = "";
                    }
                }
            }
        }