/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.Dispose model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Dispose("); strSql.Append("RejectCode,DisposeMethod,Descriptions)"); strSql.Append(" values ("); strSql.Append("@RejectCode,@DisposeMethod,@Descriptions)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@RejectCode", SqlDbType.VarChar, 20), new SqlParameter("@DisposeMethod", SqlDbType.VarChar, 100), new SqlParameter("@Descriptions", SqlDbType.VarChar, 255) }; parameters[0].Value = model.RejectCode; parameters[1].Value = model.DisposeMethod; parameters[2].Value = model.Descriptions; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Dispose model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Dispose set "); strSql.Append("RejectCode=@RejectCode,"); strSql.Append("DisposeMethod=@DisposeMethod,"); strSql.Append("Descriptions=@Descriptions"); SqlParameter[] parameters = { new SqlParameter("@RejectCode", SqlDbType.VarChar, 20), new SqlParameter("@DisposeMethod", SqlDbType.VarChar, 100), new SqlParameter("@Descriptions", SqlDbType.VarChar, 255), new SqlParameter("@ID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.RejectCode; parameters[1].Value = model.DisposeMethod; parameters[2].Value = model.Descriptions; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
// //查看重工记录 // private void dgv_Info_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { Maticsoft.Model.Rework temRek = (Maticsoft.Model.Rework)dgv_Info.SelectedItem; Maticsoft.Model.Rejected temRej = new Maticsoft.Model.Rejected(); Maticsoft.Model.Dispose temDis = new Maticsoft.Model.Dispose(); temRej = _M_Rejected.GetModel(temRek.RejectID); temDis = _M_Dispose.GetModel(decimal.Parse(temRek.DisposeID)); //不良显示 cmb_Reject.Text = temRej.Reject; txb_Search_RejectCode.Text = temRej.RejectCode; //在控件中显示图片 BitmapImage BI = new BitmapImage(); BI.BeginInit(); BI.StreamSource = new MemoryStream(temRej.Picture); //bufPic是图片二进制,byte类型 BI.EndInit(); image1.Source = BI; //image是XAML页面上定义的Image控件 //处理方法显示 cmb_DesposeMethod.Text = temDis.DisposeMethod; lab_ID.Content = temDis.ID; //处理结果 txb_SerialNumber.Text = temRek.SN; cmb_PigtaiType.Text = temRek.PigtailType; cmb_Result.Text = temRek.Result; txb_Operator.Text = temRek.ReworkID; txb_Verify.Text = temRek.VerifyID; txb_Length.Text = temRek.Length; } catch (System.Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtRejectCode.Text.Trim().Length == 0) { strErr += "RejectCode不能为空!\\n"; } if (this.txtDisposeMethod.Text.Trim().Length == 0) { strErr += "DisposeMethod不能为空!\\n"; } if (this.txtDescriptions.Text.Trim().Length == 0) { strErr += "Descriptions不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string RejectCode = this.txtRejectCode.Text; string DisposeMethod = this.txtDisposeMethod.Text; string Descriptions = this.txtDescriptions.Text; Maticsoft.Model.Dispose model = new Maticsoft.Model.Dispose(); model.RejectCode = RejectCode; model.DisposeMethod = DisposeMethod; model.Descriptions = Descriptions; Maticsoft.BLL.Dispose bll = new Maticsoft.BLL.Dispose(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(decimal ID) { Maticsoft.BLL.Dispose bll = new Maticsoft.BLL.Dispose(); Maticsoft.Model.Dispose model = bll.GetModel(ID); this.lblID.Text = model.ID.ToString(); this.txtRejectCode.Text = model.RejectCode; this.txtDisposeMethod.Text = model.DisposeMethod; this.txtDescriptions.Text = model.Descriptions; }
// //选择处理方法 // private void dgv_ReCordList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { try { Maticsoft.Model.Dispose temdispe = (Maticsoft.Model.Dispose)dgv_ReCordList.SelectedItem; txb_ReWorkMethod.Text = temdispe.DisposeMethod; cmb_LengthVerify.Text = temdispe.Descriptions; } catch (System.Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dispose DataRowToModel(DataRow row) { Maticsoft.Model.Dispose model = new Maticsoft.Model.Dispose(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = decimal.Parse(row["ID"].ToString()); } if (row["RejectCode"] != null) { model.RejectCode = row["RejectCode"].ToString(); } if (row["DisposeMethod"] != null) { model.DisposeMethod = row["DisposeMethod"].ToString(); } if (row["Descriptions"] != null) { model.Descriptions = row["Descriptions"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dispose GetModel(decimal ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,RejectCode,DisposeMethod,Descriptions from tb_Dispose "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.VarChar, 20) }; parameters[0].Value = ID; Maticsoft.Model.Dispose model = new Maticsoft.Model.Dispose(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }