Пример #1
0
 /// <summary>
 /// 添加内容到数据库
 /// </summary>
 /// <param name="FieldList"></param>
 /// <param name="FieldValue"></param>
 /// <param name="CommonData"></param>
 int ID_CommonModel.AddContent(string FieldList, string FieldValue, M_CommonData CommonData)
 {
     string strSql = "Insert Into " + CommonData.TableName + " (" + FieldList + ") values(" + FieldValue + ");select @@IDENTITY AS newID";
     //SqlHelper.ExecuteSql(strSql);
     int ItemID = SqlHelper.ObjectToInt32(SqlHelper.ExecuteScalar(CommandType.Text, strSql, null));
     string strSql2 = "Insert Into ZL_CommonModel (NodeID,ModelID,ItemID,TableName,Title,Inputer,EliteLevel,InfoID,SpecialID,Template,Status) Values (" + CommonData.NodeID + "," + CommonData.ModelID + "," + ItemID + ",'" + CommonData.TableName + "','" + CommonData.Title + "','" + CommonData.Inputer + "'," + CommonData.EliteLevel + ",'" + CommonData.InfoID + "','" + CommonData.SpecialID + "','" + CommonData.Template + "'," + CommonData.Status + ")";
     SqlHelper.ExecuteSql(strSql2);
     return ItemID;
 }
Пример #2
0
 /// <summary>
 /// 添加内容到数据库  返回新内容ID
 /// </summary>
 /// <param name="ContentDT">存储内容字段及其值的数据表</param>
 /// <param name="CommonData">存储内容公共数据的表</param>
 /// <returns>新内容ID</returns>
 public int AddContent(DataTable ContentDT, M_CommonData CommonData)
 {
     string FieldList = "";
     string FieldValue = "";
     foreach (DataRow dr in ContentDT.Rows)
     {
         if (string.IsNullOrEmpty(FieldList))
         {
             FieldList = dr["FieldName"].ToString();
         }
         else
         {
             FieldList = FieldList + "," + dr["FieldName"].ToString();
         }
         if (string.IsNullOrEmpty(FieldValue))
             FieldValue = this.GetFieldValue(dr);
         else
             FieldValue = FieldValue + "," + this.GetFieldValue(dr);
     }
     return dal.AddContent(FieldList, FieldValue, CommonData);
 }
Пример #3
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                this.ModelID = DataConverter.CLng(this.HdnModel.Value);
                this.NodeID = DataConverter.CLng(this.HdnNode.Value);
                DataTable dt = this.bfield.GetModelFieldList(this.ModelID).Tables[0];

                DataTable table = new DataTable();
                table.Columns.Add(new DataColumn("FieldName", typeof(string)));
                table.Columns.Add(new DataColumn("FieldType", typeof(string)));
                table.Columns.Add(new DataColumn("FieldValue", typeof(string)));

                foreach (DataRow dr in dt.Rows)
                {
                    if (DataConverter.CBool(dr["IsNotNull"].ToString()))
                    {
                        if (string.IsNullOrEmpty(this.Page.Request.Form["txt_" + dr["FieldName"].ToString()]))
                        {
                            function.WriteErrMsg(dr["FieldAlias"].ToString() + "不能为空!");
                        }
                    }
                    if (dr["FieldType"].ToString() == "FileType")
                    {
                        string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                        bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string sizefield = Sett[1].Split(new char[] { '=' })[1];
                        if (chksize && sizefield != "")
                        {
                            DataRow row2 = table.NewRow();
                            row2[0] = sizefield;
                            row2[1] = "FileSize";
                            row2[2] = this.Page.Request.Form["txt_" + sizefield];
                            table.Rows.Add(row2);
                        }
                    }
                    if (dr["FieldType"].ToString() == "MultiPicType")
                    {
                        string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                        bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string sizefield = Sett[1].Split(new char[] { '=' })[1];
                        if (chksize && sizefield != "")
                        {
                            if (string.IsNullOrEmpty(this.Page.Request.Form["txt_" + sizefield]))
                            {
                                function.WriteErrMsg(dr["FieldAlias"].ToString() + "的缩略图不能为空!");
                            }
                            DataRow row1 = table.NewRow();
                            row1[0] = sizefield;
                            row1[1] = "ThumbField";
                            row1[2] = this.Page.Request.Form["txt_" + sizefield];
                            table.Rows.Add(row1);
                        }
                    }
                    DataRow row = table.NewRow();
                    row[0] = dr["FieldName"].ToString();
                    row[1] = dr["FieldType"].ToString();
                    row[2] = this.Page.Request.Form["txt_" + dr["FieldName"].ToString()];
                    table.Rows.Add(row);
                }

                M_CommonData CData = new M_CommonData();
                CData.NodeID = this.NodeID;
                CData.ModelID = this.ModelID;
                CData.TableName = this.bmode.GetModelById(this.ModelID).TableName;
                CData.Title = this.txtTitle.Text;
                CData.Status = 99;
                CData.Inputer = "admin";
                CData.EliteLevel = this.ChkAudit.Checked ? 1 : 0;
                CData.InfoID = "";
                CData.SpecialID = "";
                CData.Template = this.TxtTemplate.Text;
                int newID = this.bll.AddContent(table, CData);
                string specialid = this.HdnSpec.Value;
                if (!string.IsNullOrEmpty(specialid))
                {
                    string[] arr = specialid.Split(new char[] { ',' });
                    M_SpecInfo info = new M_SpecInfo();
                    info.InfoID = newID;
                    for (int i = 0; i < arr.Length; i++)
                    {
                        info.SpecialID = DataConverter.CLng(arr[i]);
                        this.bspec.Add(info);
                    }
                }
                Response.Write("<script>alert('内容添加成功!请继续添加')</script>");
                //Response.Redirect("ContentManage.aspx?NodeID="+this.NodeID);
            }
        }
Пример #4
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                this.ModelID = DataConverter.CLng(this.HdnModel.Value);
                this.NodeID = DataConverter.CLng(this.HdnNode.Value);
                DataTable dt = this.bfield.GetModelFieldList(this.ModelID).Tables[0];

                DataTable table = new DataTable();
                table.Columns.Add(new DataColumn("FieldName", typeof(string)));
                table.Columns.Add(new DataColumn("FieldType", typeof(string)));
                table.Columns.Add(new DataColumn("FieldValue", typeof(string)));

                foreach (DataRow dr in dt.Rows)
                {
                    if (DataConverter.CBool(dr["IsNotNull"].ToString()))
                    {
                        if (string.IsNullOrEmpty(this.Page.Request.Form["txt_" + dr["FieldName"].ToString()]))
                        {
                            function.WriteErrMsg(dr["FieldAlias"].ToString() + "不能为空!");
                        }
                    }
                    if (dr["FieldType"].ToString() == "FileType")
                    {
                        string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                        bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string sizefield = Sett[1].Split(new char[] { '=' })[1];
                        if (chksize && sizefield != "")
                        {
                            DataRow row2 = table.NewRow();
                            row2[0] = sizefield;
                            row2[1] = "FileSize";
                            row2[2] = this.Page.Request.Form["txt_" + sizefield];
                            table.Rows.Add(row2);
                        }
                    }
                    if (dr["FieldType"].ToString() == "MultiPicType")
                    {
                        string[] Sett = dr["Content"].ToString().Split(new char[] { ',' });
                        bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]);
                        string sizefield = Sett[1].Split(new char[] { '=' })[1];
                        if (chksize && sizefield != "")
                        {
                            if (string.IsNullOrEmpty(this.Page.Request.Form["txt_" + sizefield]))
                            {
                                function.WriteErrMsg(dr["FieldAlias"].ToString() + "的缩略图不能为空!");
                            }
                            DataRow row1 = table.NewRow();
                            row1[0] = sizefield;
                            row1[1] = "ThumbField";
                            row1[2] = this.Page.Request.Form["txt_" + sizefield];
                            table.Rows.Add(row1);
                        }
                    }
                    DataRow row = table.NewRow();
                    row[0] = dr["FieldName"].ToString();
                    row[1] = dr["FieldType"].ToString();
                    row[2] = this.Page.Request.Form["txt_" + dr["FieldName"].ToString()];
                    table.Rows.Add(row);
                }
                string uname = HttpContext.Current.Request.Cookies["UserState"]["LoginName"];
                this.UserInfo = buser.GetUserByName(uname);

                M_CommonData CData = new M_CommonData();
                CData.NodeID = this.NodeID;
                CData.ModelID = this.ModelID;
                CData.TableName = this.bmode.GetModelById(this.ModelID).TableName;
                CData.Title = this.txtTitle.Text;
                CData.Inputer = this.UserInfo.UserName;
                CData.EliteLevel = 0;
                CData.Status = 0;
                CData.InfoID = "";
                CData.SpecialID = "";
                int newID = this.bll.AddContent(table, CData);
                //添加到专题
                //string specialid = this.HdnSpec.Value;
                //if (!string.IsNullOrEmpty(specialid))
                //{
                //    string[] arr = specialid.Split(new char[] { ',' });
                //    M_SpecInfo info = new M_SpecInfo();
                //    info.InfoID = newID;
                //    for (int i = 0; i < arr.Length; i++)
                //    {
                //        info.SpecialID = DataConverter.CLng(arr[i]);
                //        this.bspec.Add(info);
                //    }
                //}
                Response.Redirect("MyContent.aspx?NodeID=" + this.NodeID);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新内容
 /// </summary>
 /// <param name="FieldSet"></param>
 /// <param name="CommonData"></param>
 void ID_CommonModel.UpdateContent(string FieldSet, M_CommonData CommonData)
 {
     string strSql = "Update " + CommonData.TableName + " Set " + FieldSet + " Where [ID]=" + CommonData.ItemID;
     SqlHelper.ExecuteSql(strSql);
     string strSql2 = "Update ZL_CommonModel Set Title='" + CommonData.Title + "',EliteLevel=" + CommonData.EliteLevel + ",InfoID='" + CommonData.InfoID + "',SpecialID='" + CommonData.SpecialID + "',Template='" + CommonData.Template + "' Where GeneralID=" + CommonData.GeneralID;
     SqlHelper.ExecuteSql(strSql2);
 }
Пример #6
0
 /// <summary>
 /// 获取内容信息不含公用信息
 /// </summary>
 /// <param name="GeneralID"></param>
 /// <returns></returns>
 DataTable ID_CommonModel.GetContent(M_CommonData CommonData)
 {
     string strSql = "PR_Content_Read";
     SqlParameter[] cmdParam = new SqlParameter[] {
         new SqlParameter("@TableName",SqlDbType.NVarChar),
         new SqlParameter("@ItemID",SqlDbType.Int)
     };
     cmdParam[0].Value = CommonData.TableName;
     cmdParam[1].Value = CommonData.ItemID;
     return SqlHelper.ExecuteTable(CommandType.StoredProcedure, strSql, cmdParam);
 }
Пример #7
0
 /// <summary>
 /// 获取内容公用信息
 /// </summary>
 /// <param name="GeneralID"></param>
 /// <returns></returns>
 M_CommonData ID_CommonModel.GetCommonData(int GeneralID)
 {
     string strSql = "PR_Content_Common";
     SqlParameter[] cmdParam = new SqlParameter[] {
         new SqlParameter("@GeneralID",SqlDbType.Int)
     };
     cmdParam[0].Value = GeneralID;
     using (SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, strSql, cmdParam))
     {
         if (reader.Read())
         {
             M_CommonData info = new M_CommonData();
             info.GeneralID = GeneralID;
             info.NodeID = DataConverter.CLng(reader["NodeID"]);
             info.ModelID = DataConverter.CLng(reader["ModelID"]);
             info.ItemID = DataConverter.CLng(reader["ItemID"]);
             info.TableName = reader["TableName"].ToString();
             info.Title = reader["Title"].ToString();
             info.Inputer = reader["Inputer"].ToString();
             info.EliteLevel = DataConverter.CLng(reader["EliteLevel"]);
             info.InfoID = reader["InfoID"].ToString();
             info.SpecialID = reader["SpecialID"].ToString();
             info.IsCreate = DataConverter.CLng(reader["IsCreate"].ToString());
             info.HtmlLink = reader["HtmlLink"].ToString();
             info.Hits = DataConverter.CLng(reader["Hits"].ToString());
             info.Template = reader["Template"].ToString();
             info.Status = DataConverter.CLng(reader["Status"].ToString());
             return info;
         }
         else
             return new M_CommonData(true);
     }
 }
Пример #8
0
 /// <summary>
 /// 彻底删除内容数据
 /// </summary>
 /// <param name="CommonData"></param>
 void ID_CommonModel.DelContent(M_CommonData CommonData)
 {
     string strSql = "PR_Content_Del";
     SqlParameter[] cmdParam = new SqlParameter[] {
         new SqlParameter("@TableName",SqlDbType.NVarChar),
         new SqlParameter("@ItemID",SqlDbType.Int),
         new SqlParameter("@GeneralID",SqlDbType.Int)
     };
     cmdParam[0].Value = CommonData.TableName;
     cmdParam[1].Value = CommonData.ItemID;
     cmdParam[2].Value = CommonData.GeneralID;
     SqlHelper.ExecuteProc(strSql, cmdParam);
 }
Пример #9
0
 /// <summary>
 /// 更新内容
 /// </summary>
 /// <param name="ContentDT"></param>
 /// <param name="CommonData"></param>
 public void UpdateContent(DataTable ContentDT, M_CommonData CommonData)
 {
     string FieldSet = "";
     foreach (DataRow dr in ContentDT.Rows)
     {
         if (string.IsNullOrEmpty(FieldSet))
             FieldSet = this.GetFieldSet(dr);
         else
             FieldSet = FieldSet + "," + this.GetFieldSet(dr);
     }
     dal.UpdateContent(FieldSet, CommonData);
 }