/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.AR_Announcement DataRowToModel(DataRow row) { Maticsoft.Model.AR_Announcement model=new Maticsoft.Model.AR_Announcement(); if (row != null) { if(row["AnnouncementID"]!=null && row["AnnouncementID"].ToString()!="") { model.AnnouncementID=int.Parse(row["AnnouncementID"].ToString()); } if(row["A_Title"]!=null) { model.A_Title=row["A_Title"].ToString(); } if(row["A_Content"]!=null) { model.A_Content=row["A_Content"].ToString(); } if(row["A_DateTime"]!=null && row["A_DateTime"].ToString()!="") { model.A_DateTime=DateTime.Parse(row["A_DateTime"].ToString()); } if(row["A_ResponsibilityUserID"]!=null && row["A_ResponsibilityUserID"].ToString()!="") { model.A_ResponsibilityUserID=int.Parse(row["A_ResponsibilityUserID"].ToString()); } if(row["A_Type"]!=null && row["A_Type"].ToString()!="") { model.A_Type=int.Parse(row["A_Type"].ToString()); } } return model; }
/// <summary> /// 点击确定按钮执行的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Maticsoft.BLL.AR_Announcement AR_Announcement_bll = new Maticsoft.BLL.AR_Announcement(); Maticsoft.Model.AR_Announcement AR_Announcement_model = AR_Announcement_bll.GetModel(AnnouncementID); if (AR_Announcement_model == null) { AR_Announcement_model = new Maticsoft.Model.AR_Announcement(); } AR_Announcement_model.A_Type = Convert.ToInt32(A_Type.SelectedValue); AR_Announcement_model.A_Title = A_Title.Text; AR_Announcement_model.A_Content = A_Content.Text; AR_Announcement_model.A_DateTime = DateTime.Now; AR_Announcement_model.A_ResponsibilityUserID = UserData.GetUserDate.UserID; //获取当前用户ID AR_Announcement_model.A_GroupID = UserData.GetUserDate.U_GroupID; switch (CMD) { case "New": CMD_Txt = "增加"; //如果是增加操作,就调用Add方法 AR_Announcement_model.AnnouncementID = AR_Announcement_bll.Add(AR_Announcement_model); break; case "Edit": CMD_Txt = "修改"; //如果是修改操作,就调用Update方法 AR_Announcement_bll.Update(AR_Announcement_model); break; } All_Title_Txt = CMD_Txt + App_Txt; //以下方法的第4个参数需要更改 EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", AR_Announcement_model.AnnouncementID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("default.aspx")); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.AR_Announcement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AR_Announcement("); strSql.Append("A_Title,A_Content,A_DateTime,A_ResponsibilityUserID,A_Type)"); strSql.Append(" values ("); strSql.Append("@A_Title,@A_Content,@A_DateTime,@A_ResponsibilityUserID,@A_Type)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@A_Title", SqlDbType.NVarChar, 255), new SqlParameter("@A_Content", SqlDbType.Text), new SqlParameter("@A_DateTime", SqlDbType.DateTime), new SqlParameter("@A_ResponsibilityUserID", SqlDbType.Int, 4), new SqlParameter("@A_Type", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.A_Title; parameters[1].Value = model.A_Content; parameters[2].Value = model.A_DateTime; parameters[3].Value = model.A_ResponsibilityUserID; parameters[4].Value = model.A_Type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.AR_Announcement DataRowToModel(DataRow row) { Maticsoft.Model.AR_Announcement model = new Maticsoft.Model.AR_Announcement(); if (row != null) { if (row["AnnouncementID"] != null && row["AnnouncementID"].ToString() != "") { model.AnnouncementID = int.Parse(row["AnnouncementID"].ToString()); } if (row["A_Title"] != null) { model.A_Title = row["A_Title"].ToString(); } if (row["A_Content"] != null) { model.A_Content = row["A_Content"].ToString(); } if (row["A_DateTime"] != null && row["A_DateTime"].ToString() != "") { model.A_DateTime = DateTime.Parse(row["A_DateTime"].ToString()); } if (row["A_ResponsibilityUserID"] != null && row["A_ResponsibilityUserID"].ToString() != "") { model.A_ResponsibilityUserID = int.Parse(row["A_ResponsibilityUserID"].ToString()); } if (row["A_Type"] != null && row["A_Type"].ToString() != "") { model.A_Type = int.Parse(row["A_Type"].ToString()); } } return(model); }
private void ShowInfo(int AnnouncementID) { Maticsoft.BLL.AR_Announcement bll = new Maticsoft.BLL.AR_Announcement(); Maticsoft.Model.AR_Announcement model = bll.GetModel(AnnouncementID); this.lblAnnouncementID.Text = model.AnnouncementID.ToString(); this.lblA_Title.Text = model.A_Title; this.lblA_Content.Text = model.A_Content; this.lblA_DateTime.Text = model.A_DateTime.ToString(); this.lblA_ResponsibilityUserID.Text = model.A_ResponsibilityUserID.ToString(); this.lblA_Type.Text = model.A_Type.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtA_Title.Text.Trim().Length == 0) { strErr += "公告标题不能为空!\\n"; } if (this.txtA_Content.Text.Trim().Length == 0) { strErr += "公告内容不能为空!\\n"; } if (!PageValidate.IsDateTime(txtA_DateTime.Text)) { strErr += "公告时间格式错误!\\n"; } if (!PageValidate.IsNumber(txtA_ResponsibilityUserID.Text)) { strErr += "责任人格式错误!\\n"; } if (!PageValidate.IsNumber(txtA_Type.Text)) { strErr += "公告类型格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int AnnouncementID = int.Parse(this.lblAnnouncementID.Text); string A_Title = this.txtA_Title.Text; string A_Content = this.txtA_Content.Text; DateTime A_DateTime = DateTime.Parse(this.txtA_DateTime.Text); int A_ResponsibilityUserID = int.Parse(this.txtA_ResponsibilityUserID.Text); int A_Type = int.Parse(this.txtA_Type.Text); Maticsoft.Model.AR_Announcement model = new Maticsoft.Model.AR_Announcement(); model.AnnouncementID = AnnouncementID; model.A_Title = A_Title; model.A_Content = A_Content; model.A_DateTime = A_DateTime; model.A_ResponsibilityUserID = A_ResponsibilityUserID; model.A_Type = A_Type; Maticsoft.BLL.AR_Announcement bll = new Maticsoft.BLL.AR_Announcement(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtA_Title.Text.Trim().Length==0) { strErr+="公告标题不能为空!\\n"; } if(this.txtA_Content.Text.Trim().Length==0) { strErr+="公告内容不能为空!\\n"; } if(!PageValidate.IsDateTime(txtA_DateTime.Text)) { strErr+="公告时间格式错误!\\n"; } if(!PageValidate.IsNumber(txtA_ResponsibilityUserID.Text)) { strErr+="责任人格式错误!\\n"; } if(!PageValidate.IsNumber(txtA_Type.Text)) { strErr+="公告类型格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int AnnouncementID=int.Parse(this.lblAnnouncementID.Text); string A_Title=this.txtA_Title.Text; string A_Content=this.txtA_Content.Text; DateTime A_DateTime=DateTime.Parse(this.txtA_DateTime.Text); int A_ResponsibilityUserID=int.Parse(this.txtA_ResponsibilityUserID.Text); int A_Type=int.Parse(this.txtA_Type.Text); Maticsoft.Model.AR_Announcement model=new Maticsoft.Model.AR_Announcement(); model.AnnouncementID=AnnouncementID; model.A_Title=A_Title; model.A_Content=A_Content; model.A_DateTime=A_DateTime; model.A_ResponsibilityUserID=A_ResponsibilityUserID; model.A_Type=A_Type; Maticsoft.BLL.AR_Announcement bll=new Maticsoft.BLL.AR_Announcement(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.AR_Announcement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AR_Announcement set "); strSql.Append("A_Title=@A_Title,"); strSql.Append("A_Content=@A_Content,"); strSql.Append("A_DateTime=@A_DateTime,"); strSql.Append("A_ResponsibilityUserID=@A_ResponsibilityUserID,"); strSql.Append("A_Type=@A_Type"); strSql.Append(" where AnnouncementID=@AnnouncementID"); SqlParameter[] parameters = { new SqlParameter("@A_Title", SqlDbType.NVarChar, 255), new SqlParameter("@A_Content", SqlDbType.Text), new SqlParameter("@A_DateTime", SqlDbType.DateTime), new SqlParameter("@A_ResponsibilityUserID", SqlDbType.Int, 4), new SqlParameter("@A_Type", SqlDbType.TinyInt, 1), new SqlParameter("@AnnouncementID", SqlDbType.Int, 4) }; parameters[0].Value = model.A_Title; parameters[1].Value = model.A_Content; parameters[2].Value = model.A_DateTime; parameters[3].Value = model.A_ResponsibilityUserID; parameters[4].Value = model.A_Type; parameters[5].Value = model.AnnouncementID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.AR_Announcement GetModel(int AnnouncementID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 AnnouncementID,A_Title,A_Content,A_DateTime,A_ResponsibilityUserID,A_Type from AR_Announcement "); strSql.Append(" where AnnouncementID=@AnnouncementID"); SqlParameter[] parameters = { new SqlParameter("@AnnouncementID", SqlDbType.Int, 4) }; parameters[0].Value = AnnouncementID; Maticsoft.Model.AR_Announcement model = new Maticsoft.Model.AR_Announcement(); 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.AR_Announcement GetModel(int AnnouncementID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 AnnouncementID,A_Title,A_Content,A_DateTime,A_ResponsibilityUserID,A_Type,A_GroupID from AR_Announcement "); strSql.Append(" where AnnouncementID=@AnnouncementID"); SqlParameter[] parameters = { new SqlParameter("@AnnouncementID", SqlDbType.Int,4) }; parameters[0].Value = AnnouncementID; Maticsoft.Model.AR_Announcement model=new Maticsoft.Model.AR_Announcement(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }