Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        public void ResetPassword(Johnny.CMS.OM.Access.Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE [cms_administrator] SET ");
            strSql.Append("[Password]=@password,");
            strSql.Append("[UpdatedTime]=@updatedtime,");
            strSql.Append("[UpdatedById]=@updatedbyid,");
            strSql.Append("[UpdatedByName]=@updatedbyname");
            strSql.Append(" WHERE [AdminId]=@adminid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminid",       SqlDbType.Int,        4),
                new SqlParameter("@adminname",     SqlDbType.VarChar,   50),
                new SqlParameter("@password",      SqlDbType.VarChar,   32),
                new SqlParameter("@updatedtime",   SqlDbType.DateTime),
                new SqlParameter("@updatedbyid",   SqlDbType.Int,        4),
                new SqlParameter("@updatedbyname", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.AdminId;
            parameters[1].Value = model.AdminName;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.UpdatedTime;
            parameters[4].Value = model.UpdatedById;
            parameters[5].Value = model.UpdatedByName;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>
        public Johnny.CMS.OM.Access.Administrator GetModel(int adminid)
        {
            //Set up a return value
            Johnny.CMS.OM.Access.Administrator model = null;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT [AdminId], [AdminName], [Password], [FullName], [Gender], [Tel], [Email], [ValidFrom], [ValidTo], [IsActivated], [LoginTimes], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] ");
            strSql.Append(" FROM [cms_administrator] ");
            strSql.Append(" WHERE [AdminId]=@adminid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminid", SqlDbType.Int, 4)
            };
            parameters[0].Value = adminid;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                {
                    model = new Johnny.CMS.OM.Access.Administrator(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetBoolean(4), sdr.GetString(5), sdr.GetString(6), sdr.GetDateTime(7), sdr.GetDateTime(8), sdr.GetBoolean(9), sdr.GetInt32(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetDateTime(14), sdr.GetInt32(15), sdr.GetString(16), sdr.GetInt32(17));
                }
                else
                {
                    model = new Johnny.CMS.OM.Access.Administrator();
                }
            }
            return(model);
        }
Ejemplo n.º 3
0
 protected void btnResetPassword_Click(object sender, System.EventArgs e)
 {
     Johnny.CMS.BLL.Access.Administrator bll   = new Johnny.CMS.BLL.Access.Administrator();
     Johnny.CMS.OM.Access.Administrator  model = new Johnny.CMS.OM.Access.Administrator();
     model.AdminId       = Convert.ToInt32(Request.QueryString["id"]);
     model.Password      = FormsAuthentication.HashPasswordForStoringInConfigFile(Johnny.CMS.WebUI.utility.ConfigInfo.DefaultPassword, "MD5");
     model.UpdatedTime   = System.DateTime.Now;
     model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
     model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
     bll.ResetPassword(model);
     SetMessage(GetMessage("E00119", Johnny.CMS.WebUI.utility.ConfigInfo.DefaultPassword));
 }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //check input
            if (DataValidation.IsEmpty(txtOriginalPassword.Text))
            {
                SetMessage(GetMessage("E00113"));
                txtOriginalPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtNewPassword.Text))
            {
                SetMessage(GetMessage("E00114"));
                txtNewPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00115"));
                txtConfirmedPassword.Focus();
                return;
            }

            if (!DataValidation.IsEqual(txtNewPassword.Text, txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00116"));
                txtNewPassword.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOriginalPassword.Text, "MD5");

            //check old password
            if (!admin.CheckLogin(DataConvert.GetString(Session["UserName"]), strPwd))
            {
                SetMessage(GetMessage("E00117"));
                txtOriginalPassword.Focus();
                return;
            }

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            model.AdminId = DataConvert.GetInt32(Session["UserId"]);
            model.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "MD5");
            model.UpdatedTime = System.DateTime.Now;
            model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
            admin.ResetPassword(model);
            SetMessage(GetMessage("E00118"));
        }
Ejemplo n.º 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //check input
            if (DataValidation.IsEmpty(txtOriginalPassword.Text))
            {
                SetMessage(GetMessage("E00113"));
                txtOriginalPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtNewPassword.Text))
            {
                SetMessage(GetMessage("E00114"));
                txtNewPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00115"));
                txtConfirmedPassword.Focus();
                return;
            }

            if (!DataValidation.IsEqual(txtNewPassword.Text, txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00116"));
                txtNewPassword.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOriginalPassword.Text, "MD5");

            //check old password
            if (!admin.CheckLogin(DataConvert.GetString(Session["UserName"]), strPwd))
            {
                SetMessage(GetMessage("E00117"));
                txtOriginalPassword.Focus();
                return;
            }

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            model.AdminId       = DataConvert.GetInt32(Session["UserId"]);
            model.Password      = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "MD5");
            model.UpdatedTime   = System.DateTime.Now;
            model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
            admin.ResetPassword(model);
            SetMessage(GetMessage("E00118"));
        }
Ejemplo n.º 6
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            base.ManageTable = model.TableName;
            base.ManageKey = model.PrimaryKey;
            base.IsDesc = model.IsDesc;

            if (!IsPostBack)
            {
                myManageGridView.Columns[2].HeaderText = GetLabelText("Administrator_AdminName");
                myManageGridView.Columns[3].HeaderText = GetLabelText("Administrator_FullName");

                getData();
            }
        }
Ejemplo n.º 7
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            base.ManageTable = model.TableName;
            base.ManageKey   = model.PrimaryKey;
            base.IsDesc      = model.IsDesc;

            if (!IsPostBack)
            {
                myManageGridView.Columns[2].HeaderText = GetLabelText("Administrator_AdminName");
                myManageGridView.Columns[3].HeaderText = GetLabelText("Administrator_FullName");

                getData();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>    	 
        public IList<Johnny.CMS.OM.Access.Administrator> GetList()
        {
            IList<Johnny.CMS.OM.Access.Administrator> list = new List<Johnny.CMS.OM.Access.Administrator>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [AdminId], [AdminName], [Password], [FullName], [Gender], [Tel], [Email], [ValidFrom], [ValidTo], [IsActivated], [LoginTimes], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] ");
            strSql.Append(" FROM [cms_administrator] ");
            strSql.Append(" ORDER BY [Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.Access.Administrator item = new Johnny.CMS.OM.Access.Administrator(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetBoolean(4), sdr.GetString(5), sdr.GetString(6), sdr.GetDateTime(7), sdr.GetDateTime(8), sdr.GetBoolean(9), sdr.GetInt32(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetDateTime(14), sdr.GetInt32(15), sdr.GetString(16), sdr.GetInt32(17));
                    list.Add(item);
                }
            }
            return list;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>
        public IList <Johnny.CMS.OM.Access.Administrator> GetList()
        {
            IList <Johnny.CMS.OM.Access.Administrator> list = new List <Johnny.CMS.OM.Access.Administrator>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT [AdminId], [AdminName], [Password], [FullName], [Gender], [Tel], [Email], [ValidFrom], [ValidTo], [IsActivated], [LoginTimes], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] ");
            strSql.Append(" FROM [cms_administrator] ");
            strSql.Append(" ORDER BY [Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.Access.Administrator item = new Johnny.CMS.OM.Access.Administrator(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetBoolean(4), sdr.GetString(5), sdr.GetString(6), sdr.GetDateTime(7), sdr.GetDateTime(8), sdr.GetBoolean(9), sdr.GetInt32(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetDateTime(14), sdr.GetInt32(15), sdr.GetString(16), sdr.GetInt32(17));
                    list.Add(item);
                }
            }
            return(list);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>    	 
        public Johnny.CMS.OM.Access.Administrator GetModel(int adminid)
        {
            //Set up a return value
            Johnny.CMS.OM.Access.Administrator model = null;

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [AdminId], [AdminName], [Password], [FullName], [Gender], [Tel], [Email], [ValidFrom], [ValidTo], [IsActivated], [LoginTimes], [CreatedTime], [CreatedById], [CreatedByName], [UpdatedTime], [UpdatedById], [UpdatedByName], [Sequence] ");
            strSql.Append(" FROM [cms_administrator] ");
            strSql.Append(" WHERE [AdminId]=@adminid");
            SqlParameter[] parameters = {
					new SqlParameter("@adminid", SqlDbType.Int,4)};
            parameters[0].Value = adminid;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                    model = new Johnny.CMS.OM.Access.Administrator(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetBoolean(4), sdr.GetString(5), sdr.GetString(6), sdr.GetDateTime(7), sdr.GetDateTime(8), sdr.GetBoolean(9), sdr.GetInt32(10), sdr.GetDateTime(11), sdr.GetInt32(12), sdr.GetString(13), sdr.GetDateTime(14), sdr.GetInt32(15), sdr.GetString(16), sdr.GetInt32(17));
                else
                    model = new Johnny.CMS.OM.Access.Administrator();
            }
            return model;
        }
Ejemplo n.º 11
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //check full name
            if (!CheckInputLength(txtFullName, "E00104", false))
            {
                return;
            }
            //check tel
            if (!CheckInputLength(txtTel, "E00106"))
            {
                return;
            }
            //check email
            if (!CheckInputLength(txtEmail, "E00106"))
            {
                return;
            }

            Johnny.CMS.BLL.Access.Administrator bll   = new Johnny.CMS.BLL.Access.Administrator();
            Johnny.CMS.OM.Access.Administrator  model = new Johnny.CMS.OM.Access.Administrator();

            //update
            model.AdminId  = DataConvert.GetInt32(Session["UserId"]);
            model.FullName = txtFullName.Text;
            model.Gender   = rdbGender0.Checked;
            model.Tel      = txtTel.Text;
            model.Email    = txtEmail.Text;
            //model.BeginTime = DataConvert.GetDateTime(lblBeginTime.Text);
            //model.EndTime = DataConvert.GetDateTime(lblEndTime.Text);
            //model.IsActivated = rdbActivated0.Checked;
            model.UpdatedTime   = System.DateTime.Now;
            model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

            bll.UpdatePersonal(model);
            SetMessage(GetMessage("C00003"));
        }
Ejemplo n.º 12
0
 protected void btnResetPassword_Click(object sender, System.EventArgs e)
 {            
     Johnny.CMS.BLL.Access.Administrator bll = new Johnny.CMS.BLL.Access.Administrator();
     Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
     model.AdminId = Convert.ToInt32(Request.QueryString["id"]);
     model.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(Johnny.CMS.WebUI.utility.ConfigInfo.DefaultPassword, "MD5");
     model.UpdatedTime = System.DateTime.Now;
     model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
     model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
     bll.ResetPassword(model);
     SetMessage(GetMessage("E00119", Johnny.CMS.WebUI.utility.ConfigInfo.DefaultPassword));
 }
Ejemplo n.º 13
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //check admin name
            if (!CheckInputEmptyAndLength(txtAdminName, "E00101", "E00102"))
                return;
            //check full name
            if (!CheckInputLength(txtFullName, "E00104", false))
                return;
            //check tel
            if (!CheckInputLength(txtTel, "E00106"))
                return;
            //check email
            if (!CheckInputLength(txtEmail, "E00106"))
                return;
            if (!DataValidation.IsEmail(txtEmail.Text))
            {
                SetMessage(GetMessage("C00010"));
                txtEmail.Focus();
                return;
            }
            ////check date
            if (!DataValidation.IsDate(txtValidFrom.Text))
            {
                SetMessage(GetMessage("C00009"));
                txtValidFrom.Focus();
                return;
            }

            if (!DataValidation.IsDate(txtValidTo.Text))
            {
                SetMessage(GetMessage("C00009"));
                txtValidTo.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator bll = new Johnny.CMS.BLL.Access.Administrator();
            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();

            if (Request.QueryString["action"] == "modify")
            {
                //update
                model.AdminId = Convert.ToInt32(Request.QueryString["id"]);
                model.AdminName = txtAdminName.Text;
                model.FullName = txtFullName.Text;
                model.Gender = rdbGender0.Checked;
                model.Tel = txtTel.Text;
                model.Email = txtEmail.Text;
                model.ValidFrom = DataConvert.GetDateTime(txtValidFrom.Text);
                model.ValidTo = DataConvert.GetDateTime(txtValidTo.Text);
                model.IsActivated = rdbActivated0.Checked;
                model.UpdatedTime = System.DateTime.Now;
                model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
                model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

                bll.Update(model);
                SetMessage(GetMessage("C00003"));
            }
            else
            {
                //insert
                model.AdminName = txtAdminName.Text;
                model.Password = "******";
                model.FullName = txtFullName.Text;
                model.Gender = rdbGender0.Checked;
                model.Tel = txtTel.Text;
                model.Email = txtEmail.Text;
                model.ValidFrom = DataConvert.GetDateTime(txtValidFrom.Text);
                model.ValidTo = DataConvert.GetDateTime(txtValidTo.Text);
                model.IsActivated = rdbActivated0.Checked;
                model.LoginTimes = 0;
                model.CreatedTime = System.DateTime.Now;
                model.CreatedById = DataConvert.GetInt32(Session["UserId"]);
                model.CreatedByName = DataConvert.GetString(Session["UserName"]);
                model.UpdatedTime = System.DateTime.Now;
                model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
                model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

                if (bll.Add(model) > 0)
                {
                    SetMessage(GetMessage("C00001"));
                    txtAdminName.Text = "";
                    txtFullName.Text = "";
                    txtTel.Text = "";
                    txtEmail.Text = "";
                    txtValidFrom.Text = "";
                    txtValidTo.Text = "";
                    lblLoginTimes.Text = "";
                    lblCreatedTime.Text = "";
                    lblCreatedByName.Text = "";
                    lblUpdatedTime.Text = "";
                    lblUpdatedByName.Text = "";
                }
                else
                    SetMessage(GetMessage("C00002"));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Add one record
        /// </summary>
        public int Add(Johnny.CMS.OM.Access.Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("DECLARE @Sequence int");
            strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [cms_administrator]");
            strSql.Append(" if @Sequence is NULL");
            strSql.Append(" Set @Sequence=1");
            strSql.Append("INSERT INTO [cms_administrator](");
            strSql.Append("[AdminName],[Password],[FullName],[Gender],[Tel],[Email],[ValidFrom],[ValidTo],[IsActivated],[LoginTimes],[CreatedTime],[CreatedById],[CreatedByName],[UpdatedTime],[UpdatedById],[UpdatedByName],[Sequence]");
            strSql.Append(")");
            strSql.Append(" VALUES (");
            strSql.Append("@adminname,@password,@fullname,@gender,@tel,@email,@validfrom,@validto,@isactivated,@logintimes,@createdtime,@createdbyid,@createdbyname,@updatedtime,@updatedbyid,@updatedbyname,@sequence");
            strSql.Append(")");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminname",     SqlDbType.VarChar,   50),
                new SqlParameter("@password",      SqlDbType.VarChar,   32),
                new SqlParameter("@fullname",      SqlDbType.NVarChar,  50),
                new SqlParameter("@gender",        SqlDbType.Bit),
                new SqlParameter("@tel",           SqlDbType.VarChar,   50),
                new SqlParameter("@email",         SqlDbType.VarChar,   50),
                new SqlParameter("@validfrom",     SqlDbType.DateTime),
                new SqlParameter("@validto",       SqlDbType.DateTime),
                new SqlParameter("@isactivated",   SqlDbType.Bit),
                new SqlParameter("@logintimes",    SqlDbType.Int,        4),
                new SqlParameter("@createdtime",   SqlDbType.DateTime),
                new SqlParameter("@createdbyid",   SqlDbType.Int,        4),
                new SqlParameter("@createdbyname", SqlDbType.VarChar,   50),
                new SqlParameter("@updatedtime",   SqlDbType.DateTime),
                new SqlParameter("@updatedbyid",   SqlDbType.Int,        4),
                new SqlParameter("@updatedbyname", SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.AdminName;
            parameters[1].Value  = model.Password;
            parameters[2].Value  = model.FullName;
            parameters[3].Value  = model.Gender;
            parameters[4].Value  = model.Tel;
            parameters[5].Value  = model.Email;
            parameters[6].Value  = model.ValidFrom;
            parameters[7].Value  = model.ValidTo;
            parameters[8].Value  = model.IsActivated;
            parameters[9].Value  = model.LoginTimes;
            parameters[10].Value = model.CreatedTime;
            parameters[11].Value = model.CreatedById;
            parameters[12].Value = model.CreatedByName;
            parameters[13].Value = model.UpdatedTime;
            parameters[14].Value = model.UpdatedById;
            parameters[15].Value = model.UpdatedByName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 15
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);            

            if (!this.IsPostBack)
            {
                litPageTitle.Text = GetLabelText("Administrator_Title");
                litAdminName.Text = GetLabelText("Administrator_AdminName");
                txtAdminName.ToolTip = GetLabelText("Administrator_AdminName");
                litFullName.Text = GetLabelText("Administrator_FullName");
                txtFullName.ToolTip = GetLabelText("Administrator_FullName");
                litGender.Text = GetLabelText("Administrator_Gender");
                rdbGender0.Text = GetLabelText("Common_Male");
                rdbGender1.Text = GetLabelText("Common_Female");
                litRdbTip.Text = GetLabelText("Administrator_Gender");
                litTel.Text = GetLabelText("Administrator_Tel");
                txtTel.ToolTip = GetLabelText("Administrator_Tel");
                litEmail.Text = GetLabelText("Administrator_Email");
                txtEmail.ToolTip = GetLabelText("Administrator_Email");
                litValidFrom.Text = GetLabelText("Administrator_ValidFrom");
                txtValidFrom.ToolTip = GetLabelText("Administrator_ValidFrom");
                litValidTo.Text = GetLabelText("Administrator_ValidTo");
                txtValidTo.ToolTip = GetLabelText("Administrator_ValidTo");
                litActivated.Text = GetLabelText("Administrator_IsActivated");
                rdbActivated0.Text = GetLabelText("Common_Yes");
                rdbActivated1.Text = GetLabelText("Common_No");
                litRdbActivatedTip.Text = GetLabelText("Administrator_IsActivated");
                litLoginTimes.Text = GetLabelText("Administrator_LoginTimes");
                litCreatedTime.Text = GetLabelText("Common_CreatedTime");
                litCreatedByName.Text = GetLabelText("Common_CreatedByName");
                litUpdatedTime.Text = GetLabelText("Common_UpdatedTime");
                litUpdatedByName.Text = GetLabelText("Common_UpdatedByName");
                
                if (Request.QueryString["action"] == "modify")
                {
                    //get UserId
                    int UserId = Convert.ToInt32(Request.QueryString["id"]);

                    Johnny.CMS.BLL.Access.Administrator bll = new Johnny.CMS.BLL.Access.Administrator();
                    Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
                    model = bll.GetModel(UserId);

                    txtAdminName.Text = model.AdminName;
                    txtFullName.Text = model.FullName;
                    if (model.Gender)
                        rdbGender0.Checked = true;
                    else
                        rdbGender1.Checked = true;
                    txtTel.Text = model.Tel;
                    txtEmail.Text = model.Email;
                    txtValidFrom.Text = DataConvert.GetShortDateString(model.ValidFrom);
                    txtValidTo.Text = DataConvert.GetShortDateString(model.ValidTo);
                    if (model.IsActivated)
                        rdbActivated0.Checked = true;
                    else
                        rdbActivated1.Checked = true;
                    lblLoginTimes.Text = DataConvert.GetString(model.LoginTimes);
                    lblCreatedTime.Text = DataConvert.GetLongDateString(model.CreatedTime);
                    lblCreatedByName.Text = model.CreatedByName;
                    lblUpdatedTime.Text = DataConvert.GetLongDateString(model.UpdatedTime);
                    lblUpdatedByName.Text = model.UpdatedByName;

                    btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
                    //btnAdd.Text = CONST_BUTTONTEXT_SAVE;
                }
                else
                {
                    rdbGender0.Checked = true;
                    rdbActivated0.Checked = true;
                }
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Update one record
 /// </summary>
 public void UpdatePersonal(Johnny.CMS.OM.Access.Administrator model)
 {
     dal.UpdatePersonal(model);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Add one record
 /// </summary>
 public int Add(Johnny.CMS.OM.Access.Administrator model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Update one record
        /// </summary>
        public void UpdatePersonal(Johnny.CMS.OM.Access.Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE [cms_administrator] SET ");
            //strSql.Append("[AdminName]=@adminname,");
            //strSql.Append("[Password]=@password,");
            strSql.Append("[FullName]=@fullname,");
            strSql.Append("[Gender]=@gender,");
            strSql.Append("[Tel]=@tel,");
            strSql.Append("[Email]=@email,");
            //strSql.Append("[ValidFrom]=@validfrom,");
            //strSql.Append("[ValidTo]=@validto,");
            //strSql.Append("[IsActivated]=@isactivated,");
            //strSql.Append("[LoginTimes]=@logintimes,");
            //strSql.Append("[CreatedTime]=@createdtime,");
            //strSql.Append("[CreatedById]=@createdbyid,");
            //strSql.Append("[CreatedByName]=@createdbyname,");
            strSql.Append("[UpdatedTime]=@updatedtime,");
            strSql.Append("[UpdatedById]=@updatedbyid,");
            strSql.Append("[UpdatedByName]=@updatedbyname");
            strSql.Append(" WHERE [AdminId]=@adminid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminid",       SqlDbType.Int,        4),
                //new SqlParameter("@adminname", SqlDbType.VarChar,50),
                //new SqlParameter("@password", SqlDbType.VarChar,32),
                new SqlParameter("@fullname",      SqlDbType.NVarChar,  50),
                new SqlParameter("@gender",        SqlDbType.Bit),
                new SqlParameter("@tel",           SqlDbType.VarChar,   50),
                new SqlParameter("@email",         SqlDbType.VarChar,   50),
                //new SqlParameter("@validfrom", SqlDbType.DateTime),
                //new SqlParameter("@validto", SqlDbType.DateTime),
                //new SqlParameter("@isactivated", SqlDbType.Bit),
                //new SqlParameter("@logintimes", SqlDbType.Int,4),
                //new SqlParameter("@createdtime", SqlDbType.DateTime),
                //new SqlParameter("@createdbyid", SqlDbType.Int,4),
                //new SqlParameter("@createdbyname", SqlDbType.VarChar,50),
                new SqlParameter("@updatedtime",   SqlDbType.DateTime),
                new SqlParameter("@updatedbyid",   SqlDbType.Int,        4),
                new SqlParameter("@updatedbyname", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.AdminId;
            //parameters[1].Value = model.AdminName;
            //parameters[2].Value = model.Password;
            parameters[1].Value = model.FullName;
            parameters[2].Value = model.Gender;
            parameters[3].Value = model.Tel;
            parameters[4].Value = model.Email;
            //parameters[7].Value = model.ValidFrom;
            //parameters[8].Value = model.ValidTo;
            //parameters[9].Value = model.IsActivated;
            //parameters[10].Value = model.LoginTimes;
            //parameters[11].Value = model.CreatedTime;
            //parameters[12].Value = model.CreatedById;
            //parameters[13].Value = model.CreatedByName;
            parameters[5].Value = model.UpdatedTime;
            parameters[6].Value = model.UpdatedById;
            parameters[7].Value = model.UpdatedByName;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 19
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //check admin name
            if (!CheckInputEmptyAndLength(txtAdminName, "E00101", "E00102"))
            {
                return;
            }
            //check full name
            if (!CheckInputLength(txtFullName, "E00104", false))
            {
                return;
            }
            //check tel
            if (!CheckInputLength(txtTel, "E00106"))
            {
                return;
            }
            //check email
            if (!CheckInputLength(txtEmail, "E00106"))
            {
                return;
            }
            if (!DataValidation.IsEmail(txtEmail.Text))
            {
                SetMessage(GetMessage("C00010"));
                txtEmail.Focus();
                return;
            }
            ////check date
            if (!DataValidation.IsDate(txtValidFrom.Text))
            {
                SetMessage(GetMessage("C00009"));
                txtValidFrom.Focus();
                return;
            }

            if (!DataValidation.IsDate(txtValidTo.Text))
            {
                SetMessage(GetMessage("C00009"));
                txtValidTo.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator bll   = new Johnny.CMS.BLL.Access.Administrator();
            Johnny.CMS.OM.Access.Administrator  model = new Johnny.CMS.OM.Access.Administrator();

            if (Request.QueryString["action"] == "modify")
            {
                //update
                model.AdminId       = Convert.ToInt32(Request.QueryString["id"]);
                model.AdminName     = txtAdminName.Text;
                model.FullName      = txtFullName.Text;
                model.Gender        = rdbGender0.Checked;
                model.Tel           = txtTel.Text;
                model.Email         = txtEmail.Text;
                model.ValidFrom     = DataConvert.GetDateTime(txtValidFrom.Text);
                model.ValidTo       = DataConvert.GetDateTime(txtValidTo.Text);
                model.IsActivated   = rdbActivated0.Checked;
                model.UpdatedTime   = System.DateTime.Now;
                model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
                model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

                bll.Update(model);
                SetMessage(GetMessage("C00003"));
            }
            else
            {
                //insert
                model.AdminName     = txtAdminName.Text;
                model.Password      = "******";
                model.FullName      = txtFullName.Text;
                model.Gender        = rdbGender0.Checked;
                model.Tel           = txtTel.Text;
                model.Email         = txtEmail.Text;
                model.ValidFrom     = DataConvert.GetDateTime(txtValidFrom.Text);
                model.ValidTo       = DataConvert.GetDateTime(txtValidTo.Text);
                model.IsActivated   = rdbActivated0.Checked;
                model.LoginTimes    = 0;
                model.CreatedTime   = System.DateTime.Now;
                model.CreatedById   = DataConvert.GetInt32(Session["UserId"]);
                model.CreatedByName = DataConvert.GetString(Session["UserName"]);
                model.UpdatedTime   = System.DateTime.Now;
                model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
                model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

                if (bll.Add(model) > 0)
                {
                    SetMessage(GetMessage("C00001"));
                    txtAdminName.Text     = "";
                    txtFullName.Text      = "";
                    txtTel.Text           = "";
                    txtEmail.Text         = "";
                    txtValidFrom.Text     = "";
                    txtValidTo.Text       = "";
                    lblLoginTimes.Text    = "";
                    lblCreatedTime.Text   = "";
                    lblCreatedByName.Text = "";
                    lblUpdatedTime.Text   = "";
                    lblUpdatedByName.Text = "";
                }
                else
                {
                    SetMessage(GetMessage("C00002"));
                }
            }
        }
Ejemplo n.º 20
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!this.IsPostBack)
            {
                litPageTitle.Text       = GetLabelText("Administrator_Title");
                litAdminName.Text       = GetLabelText("Administrator_AdminName");
                txtAdminName.ToolTip    = GetLabelText("Administrator_AdminName");
                litFullName.Text        = GetLabelText("Administrator_FullName");
                txtFullName.ToolTip     = GetLabelText("Administrator_FullName");
                litGender.Text          = GetLabelText("Administrator_Gender");
                rdbGender0.Text         = GetLabelText("Common_Male");
                rdbGender1.Text         = GetLabelText("Common_Female");
                litRdbTip.Text          = GetLabelText("Administrator_Gender");
                litTel.Text             = GetLabelText("Administrator_Tel");
                txtTel.ToolTip          = GetLabelText("Administrator_Tel");
                litEmail.Text           = GetLabelText("Administrator_Email");
                txtEmail.ToolTip        = GetLabelText("Administrator_Email");
                litValidFrom.Text       = GetLabelText("Administrator_ValidFrom");
                txtValidFrom.ToolTip    = GetLabelText("Administrator_ValidFrom");
                litValidTo.Text         = GetLabelText("Administrator_ValidTo");
                txtValidTo.ToolTip      = GetLabelText("Administrator_ValidTo");
                litActivated.Text       = GetLabelText("Administrator_IsActivated");
                rdbActivated0.Text      = GetLabelText("Common_Yes");
                rdbActivated1.Text      = GetLabelText("Common_No");
                litRdbActivatedTip.Text = GetLabelText("Administrator_IsActivated");
                litLoginTimes.Text      = GetLabelText("Administrator_LoginTimes");
                litCreatedTime.Text     = GetLabelText("Common_CreatedTime");
                litCreatedByName.Text   = GetLabelText("Common_CreatedByName");
                litUpdatedTime.Text     = GetLabelText("Common_UpdatedTime");
                litUpdatedByName.Text   = GetLabelText("Common_UpdatedByName");

                if (Request.QueryString["action"] == "modify")
                {
                    //get UserId
                    int UserId = Convert.ToInt32(Request.QueryString["id"]);

                    Johnny.CMS.BLL.Access.Administrator bll   = new Johnny.CMS.BLL.Access.Administrator();
                    Johnny.CMS.OM.Access.Administrator  model = new Johnny.CMS.OM.Access.Administrator();
                    model = bll.GetModel(UserId);

                    txtAdminName.Text = model.AdminName;
                    txtFullName.Text  = model.FullName;
                    if (model.Gender)
                    {
                        rdbGender0.Checked = true;
                    }
                    else
                    {
                        rdbGender1.Checked = true;
                    }
                    txtTel.Text       = model.Tel;
                    txtEmail.Text     = model.Email;
                    txtValidFrom.Text = DataConvert.GetShortDateString(model.ValidFrom);
                    txtValidTo.Text   = DataConvert.GetShortDateString(model.ValidTo);
                    if (model.IsActivated)
                    {
                        rdbActivated0.Checked = true;
                    }
                    else
                    {
                        rdbActivated1.Checked = true;
                    }
                    lblLoginTimes.Text    = DataConvert.GetString(model.LoginTimes);
                    lblCreatedTime.Text   = DataConvert.GetLongDateString(model.CreatedTime);
                    lblCreatedByName.Text = model.CreatedByName;
                    lblUpdatedTime.Text   = DataConvert.GetLongDateString(model.UpdatedTime);
                    lblUpdatedByName.Text = model.UpdatedByName;

                    btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
                    //btnAdd.Text = CONST_BUTTONTEXT_SAVE;
                }
                else
                {
                    rdbGender0.Checked    = true;
                    rdbActivated0.Checked = true;
                }
            }
        }
Ejemplo n.º 21
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //check full name
            if (!CheckInputLength(txtFullName, "E00104", false))
                return;
            //check tel
            if (!CheckInputLength(txtTel, "E00106"))
                return;
            //check email
            if (!CheckInputLength(txtEmail, "E00106"))
                return;

            Johnny.CMS.BLL.Access.Administrator bll = new Johnny.CMS.BLL.Access.Administrator();
            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();

            //update
            model.AdminId = DataConvert.GetInt32(Session["UserId"]);
            model.FullName = txtFullName.Text;
            model.Gender = rdbGender0.Checked;
            model.Tel = txtTel.Text;
            model.Email = txtEmail.Text;
            //model.BeginTime = DataConvert.GetDateTime(lblBeginTime.Text);
            //model.EndTime = DataConvert.GetDateTime(lblEndTime.Text);
            //model.IsActivated = rdbActivated0.Checked;
            model.UpdatedTime = System.DateTime.Now;
            model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);

            bll.UpdatePersonal(model);
            SetMessage(GetMessage("C00003"));          
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Reset password
 /// </summary>
 /// <param name="model"></param>
 public void ResetPassword(Johnny.CMS.OM.Access.Administrator model)
 {
     dal.ResetPassword(model);
 }