Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Maticsoft.Model.ConsumableStorage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_ConsumableStorage(");
            strSql.Append("C_Barcode,Count,UserName,Datetime,Remarks)");
            strSql.Append(" values (");
            strSql.Append("@C_Barcode,@Count,@UserName,@Datetime,@Remarks)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_Barcode", SqlDbType.VarChar, 50),
                new SqlParameter("@Count",     SqlDbType.Int,      4),
                new SqlParameter("@UserName",  SqlDbType.VarChar, 50),
                new SqlParameter("@Datetime",  SqlDbType.VarChar, 50),
                new SqlParameter("@Remarks",   SqlDbType.Text)
            };
            parameters[0].Value = model.C_Barcode;
            parameters[1].Value = model.Count;
            parameters[2].Value = model.UserName;
            parameters[3].Value = model.Datetime;
            parameters[4].Value = model.Remarks;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.ConsumableStorage DataRowToModel(DataRow row)
 {
     Maticsoft.Model.ConsumableStorage model = new Maticsoft.Model.ConsumableStorage();
     if (row != null)
     {
         if (row["C_StoID"] != null && row["C_StoID"].ToString() != "")
         {
             model.C_StoID = decimal.Parse(row["C_StoID"].ToString());
         }
         if (row["C_Barcode"] != null)
         {
             model.C_Barcode = row["C_Barcode"].ToString();
         }
         if (row["Count"] != null && row["Count"].ToString() != "")
         {
             model.Count = int.Parse(row["Count"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Datetime"] != null)
         {
             model.Datetime = row["Datetime"].ToString();
         }
         if (row["Remarks"] != null)
         {
             model.Remarks = row["Remarks"].ToString();
         }
     }
     return(model);
 }
Esempio n. 3
0
 private void ShowInfo(decimal C_StoID)
 {
     Maticsoft.BLL.ConsumableStorage   bll   = new Maticsoft.BLL.ConsumableStorage();
     Maticsoft.Model.ConsumableStorage model = bll.GetModel(C_StoID);
     this.lblC_StoID.Text   = model.C_StoID.ToString();
     this.lblC_Barcode.Text = model.C_Barcode;
     this.lblCount.Text     = model.Count.ToString();
     this.lblUserName.Text  = model.UserName;
     this.lblDatetime.Text  = model.Datetime;
     this.lblRemarks.Text   = model.Remarks;
 }
Esempio n. 4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtC_Barcode.Text.Trim().Length == 0)
            {
                strErr += "C_Barcode不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtCount.Text))
            {
                strErr += "Count格式错误!\\n";
            }
            if (this.txtUserName.Text.Trim().Length == 0)
            {
                strErr += "UserName不能为空!\\n";
            }
            if (this.txtDatetime.Text.Trim().Length == 0)
            {
                strErr += "Datetime不能为空!\\n";
            }
            if (this.txtRemarks.Text.Trim().Length == 0)
            {
                strErr += "Remarks不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            decimal C_StoID   = decimal.Parse(this.lblC_StoID.Text);
            string  C_Barcode = this.txtC_Barcode.Text;
            int     Count     = int.Parse(this.txtCount.Text);
            string  UserName  = this.txtUserName.Text;
            string  Datetime  = this.txtDatetime.Text;
            string  Remarks   = this.txtRemarks.Text;


            Maticsoft.Model.ConsumableStorage model = new Maticsoft.Model.ConsumableStorage();
            model.C_StoID   = C_StoID;
            model.C_Barcode = C_Barcode;
            model.Count     = Count;
            model.UserName  = UserName;
            model.Datetime  = Datetime;
            model.Remarks   = Remarks;

            Maticsoft.BLL.ConsumableStorage bll = new Maticsoft.BLL.ConsumableStorage();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 5
0
        /// <summary>
        /// 保存入库记录 并更改库存
        /// </summary>
        /// <param name="lis"></param>
        private int Add_Stotage(DataGrid _Grid)
        {
            ConsumableStorage _M_ConsumableReceive = new ConsumableStorage();
            int _recode = 0;

            foreach (object tem in _Grid.ItemsSource)
            {
                Maticsoft.Model.ConsumableStorage _tem = (Maticsoft.Model.ConsumableStorage)tem;
                _tem.Datetime = DateTime.Now.ToString();
                if (_M_ConsumableReceive.Add(_tem) > 0)
                {
                    _recode++;
                }
            }
            return(_recode);
        }
        //
        //添加
        //
        private void btn_Add_Click(object sender, RoutedEventArgs e)
        {
            Maticsoft.Model.ConsumableReceive _Receive = new Maticsoft.Model.ConsumableReceive();
            //  _Receive = (Maticsoft.Model.ConsumableReceive)dgv_ConsumableList.DataContext;

            Maticsoft.Model.ConsumableStorage _Storage = new Maticsoft.Model.ConsumableStorage();
            //  _Storage = (Maticsoft.Model.ConsumableStorage)dgv_ConsumableList.DataContext;

            bool IsOk = true;

            MCP_CS.CheckTextBoxNotNull(ref IsOk, txb_Consumable_Barcode, txb_R_Count, txb_R_Remaks, txb_R_UserID, txb_R_UserName);
            if (IsOk)
            {
                if (_ConsumOperation.Operation == Maticsoft.BLL.cls_Consumable.ConsumableOperation.Receive)
                {
                    _Receive.C_Barcode = txb_Consumable_Barcode.Text.Trim();
                    _Receive.C_Name    = txb_ConsumableName.Text.Trim();
                    _Receive.Datetime  = DateTime.Now.ToString();
                    _Receive.Count     = int.Parse(txb_R_Count.Text.Trim());
                    _Receive.UserName  = txb_R_UserName.Text.Trim();
                    _Receive.Remarks   = txb_R_Remaks.Text.Trim();

                    _dataList_Receive.Add(_Receive);
                }
                else
                {
                    _Storage.C_Barcode = txb_Consumable_Barcode.Text.Trim();
                    _Storage.C_Name    = txb_ConsumableName.Text.Trim();
                    _Storage.Datetime  = DateTime.Now.ToString();
                    _Storage.Count     = int.Parse(txb_R_Count.Text.Trim());
                    _Storage.UserName  = txb_R_UserName.Text.Trim();
                    _Storage.Remarks   = txb_R_Remaks.Text.Trim();

                    _dataList_Storage.Add(_Storage);
                }
                //
                txb_R_Count.Text            = "";
                txb_Consumable_Barcode.Text = "";
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.ConsumableStorage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_ConsumableStorage set ");
            strSql.Append("C_Barcode=@C_Barcode,");
            strSql.Append("Count=@Count,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Datetime=@Datetime,");
            strSql.Append("Remarks=@Remarks");
            strSql.Append(" where C_StoID=@C_StoID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_Barcode", SqlDbType.VarChar, 50),
                new SqlParameter("@Count",     SqlDbType.Int,      4),
                new SqlParameter("@UserName",  SqlDbType.VarChar, 50),
                new SqlParameter("@Datetime",  SqlDbType.VarChar, 50),
                new SqlParameter("@Remarks",   SqlDbType.Text),
                new SqlParameter("@C_StoID",   SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.C_Barcode;
            parameters[1].Value = model.Count;
            parameters[2].Value = model.UserName;
            parameters[3].Value = model.Datetime;
            parameters[4].Value = model.Remarks;
            parameters[5].Value = model.C_StoID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.ConsumableStorage GetModel(decimal C_StoID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 C_StoID,C_Barcode,Count,UserName,Datetime,Remarks from tb_ConsumableStorage ");
            strSql.Append(" where C_StoID=@C_StoID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_StoID", SqlDbType.Decimal)
            };
            parameters[0].Value = C_StoID;

            Maticsoft.Model.ConsumableStorage model = new Maticsoft.Model.ConsumableStorage();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }