protected void Unnamed1_Click(object sender, EventArgs e) { QA_CategoryMod m_cate = new QA_CategoryMod(); if (type == "EDIT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { SysNo = int.Parse(Request.QueryString["id"]); } m_cate = QA_CategoryBll.GetInstance().GetModel(SysNo); try { m_cate.Name = txtName.Text.Trim(); m_cate.DR = int.Parse(drpStatus.SelectedValue); QA_CategoryBll.GetInstance().Update(m_cate); LogManagement.getInstance().WriteTrace(m_cate.SysNo, "CMS.Category.Update", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); ltrNotice.Text = "该记录已保存成功!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch { ltrError.Text = "输入资料格式有误,请检查!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } } else if (type == "ADD") { try { m_cate.Name = txtName.Text.Trim(); m_cate.DR = int.Parse(drpStatus.SelectedValue); m_cate.TS = DateTime.Now; m_cate.ParentSysNo = Convert.ToInt32(ViewState["parent"]); m_cate.TopSysNo = QA_CategoryBll.GetInstance().GetModel(Convert.ToInt32(ViewState["parent"])).TopSysNo; QA_CategoryBll.GetInstance().Add(m_cate); LogManagement.getInstance().WriteTrace(m_cate.SysNo, "CMS.Category.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); ltrNotice.Text = "该记录已保存成功!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch { ltrError.Text = "输入资料格式有误,请检查!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } } }
/// <summary> /// 得到一个对象实体 /// </summary> public QA_CategoryMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Name, ParentSysNo, TopSysNo, DR, TS, Pic, Intro, OrderID from QA_Category"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int, 4) }; parameters[0].Value = SysNo; QA_CategoryMod model = new QA_CategoryMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["ParentSysNo"].ToString() != "") { model.ParentSysNo = int.Parse(ds.Tables[0].Rows[0]["ParentSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["TopSysNo"].ToString() != "") { model.TopSysNo = int.Parse(ds.Tables[0].Rows[0]["TopSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["DR"].ToString() != "") { model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString()); } if (ds.Tables[0].Rows[0]["TS"].ToString() != "") { model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString()); } model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); model.Intro = ds.Tables[0].Rows[0]["Intro"].ToString(); if (ds.Tables[0].Rows[0]["OrderID"].ToString() != "") { model.OrderID = int.Parse(ds.Tables[0].Rows[0]["OrderID"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(QA_CategoryMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into QA_Category("); strSql.Append("Name,ParentSysNo,TopSysNo,DR,TS,Pic,Intro,OrderID)"); strSql.Append(" values ("); strSql.Append("@Name,@ParentSysNo,@TopSysNo,@DR,@TS,@Pic,@Intro,@OrderID)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Name",SqlDbType.NVarChar,200), new SqlParameter("@ParentSysNo",SqlDbType.Int,4), new SqlParameter("@TopSysNo",SqlDbType.Int,4), new SqlParameter("@DR",SqlDbType.TinyInt,1), new SqlParameter("@TS",SqlDbType.DateTime), new SqlParameter("@Pic",SqlDbType.NVarChar,500), new SqlParameter("@Intro",SqlDbType.NVarChar,1000), new SqlParameter("@OrderID",SqlDbType.Int,4), }; if (model.Name != AppConst.StringNull) parameters[0].Value = model.Name; else parameters[0].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[0]); if (model.ParentSysNo != AppConst.IntNull) parameters[1].Value = model.ParentSysNo; else parameters[1].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[1]); if (model.TopSysNo != AppConst.IntNull) parameters[2].Value = model.TopSysNo; else parameters[2].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[2]); if (model.DR != AppConst.IntNull) parameters[3].Value = model.DR; else parameters[3].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[3]); if (model.TS != AppConst.DateTimeNull) parameters[4].Value = model.TS; else parameters[4].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[4]); if (model.Pic != AppConst.StringNull) parameters[5].Value = model.Pic; else parameters[5].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[5]); if (model.Intro != AppConst.StringNull) parameters[6].Value = model.Intro; else parameters[6].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[6]); if (model.OrderID != AppConst.IntNull) parameters[7].Value = model.OrderID; else parameters[7].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[7]); return SqlHelper.ExecuteNonQuery(cmd,parameters); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(QA_CategoryMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update QA_Category set "); strSql.Append("Name=@Name,"); strSql.Append("ParentSysNo=@ParentSysNo,"); strSql.Append("TopSysNo=@TopSysNo,"); strSql.Append("DR=@DR,"); strSql.Append("TS=@TS"); strSql.Append("Pic=@Pic"); strSql.Append("Intro=@Intro"); strSql.Append("OrderID=@OrderID"); strSql.Append(" where SysNo=@SysNo "); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@SysNo",SqlDbType.Int,4), new SqlParameter("@Name",SqlDbType.NVarChar,200), new SqlParameter("@ParentSysNo",SqlDbType.Int,4), new SqlParameter("@TopSysNo",SqlDbType.Int,4), new SqlParameter("@DR",SqlDbType.TinyInt,1), new SqlParameter("@TS",SqlDbType.DateTime), new SqlParameter("@Pic",SqlDbType.NVarChar,500), new SqlParameter("@Intro",SqlDbType.NVarChar,1000), new SqlParameter("@OrderID",SqlDbType.Int,4), }; if (model.SysNo != AppConst.IntNull) parameters[0].Value = model.SysNo; else parameters[0].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[0]); if (model.Name != AppConst.StringNull) parameters[1].Value = model.Name; else parameters[1].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[1]); if (model.ParentSysNo != AppConst.IntNull) parameters[2].Value = model.ParentSysNo; else parameters[2].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[2]); if (model.TopSysNo != AppConst.IntNull) parameters[3].Value = model.TopSysNo; else parameters[3].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[3]); if (model.DR != AppConst.IntNull) parameters[4].Value = model.DR; else parameters[4].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[4]); if (model.TS != AppConst.DateTimeNull) parameters[5].Value = model.TS; else parameters[5].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[5]); if (model.Pic != AppConst.StringNull) parameters[6].Value = model.Pic; else parameters[6].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[6]); if (model.Intro != AppConst.StringNull) parameters[7].Value = model.Intro; else parameters[7].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[7]); if (model.OrderID != AppConst.IntNull) parameters[8].Value = model.OrderID; else parameters[8].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[8]); return SqlHelper.ExecuteNonQuery(cmd, parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public QA_CategoryMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Name, ParentSysNo, TopSysNo, DR, TS, Pic, Intro, OrderID from QA_Category"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int,4 ) }; parameters[0].Value = SysNo; QA_CategoryMod model = new QA_CategoryMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["ParentSysNo"].ToString() != "") { model.ParentSysNo = int.Parse(ds.Tables[0].Rows[0]["ParentSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["TopSysNo"].ToString() != "") { model.TopSysNo = int.Parse(ds.Tables[0].Rows[0]["TopSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["DR"].ToString() != "") { model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString()); } if (ds.Tables[0].Rows[0]["TS"].ToString() != "") { model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString()); } model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); model.Intro = ds.Tables[0].Rows[0]["Intro"].ToString(); if (ds.Tables[0].Rows[0]["OrderID"].ToString() != "") { model.OrderID = int.Parse(ds.Tables[0].Rows[0]["OrderID"].ToString()); } return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(QA_CategoryMod model) { return dal.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(QA_CategoryMod model) { dal.Update(model); }
protected void BindData() { int total = 0; int cate = 0; if (Request.QueryString["cate"] != null) { try { cate = int.Parse(Request.QueryString["cate"]); } catch { ShowError("请从正常入口进入"); } } else if (Page.RouteData.Values["cate"] != null && Page.RouteData.Values["cate"].ToString() != "") { try { cate = int.Parse(Page.RouteData.Values["cate"].ToString()); } catch { ShowError("请从正常入口进入"); } } else { ShowError("请从正常入口进入"); } QA_CategoryMod m_cate = QA_CategoryBll.GetInstance().GetModel(cate); ltrNav.Text = @"<a href=""" + AppConfig.HomeUrl() + @""">首页</a> > <a href=""" + AppConfig.HomeUrl() + @"Quest/"">煮酒论命</a> > <span>" + m_cate.Name + "</span>"; string search = ""; //if (txtName.Trim() != "寻找你感兴趣的咨询话题") //{ // search = txtName.Trim(); //} DataTable m_dt = QA_QuestionBll.GetInstance().GetList(pagesize, pageindex, search, cate, ViewState["order"].ToString(), ref total); m_dt.Columns.Add("DateShow"); for (int i = 0; i < m_dt.Rows.Count; i++) { //m_dt.Rows[i]["Context"] = CommonTools.CutStr(m_dt.Rows[i]["Context"].ToString(), 100); DateTime ts = DateTime.Parse(m_dt.Rows[i]["ts"].ToString()); if ((DateTime.Now - ts).TotalDays > 365) { m_dt.Rows[i]["DateShow"] = "一年前发布"; } else if ((DateTime.Now - ts).TotalDays > 180) { m_dt.Rows[i]["DateShow"] = "半年前发布"; } else if ((DateTime.Now - ts).TotalDays > 60) { m_dt.Rows[i]["DateShow"] = "几个月前发布"; } else if ((DateTime.Now - ts).TotalDays > 30) { m_dt.Rows[i]["DateShow"] = "一个月前发布"; } else if ((DateTime.Now - ts).TotalDays > 15) { m_dt.Rows[i]["DateShow"] = "半个月前发布"; } else if ((DateTime.Now - ts).TotalDays > 7) { m_dt.Rows[i]["DateShow"] = "一周前发布"; } else if ((DateTime.Now - ts).TotalDays > 2) { m_dt.Rows[i]["DateShow"] = "几天前发布"; } else if ((DateTime.Now - ts).TotalDays > 1) { m_dt.Rows[i]["DateShow"] = "一天前发布"; } else if ((DateTime.Now - ts).TotalHours > 2) { m_dt.Rows[i]["DateShow"] = "几小时前发布"; } else if ((DateTime.Now - ts).TotalHours > 1) { m_dt.Rows[i]["DateShow"] = "一小时前发布"; } else if ((DateTime.Now - ts).TotalMinutes > 30) { m_dt.Rows[i]["DateShow"] = "半小时前发布"; } else if ((DateTime.Now - ts).TotalMinutes > 2) { m_dt.Rows[i]["DateShow"] = "几分钟前发布"; } else if ((DateTime.Now - ts).TotalMinutes > 1) { m_dt.Rows[i]["DateShow"] = "一分钟前发布"; } else { m_dt.Rows[i]["DateShow"] = "几秒钟前发布"; } } rptQuestion.DataSource = m_dt; rptQuestion.DataBind(); Pager1.url = AppConfig.HomeUrl() + @"Quest/QuestList/" + cate + "/"; if (search.Trim() != "") { Pager1.url += search.Trim() + "/"; } Pager1.totalrecord = total; if (total % AppConst.PageSize == 0) { this.Pager1.total = total / pagesize; } else { this.Pager1.total = total / pagesize + 1; } this.Pager1.index = pageindex; this.Pager1.numlenth = 3; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["key"] != null) { txtName.Text = Server.HtmlEncode(Request.QueryString["key"]); } else if (Page.RouteData.Values["key"] != null && Page.RouteData.Values["key"].ToString() != "") { txtName.Text = Server.HtmlEncode(Page.RouteData.Values["key"].ToString()); } if (Request.QueryString["cate"] != null) { try { cate = int.Parse(Request.QueryString["cate"]); } catch { return; } } else if (Page.RouteData.Values["cate"] != null && Page.RouteData.Values["cate"].ToString() != "") { try { cate = int.Parse(Page.RouteData.Values["cate"].ToString()); } catch { return; } } else { return; } if (!IsPostBack) { QA_CategoryMod m_cate = QA_CategoryBll.GetInstance().GetModel(cate); if (m_cate.TopSysNo == 1) { ltrMaster.Text = "驻场命理师"; } else if (m_cate.TopSysNo == 2) { ltrMaster.Text = "版主"; } DataTable m_dt = QA_CategoryBll.GetInstance().GetCates(0).Copy(); for (int i = 0; i < m_dt.Rows.Count; i++) { if (m_dt.Rows[i]["SysNo"].ToString() != m_cate.TopSysNo.ToString()) { m_dt.Rows.RemoveAt(i); i--; } } rptCateMain.DataSource = m_dt; rptCateMain.DataBind(); BindStars(); } }
protected void PrepareForm() { if (type == "ADD") { if (Request.QueryString["parent"] == null || Request.QueryString["parent"] == "") { Response.Redirect("../Error.aspx?msg="); return; } try { ltrParent.Text = QA_CategoryBll.GetInstance().GetModel(int.Parse(Request.QueryString["parent"])).Name; } catch { Response.Redirect("../Error.aspx?msg="); return; } ViewState["parent"] = Request.QueryString["parent"]; fieldset1.Style["display"] = ""; fieldset2.Style["display"] = ""; } else if (type == "EDIT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { try { SysNo = int.Parse(Request.QueryString["id"]); QA_CategoryMod m_cate = QA_CategoryBll.GetInstance().GetModel(SysNo); txtName.Text = m_cate.Name; drpStatus.SelectedIndex = drpStatus.Items.IndexOf(drpStatus.Items.FindByValue(m_cate.DR.ToString())); DataTable m_child = QA_CategoryBll.GetInstance().GetCates(SysNo); rptFamous.DataSource = m_child; rptFamous.DataBind(); if (m_cate.ParentSysNo != 0) { QA_CategoryMod m_parent = QA_CategoryBll.GetInstance().GetModel(m_cate.ParentSysNo); ltrParent.Text = m_parent.Name + "—" + m_cate.Name; } else { ltrParent.Text = "此分类为一级分类"; } fieldset1.Style["display"] = ""; fieldset2.Style["display"] = ""; } catch { Response.Redirect("../Error.aspx?msg="); return; } } } else if (type == "TOP") { DataTable m_child = QA_CategoryBll.GetInstance().GetCates(0); rptFamous.DataSource = m_child; rptFamous.DataBind(); fieldset1.Style["display"] = "none"; fieldset2.Style["display"] = "none"; } }
protected void Unnamed1_Click(object sender, EventArgs e) { QA_CategoryMod m_cate = new QA_CategoryMod(); if (type == "EDIT") { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { SysNo = int.Parse(Request.QueryString["id"]); } m_cate = QA_CategoryBll.GetInstance().GetModel(SysNo); try { m_cate.Name = txtName.Text.Trim(); m_cate.DR = int.Parse(drpStatus.SelectedValue); QA_CategoryBll.GetInstance().Update(m_cate); LogManagement.getInstance().WriteTrace(m_cate.SysNo, "CMS.Category.Update", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); ltrNotice.Text = "该记录已保存成功!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch { ltrError.Text = "输入资料格式有误,请检查!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } } else if (type == "ADD") { try { m_cate.Name = txtName.Text.Trim(); m_cate.DR = int.Parse(drpStatus.SelectedValue); m_cate.TS = DateTime.Now; m_cate.ParentSysNo = Convert.ToInt32(ViewState["parent"]); m_cate.TopSysNo = QA_CategoryBll.GetInstance().GetModel(Convert.ToInt32(ViewState["parent"])).TopSysNo; QA_CategoryBll.GetInstance().Add(m_cate); LogManagement.getInstance().WriteTrace(m_cate.SysNo, "CMS.Category.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username); ltrNotice.Text = "该记录已保存成功!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true); } catch { ltrError.Text = "输入资料格式有误,请检查!"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(QA_CategoryMod model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(QA_CategoryMod model) { return(dal.Add(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(QA_CategoryMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into QA_Category("); strSql.Append("Name,ParentSysNo,TopSysNo,DR,TS,Pic,Intro,OrderID)"); strSql.Append(" values ("); strSql.Append("@Name,@ParentSysNo,@TopSysNo,@DR,@TS,@Pic,@Intro,@OrderID)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 200), new SqlParameter("@ParentSysNo", SqlDbType.Int, 4), new SqlParameter("@TopSysNo", SqlDbType.Int, 4), new SqlParameter("@DR", SqlDbType.TinyInt, 1), new SqlParameter("@TS", SqlDbType.DateTime), new SqlParameter("@Pic", SqlDbType.NVarChar, 500), new SqlParameter("@Intro", SqlDbType.NVarChar, 1000), new SqlParameter("@OrderID", SqlDbType.Int, 4), }; if (model.Name != AppConst.StringNull) { parameters[0].Value = model.Name; } else { parameters[0].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[0]); if (model.ParentSysNo != AppConst.IntNull) { parameters[1].Value = model.ParentSysNo; } else { parameters[1].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[1]); if (model.TopSysNo != AppConst.IntNull) { parameters[2].Value = model.TopSysNo; } else { parameters[2].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[2]); if (model.DR != AppConst.IntNull) { parameters[3].Value = model.DR; } else { parameters[3].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[3]); if (model.TS != AppConst.DateTimeNull) { parameters[4].Value = model.TS; } else { parameters[4].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[4]); if (model.Pic != AppConst.StringNull) { parameters[5].Value = model.Pic; } else { parameters[5].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[5]); if (model.Intro != AppConst.StringNull) { parameters[6].Value = model.Intro; } else { parameters[6].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[6]); if (model.OrderID != AppConst.IntNull) { parameters[7].Value = model.OrderID; } else { parameters[7].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[7]); return(SqlHelper.ExecuteNonQuery(cmd, parameters)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(QA_CategoryMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update QA_Category set "); strSql.Append("Name=@Name,"); strSql.Append("ParentSysNo=@ParentSysNo,"); strSql.Append("TopSysNo=@TopSysNo,"); strSql.Append("DR=@DR,"); strSql.Append("TS=@TS"); strSql.Append("Pic=@Pic"); strSql.Append("Intro=@Intro"); strSql.Append("OrderID=@OrderID"); strSql.Append(" where SysNo=@SysNo "); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 200), new SqlParameter("@ParentSysNo", SqlDbType.Int, 4), new SqlParameter("@TopSysNo", SqlDbType.Int, 4), new SqlParameter("@DR", SqlDbType.TinyInt, 1), new SqlParameter("@TS", SqlDbType.DateTime), new SqlParameter("@Pic", SqlDbType.NVarChar, 500), new SqlParameter("@Intro", SqlDbType.NVarChar, 1000), new SqlParameter("@OrderID", SqlDbType.Int, 4), }; if (model.SysNo != AppConst.IntNull) { parameters[0].Value = model.SysNo; } else { parameters[0].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[0]); if (model.Name != AppConst.StringNull) { parameters[1].Value = model.Name; } else { parameters[1].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[1]); if (model.ParentSysNo != AppConst.IntNull) { parameters[2].Value = model.ParentSysNo; } else { parameters[2].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[2]); if (model.TopSysNo != AppConst.IntNull) { parameters[3].Value = model.TopSysNo; } else { parameters[3].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[3]); if (model.DR != AppConst.IntNull) { parameters[4].Value = model.DR; } else { parameters[4].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[4]); if (model.TS != AppConst.DateTimeNull) { parameters[5].Value = model.TS; } else { parameters[5].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[5]); if (model.Pic != AppConst.StringNull) { parameters[6].Value = model.Pic; } else { parameters[6].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[6]); if (model.Intro != AppConst.StringNull) { parameters[7].Value = model.Intro; } else { parameters[7].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[7]); if (model.OrderID != AppConst.IntNull) { parameters[8].Value = model.OrderID; } else { parameters[8].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[8]); return(SqlHelper.ExecuteNonQuery(cmd, parameters)); }