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

            strSql.Append("insert into tb_BoxInfo(");
            strSql.Append("BatchNo,BoxSN,Qty,Type,State)");
            strSql.Append(" values (");
            strSql.Append("@BatchNo,@BoxSN,@Qty,@Type,@State)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BatchNo", SqlDbType.VarChar, 30),
                new SqlParameter("@BoxSN",   SqlDbType.VarChar, 50),
                new SqlParameter("@Qty",     SqlDbType.VarChar, 30),
                new SqlParameter("@Type",    SqlDbType.VarChar, 30),
                new SqlParameter("@State",   SqlDbType.VarChar, 30)
            };
            parameters[0].Value = model.BatchNo;
            parameters[1].Value = model.BoxSN;
            parameters[2].Value = model.Qty;
            parameters[3].Value = model.Type;
            parameters[4].Value = model.State;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.BoxInfo DataRowToModel(DataRow row)
 {
     Maticsoft.Model.BoxInfo model = new Maticsoft.Model.BoxInfo();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = decimal.Parse(row["ID"].ToString());
         }
         if (row["BatchNo"] != null)
         {
             model.BatchNo = row["BatchNo"].ToString();
         }
         if (row["BoxSN"] != null)
         {
             model.BoxSN = row["BoxSN"].ToString();
         }
         if (row["Qty"] != null)
         {
             model.Qty = row["Qty"].ToString();
         }
         if (row["Type"] != null)
         {
             model.Type = row["Type"].ToString();
         }
         if (row["State"] != null)
         {
             model.State = row["State"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
 private void ShowInfo(decimal ID)
 {
     Maticsoft.BLL.BoxInfo   bll   = new Maticsoft.BLL.BoxInfo();
     Maticsoft.Model.BoxInfo model = bll.GetModel(ID);
     this.lblID.Text      = model.ID.ToString();
     this.txtBatchNo.Text = model.BatchNo;
     this.txtBoxSN.Text   = model.BoxSN;
     this.txtQty.Text     = model.Qty;
     this.txtType.Text    = model.Type;
     this.txtState.Text   = model.State;
 }
Exemplo n.º 4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtBatchNo.Text.Trim().Length == 0)
            {
                strErr += "BatchNo不能为空!\\n";
            }
            if (this.txtBoxSN.Text.Trim().Length == 0)
            {
                strErr += "BoxSN不能为空!\\n";
            }
            if (this.txtQty.Text.Trim().Length == 0)
            {
                strErr += "Qty不能为空!\\n";
            }
            if (this.txtType.Text.Trim().Length == 0)
            {
                strErr += "Type不能为空!\\n";
            }
            if (this.txtState.Text.Trim().Length == 0)
            {
                strErr += "State不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            decimal ID      = decimal.Parse(this.lblID.Text);
            string  BatchNo = this.txtBatchNo.Text;
            string  BoxSN   = this.txtBoxSN.Text;
            string  Qty     = this.txtQty.Text;
            string  Type    = this.txtType.Text;
            string  State   = this.txtState.Text;


            Maticsoft.Model.BoxInfo model = new Maticsoft.Model.BoxInfo();
            model.ID      = ID;
            model.BatchNo = BatchNo;
            model.BoxSN   = BoxSN;
            model.Qty     = Qty;
            model.Type    = Type;
            model.State   = State;

            Maticsoft.BLL.BoxInfo bll = new Maticsoft.BLL.BoxInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.BoxInfo GetModel(string sqlWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT TOP (1) ID, BatchNo, BoxSN, Qty, Type, State FROM tb_BoxInfo WHERE ");
            strSql.Append(sqlWhere);
            strSql.Append("ORDER BY ID");
            Maticsoft.Model.BoxInfo model = new Maticsoft.Model.BoxInfo();
            DataSet ds = dbs.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                Maticsoft.Model.BoxInfo tem = new Model.BoxInfo();
                return(tem);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.BoxInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_BoxInfo set ");
            strSql.Append("BatchNo=@BatchNo,");
            strSql.Append("BoxSN=@BoxSN,");
            strSql.Append("Qty=@Qty,");
            strSql.Append("Type=@Type,");
            strSql.Append("State=@State");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BatchNo", SqlDbType.VarChar, 30),
                new SqlParameter("@BoxSN",   SqlDbType.VarChar, 50),
                new SqlParameter("@Qty",     SqlDbType.VarChar, 30),
                new SqlParameter("@Type",    SqlDbType.VarChar, 30),
                new SqlParameter("@State",   SqlDbType.VarChar, 30),
                new SqlParameter("@ID",      SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.BatchNo;
            parameters[1].Value = model.BoxSN;
            parameters[2].Value = model.Qty;
            parameters[3].Value = model.Type;
            parameters[4].Value = model.State;
            parameters[5].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        //
        //扫描箱号
        //
        private void txb_BoxSN_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Enter && txb_BoxSN.IsFocused)
            {
                //获取箱号
                Maticsoft.BLL.BoxInfo _M_BoxInfo = new Maticsoft.BLL.BoxInfo();
                _GTT_BoxInfo = _M_BoxInfo.GetModel("(BatchNo = '" + cmb_BatchNo.Text.Trim() + "') AND (State = 'NotEncasement') AND (BoxSN = '" + txb_BoxSN.Text.Trim() + "')");
                if (_GTT_BoxInfo.BoxSN != null)
                {
                    //验证通过
                    SolidColorBrush myBrush = new SolidColorBrush(_Mycolor); //定义纯色绘制 变量
                    lab_BoxResult.Text = "PASS"; lab_BoxResult.Foreground = myBrush;

                    //箱子总量
                    txb_BoxCount.Text   = _GTT_BoxInfo.Qty;
                    txb_BoxSN.IsEnabled = false;

                    //显示箱子已包装数量
                    Encasement _M_Encasement = new Encasement();
                    txb_SackCount.Text = _M_Encasement.GetBoxCount("(BoxID = '" + _GTT_BoxInfo.ID + "')").ToString();

                    //在 ListBox 控件中显示
                    view.Source = _M_Encasement.GetModelList("(BoxID = '" + _GTT_BoxInfo.ID + "')");
                    lab_EncasementRecordCount.Text = lsv_SerialNumberList.Items.Count.ToString();

                    //判断是否箱子装满
                    if (txb_SackCount.Text.Trim() == txb_BoxCount.Text.Trim())
                    {
                        txb_SerialNumber.IsEnabled = false;
                    }
                }
                else
                {
                    lab_BoxResult.Text = "FAIL"; lab_BoxResult.Foreground = Brushes.Red;
                    My_MessageBox.My_MessageBox_Message("此箱号不属于此批号,或此箱号已装箱!\r\n请更换箱号后重试!");
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.BoxInfo GetModel(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,BatchNo,BoxSN,Qty,Type,State from tb_BoxInfo ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Decimal)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        //
        //保存装箱信息 
        //
        private void btn_Save_PackSettinh_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                //****保存装箱设置               
                EncasementSet _M_EncasementSet = new EncasementSet();
                Maticsoft.Model.EncasementSet _EncasementSet = _M_EncasementSet.GetModel(cmb_Pak_BatchNo.Text.Trim());
                         
                if (_EncasementSet.BatchNo == null)
                {
                    _EncasementSet.BatchNo = cmb_Pak_BatchNo.Text.Trim();
                    _EncasementSet.Device = txb_Pak_Device.Text.Trim();
                    _EncasementSet.DeviceQty = txb_Pak_DeviceCount.Text.Trim();
                    _EncasementSet.SackQty = txb_Pak_SackQty.Text.Trim();

                    _M_EncasementSet.Add(_EncasementSet); //添加
                }
                else 
                {
                    _EncasementSet.BatchNo = cmb_Pak_BatchNo.Text.Trim();
                    _EncasementSet.Device = txb_Pak_Device.Text.Trim();
                    _EncasementSet.DeviceQty = txb_Pak_DeviceCount.Text.Trim();
                    _EncasementSet.SackQty = txb_Pak_SackQty.Text.Trim();

                    _M_EncasementSet.Update(_EncasementSet); 
                }

                //保存箱号
                ObservableCollection<Maticsoft.Model.BoxInfo> _BoxInfo = new ObservableCollection<Maticsoft.Model.BoxInfo>();
                Maticsoft.Model.BoxInfo _TemBoxInfo = new Maticsoft.Model.BoxInfo();
                BoxInfo _M_BoxInfo = new BoxInfo();
                foreach (Customer Temcutomer in customers)
                {
                    _TemBoxInfo = _M_BoxInfo.GetModel("BoxSN = '"+Temcutomer.BoxSN+"'");
                                  
                    if (_TemBoxInfo.BoxSN == null)   //如果不存在则添加  否则 更新
                    {
                        _TemBoxInfo.BatchNo = cmb_Pak_BatchNo.Text.Trim();
                        _TemBoxInfo.Type = "BoxSN";
                        _TemBoxInfo.State = "NotEncasement";
                        _TemBoxInfo.BoxSN = Temcutomer.BoxSN;
                        _TemBoxInfo.Qty = Temcutomer.Qty;
                        _M_BoxInfo.Add(_TemBoxInfo);
                    }
                    else 
                    {
                        _TemBoxInfo.BatchNo = cmb_Pak_BatchNo.Text.Trim();
                        _TemBoxInfo.Type = "BoxSN";
                       // _TemBoxInfo.State = "NotEncasement";
                        _TemBoxInfo.BoxSN = Temcutomer.BoxSN;
                        _TemBoxInfo.Qty = Temcutomer.Qty;

                        _M_BoxInfo.Update(_TemBoxInfo);
                    }
                }

                My_MessageBox.My_MessageBox_Message("保存完成!");
                customers.Clear();
            }
            catch (System.Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); }

        }