public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtI_Location.Text.Trim().Length==0) { strErr+="I_Location不能为空!\\n"; } if(!PageValidate.IsNumber(txtI_Type.Text)) { strErr+="I_Type格式错误!\\n"; } if(!PageValidate.IsDateTime(txtI_Date.Text)) { strErr+="巡查时间格式错误!\\n"; } if(!PageValidate.IsNumber(txtI_UserID.Text)) { strErr+="巡查人格式错误!\\n"; } if(this.txtI_Conent.Text.Trim().Length==0) { strErr+="寻常内容不能为空!\\n"; } if(this.txtI_MainProblem.Text.Trim().Length==0) { strErr+="发现的主要问题不能为空!\\n"; } if(this.txtI_Note.Text.Trim().Length==0) { strErr+="备注不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int InspectID=int.Parse(this.lblInspectID.Text); string I_Location=this.txtI_Location.Text; int I_Type=int.Parse(this.txtI_Type.Text); DateTime I_Date=DateTime.Parse(this.txtI_Date.Text); int I_UserID=int.Parse(this.txtI_UserID.Text); string I_Conent=this.txtI_Conent.Text; string I_MainProblem=this.txtI_MainProblem.Text; string I_Note=this.txtI_Note.Text; Maticsoft.Model.supervision_Inspect model=new Maticsoft.Model.supervision_Inspect(); model.InspectID=InspectID; model.I_Location=I_Location; model.I_Type=I_Type; model.I_Date=I_Date; model.I_UserID=I_UserID; model.I_Conent=I_Conent; model.I_MainProblem=I_MainProblem; model.I_Note=I_Note; Maticsoft.BLL.supervision_Inspect bll=new Maticsoft.BLL.supervision_Inspect(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtI_Location.Text.Trim().Length == 0) { strErr += "I_Location不能为空!\\n"; } if (!PageValidate.IsNumber(txtI_Type.Text)) { strErr += "I_Type格式错误!\\n"; } if (!PageValidate.IsDateTime(txtI_Date.Text)) { strErr += "巡查时间格式错误!\\n"; } if (!PageValidate.IsNumber(txtI_UserID.Text)) { strErr += "巡查人格式错误!\\n"; } if (this.txtI_Conent.Text.Trim().Length == 0) { strErr += "寻常内容不能为空!\\n"; } if (this.txtI_MainProblem.Text.Trim().Length == 0) { strErr += "发现的主要问题不能为空!\\n"; } if (this.txtI_Note.Text.Trim().Length == 0) { strErr += "备注不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string I_Location = this.txtI_Location.Text; int I_Type = int.Parse(this.txtI_Type.Text); DateTime I_Date = DateTime.Parse(this.txtI_Date.Text); int I_UserID = int.Parse(this.txtI_UserID.Text); string I_Conent = this.txtI_Conent.Text; string I_MainProblem = this.txtI_MainProblem.Text; string I_Note = this.txtI_Note.Text; Maticsoft.Model.supervision_Inspect model = new Maticsoft.Model.supervision_Inspect(); model.I_Location = I_Location; model.I_Type = I_Type; model.I_Date = I_Date; model.I_UserID = I_UserID; model.I_Conent = I_Conent; model.I_MainProblem = I_MainProblem; model.I_Note = I_Note; Maticsoft.BLL.supervision_Inspect bll = new Maticsoft.BLL.supervision_Inspect(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(int InspectID) { Maticsoft.BLL.supervision_Inspect bll = new Maticsoft.BLL.supervision_Inspect(); Maticsoft.Model.supervision_Inspect model = bll.GetModel(InspectID); this.lblInspectID.Text = model.InspectID.ToString(); this.txtI_Location.Text = model.I_Location; this.txtI_Type.Text = model.I_Type.ToString(); this.txtI_Date.Text = model.I_Date.ToString(); this.txtI_UserID.Text = model.I_UserID.ToString(); this.txtI_Conent.Text = model.I_Conent; this.txtI_MainProblem.Text = model.I_MainProblem; this.txtI_Note.Text = model.I_Note; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.supervision_Inspect model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update supervision_Inspect set "); strSql.Append("I_Location=@I_Location,"); strSql.Append("I_Type=@I_Type,"); strSql.Append("I_Date=@I_Date,"); strSql.Append("I_UserID=@I_UserID,"); strSql.Append("I_Conent=@I_Conent,"); strSql.Append("I_MainProblem=@I_MainProblem,"); strSql.Append("I_Note=@I_Note"); strSql.Append(" where InspectID=@InspectID"); SqlParameter[] parameters = { new SqlParameter("@I_Location", SqlDbType.NVarChar, 100), new SqlParameter("@I_Type", SqlDbType.TinyInt, 1), new SqlParameter("@I_Date", SqlDbType.DateTime), new SqlParameter("@I_UserID", SqlDbType.Int, 4), new SqlParameter("@I_Conent", SqlDbType.Text), new SqlParameter("@I_MainProblem", SqlDbType.Text), new SqlParameter("@I_Note", SqlDbType.Text), new SqlParameter("@InspectID", SqlDbType.Int, 4) }; parameters[0].Value = model.I_Location; parameters[1].Value = model.I_Type; parameters[2].Value = model.I_Date; parameters[3].Value = model.I_UserID; parameters[4].Value = model.I_Conent; parameters[5].Value = model.I_MainProblem; parameters[6].Value = model.I_Note; parameters[7].Value = model.InspectID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 点击确定按钮执行的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Maticsoft.BLL.supervision_Inspect supervision_bll = new Maticsoft.BLL.supervision_Inspect(); Maticsoft.Model.supervision_Inspect supervision_Inspect_model = supervision_bll.GetModel(InspectID); if (supervision_Inspect_model == null) { supervision_Inspect_model = new Maticsoft.Model.supervision_Inspect(); } //获取客户端通过Post方式传递过来的值的 supervision_Inspect_model.I_Date = (DateTime)Common.sink(this.I_Date.UniqueID, MethodType.Post, 255, 0, DataType.Dat); supervision_Inspect_model.I_Type = Convert.ToInt32(this.I_Type.SelectedValue); supervision_Inspect_model.I_Content = (string)Common.sink(this.I_Content.UniqueID, MethodType.Post, 0, 0, DataType.Str); supervision_Inspect_model.I_Location = (string)Common.sink(this.I_Location.UniqueID, MethodType.Post, 0, 0, DataType.Str); supervision_Inspect_model.I_MainProblem = (string)Common.sink(this.I_MainProblem.UniqueID, MethodType.Post, 0, 0, DataType.Str); supervision_Inspect_model.I_UserID = Convert.ToInt32(this.I_UserID.Value); switch (CMD) { case "New": CMD_Txt = "增加"; supervision_Inspect_model.I_InfoID = InfoID; //如果是增加操作,就调用Add方法 supervision_Inspect_model.InspectID = supervision_bll.Add(supervision_Inspect_model); if (supervision_Inspect_model.InspectID > 0) { Maticsoft.BLL.supervision_Info supervision_Info_bll = new Maticsoft.BLL.supervision_Info(); Maticsoft.Model.supervision_Info supervision_Info_model = supervision_Info_bll.GetModel(InfoID); supervision_Info_model.I_Status = 2; supervision_Info_bll.Update(supervision_Info_model); } break; case "Edit": CMD_Txt = "修改"; //如果是修改操作,就调用Update方法 supervision_bll.Update(supervision_Inspect_model); break; } All_Title_Txt = CMD_Txt + App_Txt; EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", supervision_Inspect_model.InspectID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("default.aspx")); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.supervision_Inspect DataRowToModel(DataRow row) { Maticsoft.Model.supervision_Inspect model = new Maticsoft.Model.supervision_Inspect(); if (row != null) { if (row["InspectID"] != null && row["InspectID"].ToString() != "") { model.InspectID = int.Parse(row["InspectID"].ToString()); } if (row["I_Location"] != null) { model.I_Location = row["I_Location"].ToString(); } if (row["I_Type"] != null && row["I_Type"].ToString() != "") { model.I_Type = int.Parse(row["I_Type"].ToString()); } if (row["I_Date"] != null && row["I_Date"].ToString() != "") { model.I_Date = DateTime.Parse(row["I_Date"].ToString()); } if (row["I_UserID"] != null && row["I_UserID"].ToString() != "") { model.I_UserID = int.Parse(row["I_UserID"].ToString()); } if (row["I_Conent"] != null) { model.I_Conent = row["I_Conent"].ToString(); } if (row["I_MainProblem"] != null) { model.I_MainProblem = row["I_MainProblem"].ToString(); } if (row["I_Note"] != null) { model.I_Note = row["I_Note"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.supervision_Inspect DataRowToModel(DataRow row) { Maticsoft.Model.supervision_Inspect model=new Maticsoft.Model.supervision_Inspect(); if (row != null) { if(row["InspectID"]!=null && row["InspectID"].ToString()!="") { model.InspectID=int.Parse(row["InspectID"].ToString()); } if(row["I_Location"]!=null) { model.I_Location=row["I_Location"].ToString(); } if(row["I_Type"]!=null && row["I_Type"].ToString()!="") { model.I_Type=int.Parse(row["I_Type"].ToString()); } if(row["I_Date"]!=null && row["I_Date"].ToString()!="") { model.I_Date=DateTime.Parse(row["I_Date"].ToString()); } if(row["I_UserID"]!=null && row["I_UserID"].ToString()!="") { model.I_UserID=int.Parse(row["I_UserID"].ToString()); } if(row["I_Conent"]!=null) { model.I_Conent=row["I_Conent"].ToString(); } if(row["I_MainProblem"]!=null) { model.I_MainProblem=row["I_MainProblem"].ToString(); } if(row["I_Note"]!=null) { model.I_Note=row["I_Note"].ToString(); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.supervision_Inspect model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into supervision_Inspect("); strSql.Append("I_Location,I_Type,I_Date,I_UserID,I_Conent,I_MainProblem,I_Note)"); strSql.Append(" values ("); strSql.Append("@I_Location,@I_Type,@I_Date,@I_UserID,@I_Conent,@I_MainProblem,@I_Note)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@I_Location", SqlDbType.NVarChar, 100), new SqlParameter("@I_Type", SqlDbType.TinyInt, 1), new SqlParameter("@I_Date", SqlDbType.DateTime), new SqlParameter("@I_UserID", SqlDbType.Int, 4), new SqlParameter("@I_Conent", SqlDbType.Text), new SqlParameter("@I_MainProblem", SqlDbType.Text), new SqlParameter("@I_Note", SqlDbType.Text) }; parameters[0].Value = model.I_Location; parameters[1].Value = model.I_Type; parameters[2].Value = model.I_Date; parameters[3].Value = model.I_UserID; parameters[4].Value = model.I_Conent; parameters[5].Value = model.I_MainProblem; parameters[6].Value = model.I_Note; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.supervision_Inspect GetModel(int InspectID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 InspectID,I_Location,I_Type,I_Date,I_UserID,I_Conent,I_MainProblem,I_Note from supervision_Inspect "); strSql.Append(" where InspectID=@InspectID"); SqlParameter[] parameters = { new SqlParameter("@InspectID", SqlDbType.Int, 4) }; parameters[0].Value = InspectID; Maticsoft.Model.supervision_Inspect model = new Maticsoft.Model.supervision_Inspect(); DataSet ds = DbHelperSQL.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.supervision_Inspect GetModel(int InspectID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 InspectID,I_Location,I_Type,I_Date,I_UserID,I_Conent,I_MainProblem,I_Note from supervision_Inspect "); strSql.Append(" where InspectID=@InspectID"); SqlParameter[] parameters = { new SqlParameter("@InspectID", SqlDbType.Int,4) }; parameters[0].Value = InspectID; Maticsoft.Model.supervision_Inspect model=new Maticsoft.Model.supervision_Inspect(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }