Ejemplo n.º 1
0
        private void MenuItem_HalfProductIn_Click(object sender, RoutedEventArgs e)
        {
            Model_ProductionBookkeeping m = this.DataGrid_ProductionBookkeeping.SelectedCells[0].Item as Model_ProductionBookkeeping;

            if (m.IsTurn != 0)
            {
                MessageBox.Show("此行数据已经添加到半成品仓库中,请勿重复添加!");
                return;
            }
            else
            {
                WarehouseHalpProductModel mm = new WarehouseHalpProductModel();
                mm.ProductID = m.ProductGuid;
                mm.Quantity  = m.P4Num;
                if (new WarehouseHalfProductConsole().Insert(mm) && new ProductionBookkeepingConsole().UpdateTurn(m))
                {
                    MessageBox.Show("成功添加" + m.ProductName + "到半成品仓库!");
                    InitializeData();
                    HalfProductEvent.OnUpdateDataGrid();
                }
                else
                {
                    MessageBox.Show("添加失败,请联系管理员!");
                }
            }
        }
        internal bool Insert(WarehouseHalpProductModel m)
        {
            string sql = "Insert into T_Warehouse_HalfProduct(Guid,ProductID,Date,Operator,Quantity,Remark) "
                         + " values('" + Guid.NewGuid() + "','" + m.ProductID + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + CommonParameters.LoginUserName + "','" + m.Quantity + "','" + m.Remark + "')";

            return(new Helper.SQLite.DBHelper().SingleExecution(sql));
        }
        internal bool ReadDetailsList(string Search, out List <WarehouseHalpProductModel> data)
        {
            string TableName = "T_Warehouse_HalfProduct";

            data = new List <WarehouseHalpProductModel>();
            string sql = "SELECT" +
                         "	a.ProductID,"+
                         "	b.Number,"+
                         "	b.Name,"+
                         "	b.Material,"+
                         "	b.Specification,"+
                         "	b.Type,"+
                         "	total(a.Quantity) as Quantity "+
                         "FROM "
                         + TableName +
                         "  a LEFT JOIN T_ProductInfo_Product b ON a.ProductID = b.GUID where  a.deleteMark is null and   (b.Number like '%" +
                         Search + "%' or b.Name like '%" + Search + "%')" +
                         "GROUP BY" +
                         "	a.ProductID";
            DataSet ds = new DataSet();
            decimal dd = 0m;

            if (new Helper.SQLite.DBHelper().QueryData(sql, out ds))
            {
                int id = 1;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    WarehouseHalpProductModel d = new WarehouseHalpProductModel();
                    d.Id            = id++;
                    d.Number        = dr["Number"].ToString();
                    d.ProductName   = dr["Name"].ToString();
                    d.Specification = dr["Specification"].ToString();
                    d.Type          = dr["Type"].ToString();
                    d.Material      = dr["Material"].ToString();
                    decimal.TryParse(dr["Quantity"].ToString(), out dd);
                    d.Quantity = dd;
                    data.Add(d);
                }
                return(true);
            }
            return(false);
        }