/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Configure model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Configure set "); strSql.Append("CATEGORY=@CATEGORY,"); strSql.Append("NAME=@NAME,"); strSql.Append("VALUE=@VALUE,"); strSql.Append("UNIT=@UNIT,"); strSql.Append("UPDATED_TIME=@UPDATED_TIME,"); strSql.Append("USER_ID=@USER_ID,"); strSql.Append("USER_GROUP=@USER_GROUP,"); strSql.Append("DEFAULT_VALUE=@DEFAULT_VALUE"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@CATEGORY", SqlDbType.VarChar, 50), new SqlParameter("@NAME", SqlDbType.VarChar, 200), new SqlParameter("@VALUE", SqlDbType.VarChar, 100), new SqlParameter("@UNIT", SqlDbType.VarChar, 50), new SqlParameter("@UPDATED_TIME", SqlDbType.DateTime), new SqlParameter("@USER_ID", SqlDbType.VarChar, 50), new SqlParameter("@USER_GROUP", SqlDbType.VarChar, 50), new SqlParameter("@DEFAULT_VALUE", SqlDbType.VarChar, 100) }; parameters[0].Value = model.CATEGORY; parameters[1].Value = model.NAME; parameters[2].Value = model.VALUE; parameters[3].Value = model.UNIT; parameters[4].Value = model.UPDATED_TIME; parameters[5].Value = model.USER_ID; parameters[6].Value = model.USER_GROUP; parameters[7].Value = model.DEFAULT_VALUE; int rows = Common.DB.SqlDB.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Configure DataRowToModel(DataRow row) { Model.Configure model = new Model.Configure(); if (row != null) { if (row["CATEGORY"] != null) { model.CATEGORY = row["CATEGORY"].ToString(); } if (row["NAME"] != null) { model.NAME = row["NAME"].ToString(); } if (row["VALUE"] != null) { model.VALUE = row["VALUE"].ToString(); } if (row["UNIT"] != null) { model.UNIT = row["UNIT"].ToString(); } if (row["UPDATED_TIME"] != null && row["UPDATED_TIME"].ToString() != "") { model.UPDATED_TIME = DateTime.Parse(row["UPDATED_TIME"].ToString()); } if (row["USER_ID"] != null) { model.USER_ID = row["USER_ID"].ToString(); } if (row["USER_GROUP"] != null) { model.USER_GROUP = row["USER_GROUP"].ToString(); } if (row["DEFAULT_VALUE"] != null) { model.DEFAULT_VALUE = row["DEFAULT_VALUE"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.Configure model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Configure("); strSql.Append("CATEGORY,NAME,VALUE,UNIT,UPDATED_TIME,USER_ID,USER_GROUP,DEFAULT_VALUE)"); strSql.Append(" values ("); strSql.Append("@CATEGORY,@NAME,@VALUE,@UNIT,@UPDATED_TIME,@USER_ID,@USER_GROUP,@DEFAULT_VALUE)"); SqlParameter[] parameters = { new SqlParameter("@CATEGORY", SqlDbType.VarChar, 50), new SqlParameter("@NAME", SqlDbType.VarChar, 200), new SqlParameter("@VALUE", SqlDbType.VarChar, 100), new SqlParameter("@UNIT", SqlDbType.VarChar, 50), new SqlParameter("@UPDATED_TIME", SqlDbType.DateTime), new SqlParameter("@USER_ID", SqlDbType.VarChar, 50), new SqlParameter("@USER_GROUP", SqlDbType.VarChar, 50), new SqlParameter("@DEFAULT_VALUE", SqlDbType.VarChar, 100) }; parameters[0].Value = model.CATEGORY; parameters[1].Value = model.NAME; parameters[2].Value = model.VALUE; parameters[3].Value = model.UNIT; parameters[4].Value = model.UPDATED_TIME; parameters[5].Value = model.USER_ID; parameters[6].Value = model.USER_GROUP; parameters[7].Value = model.DEFAULT_VALUE; int rows = Common.DB.SqlDB.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public Mix() { InitializeComponent(); try { //initalize UI & Parameters runningTime = 0; onGoing = false; this.btn_startMix.IsEnabled = false; InitMaterialInfo(); //initalize mix time BLL.Configure confBLL = new BLL.Configure(); Model.Configure confModel = confBLL.GetModel("Mix_Time"); mixTime = confModel == null ? 0 : double.Parse(confModel.VALUE); //后台计时, 显示进度条 bgwMixing = new BackgroundWorker(); bgwMixing.WorkerReportsProgress = true; bgwMixing.WorkerSupportsCancellation = true; bgwMixing.DoWork += BackgroundWorker_DoWork; bgwMixing.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; bgwMixing.ProgressChanged += BgwMixing_ProgressChanged; kb.CurrentTextBox = this.txt_partID_input; } catch (Exception ex) { MessageBox.Show("Initalizing error, Exception:" + ex.ToString()); Common.Reports.LogFile.Log("[EMS.Transaction.Mix], Initalize error, exception:" + ex.ToString()); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Configure model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.Configure model) { return(dal.Add(model)); }