Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_Logs_Model GetModel(Guid LogsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(
                "select  top 1 LogsID,LogsTitle,LogsContent,CoverPictureUrl,CreateUser,CreateTime,UpdateUser,UpdateTime,isDelete,Remark from Info_Logs ");
            strSql.Append(" where LogsID=@LogsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LogsID", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = LogsID;

            Info_Logs_Model model = new Info_Logs_Model();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        protected void Repeater1_OnItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                string LogsID = ((HiddenField)e.Item.FindControl("HiddenField1")).Value;

                Response.Redirect("LogDetail.aspx?LogsID=" + LogsID + "&AccountNum=" + AccountNum + "&UserID=" +
                                  UserID);
            }
            else if (e.CommandName == "Check")
            {
                string LogsID = ((HiddenField)e.Item.FindControl("HiddenField1")).Value;

                Response.Redirect("LogShow.aspx?LogsID=" + LogsID + "&AccountNum=" + AccountNum + "&UserID=" +
                                  UserID);
            }
            else if (e.CommandName == "Delete")
            {
                string          LogsID        = ((HiddenField)e.Item.FindControl("HiddenField1")).Value;
                Info_Logs_BLL   infoLogsBll   = new Info_Logs_BLL();
                Info_Logs_Model infoLogsModel = infoLogsBll.GetModel(new Guid(LogsID));
                infoLogsModel.isDelete   = true;
                infoLogsModel.UpdateUser = new Guid(UserID);
                infoLogsModel.UpdateTime = DateTime.Now;
                infoLogsBll.Update(infoLogsModel);
                GetLogsList();
                // infoLogsBll.Update("")
            }

            if (e.CommandName == "ADD")
            {
                Response.Redirect("LogDetail.aspx?UserID=" + UserID + "&AccountNum=" + AccountNum);
            }
        }
Ejemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string        LogsTitle   = TextBox1.Text;
            string        LogsContent = TextArea1.Value;
            Info_Logs_BLL infoLogsBll = new Info_Logs_BLL();

            if (LogsID != null)
            {
                Info_Logs_Model infoLogsModel = infoLogsBll.GetModel(new Guid(LogsID));
                // 更新
                infoLogsModel.LogsTitle   = LogsTitle;
                infoLogsModel.LogsContent = LogsContent;
                infoLogsModel.isDelete    = false;
                infoLogsModel.UpdateTime  = DateTime.Now;
                infoLogsModel.UpdateUser  = infoLogsModel.CreateUser;

                // 添加日志
                Sys_ProcessLog_Model sysProcessLogModel = new Sys_ProcessLog_Model();
                sysProcessLogModel.ID             = Guid.NewGuid();
                sysProcessLogModel.LogType        = (int)SystemLogType.LogsAdd;
                sysProcessLogModel.LogDescription = "更新了一条日志";
                sysProcessLogModel.CreateUser     = new Guid(UserID);
                sysProcessLogModel.CreateTime     = DateTime.Now;


                bool result = infoLogsBll.Update(infoLogsModel, sysProcessLogModel);
                if (result)
                {
                    Response.Write("更新成功");
                    Response.Redirect("LogList.aspx?LogsID=" + LogsID + "&AccountNum=" + AccountNum + "&UserID=" + UserID);
                }
            }
            // 为空.添加
            if (UserID != null)
            {
                // 两种写法
                Info_Logs_Model infoLogsModel = new Info_Logs_Model()
                {
                    LogsTitle   = LogsTitle,
                    LogsContent = LogsContent,
                    isDelete    = false,
                    CreateTime  = DateTime.Now,
                    CreateUser  = new Guid(UserID)
                };
                // 添加日志
                Sys_ProcessLog_Model sysProcessLogModel = new Sys_ProcessLog_Model();
                sysProcessLogModel.ID             = Guid.NewGuid();
                sysProcessLogModel.LogType        = (int)SystemLogType.LogsAdd;
                sysProcessLogModel.LogDescription = "添加了一条日志";
                sysProcessLogModel.CreateUser     = new Guid(UserID);
                sysProcessLogModel.CreateTime     = DateTime.Now;
                bool result = infoLogsBll.Add(infoLogsModel, sysProcessLogModel);
                if (result)
                {
                    Response.Write("添加成功");
                    Response.Redirect("LogList.aspx?LogsID=" + LogsID + "&AccountNum=" + AccountNum + "&UserID=" + UserID);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取页面内容
        /// </summary>
        private void GetInfoLogs()
        {
            Info_Logs_BLL   infoLogsBll   = new Info_Logs_BLL();
            Info_Logs_Model infoLogsModel = infoLogsBll.GetModel(new Guid(LogsID));

            Label1.Text = infoLogsModel.LogsTitle;
            Label2.Text = infoLogsModel.LogsContent;
            Label3.Text = infoLogsModel.UpdateTime.ToString();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Info_Logs_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Info_Logs set ");
            strSql.Append("LogsTitle=@LogsTitle,");
            strSql.Append("LogsContent=@LogsContent,");
            strSql.Append("CoverPictureUrl=@CoverPictureUrl,");
            strSql.Append("CreateUser=@CreateUser,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("UpdateUser=@UpdateUser,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("isDelete=@isDelete,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where LogsID=@LogsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LogsTitle",       SqlDbType.NVarChar,          50),
                new SqlParameter("@LogsContent",     SqlDbType.NVarChar,          -1),
                new SqlParameter("@CoverPictureUrl", SqlDbType.NVarChar,         255),
                new SqlParameter("@CreateUser",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@UpdateUser",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@UpdateTime",      SqlDbType.DateTime),
                new SqlParameter("@isDelete",        SqlDbType.Bit,                1),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,          50),
                new SqlParameter("@LogsID",          SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = model.LogsTitle;
            parameters[1].Value = model.LogsContent;
            parameters[2].Value = model.CoverPictureUrl;
            parameters[3].Value = model.CreateUser;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.UpdateUser;
            parameters[6].Value = model.UpdateTime;
            parameters[7].Value = model.isDelete;
            parameters[8].Value = model.Remark;
            parameters[9].Value = model.LogsID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Info_Logs_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Info_Logs(");
            strSql.Append(
                "LogsID,LogsTitle,LogsContent,CoverPictureUrl,CreateUser,CreateTime,UpdateUser,UpdateTime,isDelete,Remark)");
            strSql.Append(" values (");
            strSql.Append(
                "@LogsID,@LogsTitle,@LogsContent,@CoverPictureUrl,@CreateUser,@CreateTime,@UpdateUser,@UpdateTime,@isDelete,@Remark)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LogsID",          SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@LogsTitle",       SqlDbType.NVarChar,          50),
                new SqlParameter("@LogsContent",     SqlDbType.NVarChar,          -1),
                new SqlParameter("@CoverPictureUrl", SqlDbType.NVarChar,         255),
                new SqlParameter("@CreateUser",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@UpdateUser",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@UpdateTime",      SqlDbType.DateTime),
                new SqlParameter("@isDelete",        SqlDbType.Bit,                1),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = Guid.NewGuid();
            parameters[1].Value = model.LogsTitle;
            parameters[2].Value = model.LogsContent;
            parameters[3].Value = model.CoverPictureUrl;
            // parameters[4].Value = Guid.NewGuid();
            parameters[4].Value = model.CreateUser;

            parameters[5].Value = model.CreateTime;
            // parameters[6].Value = Guid.NewGuid();
            parameters[6].Value = model.UpdateUser;

            parameters[7].Value = model.UpdateTime;
            parameters[8].Value = model.isDelete;
            parameters[9].Value = model.Remark;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // 获取传值
     LogsID     = Request["LogsID"];
     UserID     = Request["UserID"];
     AccountNum = Request["AccountNum"];
     if (!IsPostBack)
     {
         if (LogsID != null)
         {
             Info_Logs_BLL   infoLogsBll   = new Info_Logs_BLL();
             Info_Logs_Model infoLogsModel = infoLogsBll.GetModel(new Guid(LogsID));
             if (infoLogsModel != null)
             {
                 TextBox1.Text      = infoLogsModel.LogsTitle;
                 TextArea1.Value    = infoLogsModel.LogsContent;
                 HiddenField1.Value = infoLogsModel.LogsID.ToString();
             }
         }
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新一条数据,使用事务
        /// </summary>
        public bool Update(Info_Logs_Model model, Sys_ProcessLog_Model sysProcessLogModel)
        {
            bool result = false;

            // 使用数据库链接
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                //使用事务 开始事务
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update Info_Logs set ");
                        strSql.Append("LogsTitle=@LogsTitle,");
                        strSql.Append("LogsContent=@LogsContent,");
                        strSql.Append("CoverPictureUrl=@CoverPictureUrl,");
                        strSql.Append("CreateUser=@CreateUser,");
                        strSql.Append("CreateTime=@CreateTime,");
                        strSql.Append("UpdateUser=@UpdateUser,");
                        strSql.Append("UpdateTime=@UpdateTime,");
                        strSql.Append("isDelete=@isDelete,");
                        strSql.Append("Remark=@Remark");
                        strSql.Append(" where LogsID=@LogsID ");
                        strSql.Append(";select @LogsID;");

                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@LogsTitle",       SqlDbType.NVarChar,          50),
                            new SqlParameter("@LogsContent",     SqlDbType.NVarChar,          -1),
                            new SqlParameter("@CoverPictureUrl", SqlDbType.NVarChar,         255),
                            new SqlParameter("@CreateUser",      SqlDbType.UniqueIdentifier,  16),
                            new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                            new SqlParameter("@UpdateUser",      SqlDbType.UniqueIdentifier,  16),
                            new SqlParameter("@UpdateTime",      SqlDbType.DateTime),
                            new SqlParameter("@isDelete",        SqlDbType.Bit,                1),
                            new SqlParameter("@Remark",          SqlDbType.NVarChar,          50),
                            new SqlParameter("@LogsID",          SqlDbType.UniqueIdentifier, 16)
                        };
                        parameters[0].Value = model.LogsTitle;
                        parameters[1].Value = model.LogsContent;
                        parameters[2].Value = model.CoverPictureUrl;
                        parameters[3].Value = model.CreateUser;
                        parameters[4].Value = model.CreateTime;
                        parameters[5].Value = model.UpdateUser;
                        parameters[6].Value = model.UpdateTime;
                        parameters[7].Value = model.isDelete;
                        parameters[8].Value = model.Remark;
                        parameters[9].Value = model.LogsID;

                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters);
                        if (obj != null)
                        {
                            model.LogsID = new Guid(Convert.ToString(obj));
                            // 判断想不想要加入日志,如果不想加入日志,可以传null
                            bool processLogResult = true;
                            if (sysProcessLogModel != null)
                            {
                                //添加时要告诉另一个语句用的是,哪一个连接,哪一个事务
                                processLogResult = new Sys_ProcessLog_DAL().Add(conn, trans, sysProcessLogModel);
                            }

                            if (processLogResult)
                            {
                                result = true;
                                trans.Commit();
                            }
                            else
                            {
                                result = false;
                                trans.Rollback();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        result = false;
                        trans.Rollback();
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_Logs_Model DataRowToModel(DataRow row)
        {
            Info_Logs_Model model = new Info_Logs_Model();

            if (row != null)
            {
                if (row["LogsID"] != null && row["LogsID"].ToString() != "")
                {
                    model.LogsID = new Guid(row["LogsID"].ToString());
                }

                if (row["LogsTitle"] != null)
                {
                    model.LogsTitle = row["LogsTitle"].ToString();
                }

                if (row["LogsContent"] != null)
                {
                    model.LogsContent = row["LogsContent"].ToString();
                }

                if (row["CoverPictureUrl"] != null)
                {
                    model.CoverPictureUrl = row["CoverPictureUrl"].ToString();
                }

                if (row["CreateUser"] != null && row["CreateUser"].ToString() != "")
                {
                    model.CreateUser = new Guid(row["CreateUser"].ToString());
                }

                if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                }

                if (row["UpdateUser"] != null && row["UpdateUser"].ToString() != "")
                {
                    model.UpdateUser = new Guid(row["UpdateUser"].ToString());
                }

                if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
                }

                if (row["isDelete"] != null && row["isDelete"].ToString() != "")
                {
                    if ((row["isDelete"].ToString() == "1") || (row["isDelete"].ToString().ToLower() == "true"))
                    {
                        model.isDelete = true;
                    }
                    else
                    {
                        model.isDelete = false;
                    }
                }

                if (row["Remark"] != null)
                {
                    model.Remark = row["Remark"].ToString();
                }
            }

            return(model);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Info_Logs_Model model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Info_Logs_Model model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 更新一条数据,使用事务
 /// </summary>
 public bool Update(Info_Logs_Model model, Sys_ProcessLog_Model sysProcessLogModel)
 {
     return(dal.Update(model, sysProcessLogModel));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion BasicMethod

        #region ExtensionMethod

        /// <summary>
        /// 增加一条数据,使用事务
        /// </summary>
        public bool Add(Info_Logs_Model model, Sys_ProcessLog_Model sysProcessLogModel)
        {
            return(dal.Add(model, sysProcessLogModel));
        }