/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Encasement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Encasement set "); strSql.Append("BoxID=@BoxID,"); strSql.Append("SN=@SN,"); strSql.Append("Qty=@Qty"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@BoxID", SqlDbType.VarChar, 30), new SqlParameter("@SN", SqlDbType.VarChar, 50), new SqlParameter("@Qty", SqlDbType.VarChar, 30), new SqlParameter("@ID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.BoxID; parameters[1].Value = model.SN; parameters[2].Value = model.Qty; parameters[3].Value = model.ID; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.Encasement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Encasement("); strSql.Append("BoxID,SN,Qty)"); strSql.Append(" values ("); strSql.Append("@BoxID,@SN,@Qty)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@BoxID", SqlDbType.VarChar, 30), new SqlParameter("@SN", SqlDbType.VarChar, 50), new SqlParameter("@Qty", SqlDbType.VarChar, 30) }; parameters[0].Value = model.BoxID; parameters[1].Value = model.SN; parameters[2].Value = model.Qty; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Encasement GetModel(decimal ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,BoxID,SN,Qty from tb_Encasement "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Decimal) }; parameters[0].Value = ID; Maticsoft.Model.Encasement model = new Maticsoft.Model.Encasement(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Encasement DataRowToModel(DataRow row) { Maticsoft.Model.Encasement model = new Maticsoft.Model.Encasement(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = decimal.Parse(row["ID"].ToString()); } if (row["BoxID"] != null) { model.BoxID = row["BoxID"].ToString(); } if (row["SN"] != null) { model.SN = row["SN"].ToString(); } if (row["Qty"] != null) { model.Qty = row["Qty"].ToString(); } } return(model); }
// //扫描条码 // private void txb_SerialNumber_KeyUp(object sender, KeyEventArgs e) { try { if (e.Key == System.Windows.Input.Key.Enter && txb_SerialNumber.IsFocused) { if (txb_W_BoxSN.IsEnabled || txb_BoxSN.IsEnabled) { My_MessageBox.My_MessageBox_Message("请扫描外箱箱号与外箱ASN编码!"); } else { Encasement _M_Encasement = new Encasement(); Maticsoft.BLL.SerialNumber _M_SerialNumber = new SerialNumber(); //条码是否属于此工单 if (!_M_SerialNumber.Exists_where("(OrderID = '" + txb_OrderID.Text.Trim() + "') AND (SN LIKE '" + txb_SerialNumber.Text.Trim() + "%')")) { My_MessageBox.My_MessageBox_Message("此条吗不属于此工单!"); } else { //条码是否已经检测通过 if (!_M_SerialNumber.Exists_where("(State = 'Yet_Pack') AND (SN LIKE '" + txb_SerialNumber.Text.Trim() + "%')")) { My_MessageBox.My_MessageBox_Message("此条码未经过出货检测!"); } else { //条码是否已经装箱 if (_M_Encasement.Exists_where("(SN = '" + txb_SerialNumber.Text.Trim() + "')")) { My_MessageBox.My_MessageBox_Message("此条码已经装箱!"); } else { Maticsoft.BLL.LabelCheck labcheck = new LabelCheck(); //条码是否已经检测标签 if (!labcheck.Exists(txb_SerialNumber.Text.Trim())) { My_MessageBox.My_MessageBox_Message("此条码未核对标签!"); } else { //赋值记录 Maticsoft.Model.Encasement _Encasement = new Maticsoft.Model.Encasement(); _Encasement.BoxID = _GTT_BoxInfo.ID.ToString(); _Encasement.SN = txb_SerialNumber.Text.Trim(); _Encasement.Qty = Info_SackQty.Text.Trim(); //保存记录 _M_Encasement.Add(_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; } txb_SerialNumber.Text = ""; //批号装箱完成 Maticsoft.BLL.BoxInfo _M_BoxInfo = new Maticsoft.BLL.BoxInfo(); if (_M_BoxInfo.GetYetEncasementCount("tb_BoxInfo.BatchNo = '" + cmb_BatchNo.Text.Trim() + "'") >= int.Parse(txb_BatchCount.Text.Trim())) { My_MessageBox.My_MessageBox_Message("批号:" + cmb_BatchNo.Text.Trim() + "数量:" + txb_BatchCount.Text.Trim() + "\r\n线材扫描完毕,请继续装箱!"); txb_SerialNumber.IsEnabled = false; } } } } } } } } catch (System.Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); } }