// //选择治具 // private void dgv_FixtureList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { try { _W_FixList = (Maticsoft.Model.FixtureList)dgv_FixtureList.SelectedItem; SetControlValue(_W_FixList); } catch { } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.FixtureList DataRowToModel(DataRow row) { Maticsoft.Model.FixtureList model = new Maticsoft.Model.FixtureList(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = decimal.Parse(row["ID"].ToString()); } if (row["BarCode"] != null) { model.BarCode = row["BarCode"].ToString(); } if (row["Fixture_Name"] != null) { model.Fixture_Name = row["Fixture_Name"].ToString(); } if (row["InstallLocation"] != null) { model.InstallLocation = row["InstallLocation"].ToString(); } if (row["F_State"] != null) { model.F_State = row["F_State"].ToString(); } if (row["LogDate"] != null && row["LogDate"].ToString() != "") { model.LogDate = DateTime.Parse(row["LogDate"].ToString()); } if (row["LogUser"] != null) { model.LogUser = row["LogUser"].ToString(); } if (row["CareUser"] != null) { model.CareUser = row["CareUser"].ToString(); } if (row["UseDate"] != null && row["UseDate"].ToString() != "") { model.UseDate = DateTime.Parse(row["UseDate"].ToString()); } if (row["ScrapDate"] != null && row["ScrapDate"].ToString() != "") { model.ScrapDate = DateTime.Parse(row["ScrapDate"].ToString()); } if (row["FAY_ID"] != null) { model.FAY_ID = row["FAY_ID"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.FixtureList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_FixtureList set "); strSql.Append("BarCode=@BarCode,"); strSql.Append("Fixture_Name=@Fixture_Name,"); strSql.Append("InstallLocation=@InstallLocation,"); strSql.Append("F_State=@F_State,"); strSql.Append("LogDate=@LogDate,"); strSql.Append("LogUser=@LogUser,"); strSql.Append("CareUser=@CareUser,"); strSql.Append("UseDate=@UseDate,"); strSql.Append("ScrapDate=@ScrapDate,"); strSql.Append("FAY_ID=@FAY_ID,"); strSql.Append("Remark=@Remark"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@BarCode", SqlDbType.VarChar, 50), new SqlParameter("@Fixture_Name", SqlDbType.VarChar, 50), new SqlParameter("@InstallLocation", SqlDbType.VarChar, 50), new SqlParameter("@F_State", SqlDbType.VarChar, 50), new SqlParameter("@LogDate", SqlDbType.DateTime), new SqlParameter("@LogUser", SqlDbType.VarChar, 50), new SqlParameter("@CareUser", SqlDbType.VarChar, 50), new SqlParameter("@UseDate", SqlDbType.DateTime), new SqlParameter("@ScrapDate", SqlDbType.DateTime), new SqlParameter("@FAY_ID", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 255), new SqlParameter("@ID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.BarCode; parameters[1].Value = model.Fixture_Name; parameters[2].Value = model.InstallLocation; parameters[3].Value = model.F_State; parameters[4].Value = model.LogDate; parameters[5].Value = model.LogUser; parameters[6].Value = model.CareUser; parameters[7].Value = model.UseDate; parameters[8].Value = model.ScrapDate; parameters[9].Value = model.FAY_ID; parameters[10].Value = model.Remark; parameters[11].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获取治具总表中的治具列表 /// </summary> /// <param name="_Fix"></param> /// <returns></returns> private ArrayList FixList(Maticsoft.Model.FixtureList _Fix) { ArrayList tem = new ArrayList(); /* * foreach (object fix in MCP_CS.FixtureInfo.GetModelList("(Assembly_BarCode = '" + _Fix.Assembly_BarCode + "')")) * { * tem.Add(fix); * } */ return(tem); }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.FixtureList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_FixtureList("); strSql.Append("BarCode,Fixture_Name,InstallLocation,F_State,LogDate,LogUser,CareUser,UseDate,ScrapDate,FAY_ID,Remark)"); strSql.Append(" values ("); strSql.Append("@BarCode,@Fixture_Name,@InstallLocation,@F_State,@LogDate,@LogUser,@CareUser,@UseDate,@ScrapDate,@FAY_ID,@Remark)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@BarCode", SqlDbType.VarChar, 50), new SqlParameter("@Fixture_Name", SqlDbType.VarChar, 50), new SqlParameter("@InstallLocation", SqlDbType.VarChar, 50), new SqlParameter("@F_State", SqlDbType.VarChar, 50), new SqlParameter("@LogDate", SqlDbType.DateTime), new SqlParameter("@LogUser", SqlDbType.VarChar, 50), new SqlParameter("@CareUser", SqlDbType.VarChar, 50), new SqlParameter("@UseDate", SqlDbType.DateTime), new SqlParameter("@ScrapDate", SqlDbType.DateTime), new SqlParameter("@FAY_ID", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 255) }; parameters[0].Value = model.BarCode; parameters[1].Value = model.Fixture_Name; parameters[2].Value = model.InstallLocation; parameters[3].Value = model.F_State; parameters[4].Value = model.LogDate; parameters[5].Value = model.LogUser; parameters[6].Value = model.CareUser; parameters[7].Value = model.UseDate; parameters[8].Value = model.ScrapDate; parameters[9].Value = model.FAY_ID; parameters[10].Value = model.Remark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 获取一个 治具 从当前空间中 /// </summary> /// <returns></returns> private Maticsoft.Model.FixtureList Get_Fixture() { Maticsoft.Model.FixtureList _temFix = new Maticsoft.Model.FixtureList(); _temFix.BarCode = txb_Barcode.Text.Trim(); _temFix.Fixture_Name = txb_AssetName.Text.Trim(); _temFix.FAY_ID = txb_AssetNumber.Text.Trim(); _temFix.InstallLocation = cmb_Install.Text.Trim(); _temFix.LogDate = dpk_LogDate.SelectedDate; _temFix.LogUser = txb_JobNum.Text.Trim(); _temFix.F_State = cmb_State.Text.Trim(); _temFix.UseDate = dpk_StateDate.SelectedDate; _temFix.ScrapDate = dpk_EndDate.SelectedDate; _temFix.CareUser = txb_userName.Text.Trim(); return(_temFix); }
private void ShowInfo(decimal ID) { Maticsoft.BLL.FixtureList bll = new Maticsoft.BLL.FixtureList(); Maticsoft.Model.FixtureList model = bll.GetModel(ID); this.lblID.Text = model.ID.ToString(); this.txtBarCode.Text = model.BarCode; this.txtFixture_Name.Text = model.Fixture_Name; this.txtInstallLocation.Text = model.InstallLocation; this.txtF_State.Text = model.F_State; this.txtLogDate.Text = model.LogDate.ToString(); this.txtLogUser.Text = model.LogUser; this.txtCareUser.Text = model.CareUser; this.txtUseDate.Text = model.UseDate.ToString(); this.txtScrapDate.Text = model.ScrapDate.ToString(); this.txtFAY_ID.Text = model.FAY_ID; this.txtRemark.Text = model.Remark; }
/// <summary> /// 获取一个 治具 用于更新 /// </summary> /// <returns></returns> private Maticsoft.Model.FixtureList Get_Fixture(Maticsoft.Model.FixtureList _temFix) { try { _temFix.BarCode = txb_Barcode.Text.Trim(); _temFix.Fixture_Name = txb_AssetName.Text.Trim(); _temFix.FAY_ID = txb_AssetNumber.Text.Trim(); _temFix.InstallLocation = cmb_Install.Text.Trim(); _temFix.LogDate = dpk_LogDate.SelectedDate; _temFix.LogUser = txb_JobNum.Text.Trim(); _temFix.F_State = cmb_State.Text.Trim(); _temFix.UseDate = dpk_StateDate.SelectedDate; _temFix.ScrapDate = dpk_EndDate.SelectedDate; _temFix.CareUser = txb_userName.Text.Trim(); } catch (SyntaxErrorException ex) { My_MessageBox.My_MessageBox_Message(ex.Message); } return(_temFix); }
/// <summary> /// 设置控件的内容 /// </summary> /// <param name="_temFix"></param> private void SetControlValue(Maticsoft.Model.FixtureList _temFix) { if (_temFix != null) { txb_Barcode.Text = _temFix.BarCode; txb_AssetName.Text = _temFix.Fixture_Name; txb_AssetNumber.Text = _temFix.FAY_ID; cmb_Install.Text = _temFix.InstallLocation; dpk_LogDate.SelectedDate = _temFix.LogDate; txb_JobNum.Text = _temFix.LogUser; cmb_State.Text = _temFix.F_State; dpk_StateDate.SelectedDate = _temFix.UseDate; dpk_EndDate.SelectedDate = _temFix.ScrapDate; if (_temFix.FAY_ID != "") { txb_AssetName.Text = MCP_CS.FixtureInfo.GetModel(_temFix.FAY_ID).Assembly_Name; } if (_temFix.LogUser != "") { txb_userName.Text = MCP_CS._M_User.Get_UserName(_temFix.LogUser); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.FixtureList GetModel(decimal ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,BarCode,Fixture_Name,InstallLocation,F_State,LogDate,LogUser,CareUser,UseDate,ScrapDate,FAY_ID,Remark from tb_FixtureList "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Decimal) }; parameters[0].Value = ID; Maticsoft.Model.FixtureList model = new Maticsoft.Model.FixtureList(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtBarCode.Text.Trim().Length == 0) { strErr += "BarCode不能为空!\\n"; } if (this.txtFixture_Name.Text.Trim().Length == 0) { strErr += "Fixture_Name不能为空!\\n"; } if (this.txtInstallLocation.Text.Trim().Length == 0) { strErr += "InstallLocation不能为空!\\n"; } if (this.txtF_State.Text.Trim().Length == 0) { strErr += "F_State不能为空!\\n"; } if (!PageValidate.IsDateTime(txtLogDate.Text)) { strErr += "LogDate格式错误!\\n"; } if (this.txtLogUser.Text.Trim().Length == 0) { strErr += "LogUser不能为空!\\n"; } if (this.txtCareUser.Text.Trim().Length == 0) { strErr += "CareUser不能为空!\\n"; } if (!PageValidate.IsDateTime(txtUseDate.Text)) { strErr += "UseDate格式错误!\\n"; } if (!PageValidate.IsDateTime(txtScrapDate.Text)) { strErr += "ScrapDate格式错误!\\n"; } if (this.txtFAY_ID.Text.Trim().Length == 0) { strErr += "FAY_ID不能为空!\\n"; } if (this.txtRemark.Text.Trim().Length == 0) { strErr += "Remark不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } decimal ID = decimal.Parse(this.lblID.Text); string BarCode = this.txtBarCode.Text; string Fixture_Name = this.txtFixture_Name.Text; string InstallLocation = this.txtInstallLocation.Text; string F_State = this.txtF_State.Text; DateTime LogDate = DateTime.Parse(this.txtLogDate.Text); string LogUser = this.txtLogUser.Text; string CareUser = this.txtCareUser.Text; DateTime UseDate = DateTime.Parse(this.txtUseDate.Text); DateTime ScrapDate = DateTime.Parse(this.txtScrapDate.Text); string FAY_ID = this.txtFAY_ID.Text; string Remark = this.txtRemark.Text; Maticsoft.Model.FixtureList model = new Maticsoft.Model.FixtureList(); model.ID = ID; model.BarCode = BarCode; model.Fixture_Name = Fixture_Name; model.InstallLocation = InstallLocation; model.F_State = F_State; model.LogDate = LogDate; model.LogUser = LogUser; model.CareUser = CareUser; model.UseDate = UseDate; model.ScrapDate = ScrapDate; model.FAY_ID = FAY_ID; model.Remark = Remark; Maticsoft.BLL.FixtureList bll = new Maticsoft.BLL.FixtureList(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }