Esempio n. 1
0
        protected void Unnamed3_Click(object sender, EventArgs e)
        {
            SYS_AdminMod m_supplier = new SYS_AdminMod();

            if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    SysNo = int.Parse(Request.QueryString["id"]);
                }
                m_supplier = SYS_AdminBll.GetInstance().GetModel(SysNo);
            }
            if (txtUserName.Text.Trim() == "")
            {
                ltrError.Text = "请填写用户登录名!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            if (txtPass.Text.Trim() == "" && type == "ADD")
            {
                ltrError.Text = "请输入初始密码!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            m_supplier.CustomerSysNo = int.Parse(Request.QueryString["user"]);
            m_supplier.Username      = txtUserName.Text;

            try
            {
                if (type == "ADD")
                {
                    m_supplier.DR        = 0;
                    m_supplier.Password  = txtPass.Text;
                    m_supplier.TS        = DateTime.Now;
                    m_supplier.LastLogin = DateTime.Now;
                    m_supplier.SysNo     = SYS_AdminBll.GetInstance().Add(m_supplier);

                    SetPrivilege(m_supplier.SysNo);
                    LogManagement.getInstance().WriteTrace(m_supplier.SysNo, "Article.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
                }
                else if (type == "EDIT")
                {
                    if (txtPass.Text.Trim() != "加密存储")
                    {
                        m_supplier.Password = txtPass.Text;
                    }
                    SYS_AdminBll.GetInstance().Update(m_supplier);
                    SetPrivilege(m_supplier.SysNo);
                    LogManagement.getInstance().WriteTrace(m_supplier.SysNo, "Article.Edit", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
                }
                ltrNotice.Text = "该记录已保存成功!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
            }
            catch (Exception ex)
            {
                ltrError.Text = "系统错误,保存失败!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                LogManagement.getInstance().WriteException(ex, "Article.Save", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
            }
        }
Esempio n. 2
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            try
            {
                SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().GetModel(GetSession().AdminEntity.SysNo);
                if (txtOldPsd.Text.Trim() == m_admin.Password)
                {
                    if (txtNewPsd.Text.Trim() == txtNewAgain.Text.Trim())
                    {
                        m_admin.Password = txtNewPsd.Text.Trim();
                        SYS_AdminBll.GetInstance().Update(m_admin);

                        ltrNotice.Text = "密码修改成功!";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('masternoticediv').style.display='';document.getElementById('masternoticediv').style.display;", true);
                    }
                    else
                    {
                        ltrError.Text = "两次密码输入不一致,请重新输入!";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('mastererrordiv').style.display='';jQuery.facebox('PassWord');", true);
                    }
                }
                else
                {
                    ltrError.Text = "旧密码错误,请重新输入!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('mastererrordiv').style.display='';jQuery.facebox('PassWord');", true);
                }
            }
            catch
            {
                ltrError.Text = "系统错误,密码修改失败!";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('mastererrordiv').style.display='';jQuery.facebox('PassWord');", true);
            }
        }
Esempio n. 3
0
        public SYS_AdminMod CheckAdmin(string username, string password)
        {
            SYS_AdminMod model = new SYS_AdminMod();

            using (SQLData data = new SQLData())
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("select SysNo from SYS_Admin where Username='******' and Password='******' and DR=").Append(0);
                try
                {
                    model.CustomerSysNo = int.Parse(data.CmdtoDataRow(builder.ToString())["SysNo"].ToString());
                }
                catch (Exception exception)
                {
                    //throw exception;
                }
            }
            if (model.CustomerSysNo != -999999)
            {
                model           = this.GetModel(model.CustomerSysNo);
                model.LastLogin = DateTime.Now;
                this.Update(model);
            }
            return(model);
        }
Esempio n. 4
0
 public SessionInfo()
 {
     //
     //TODO: 在此处添加构造函数逻辑
     //
     PrivilegeDt = null;
     AdminEntity = null;
 }
Esempio n. 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SYS_AdminMod model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SYS_Admin(");
            strSql.Append("Username,Password,CustomerSysNo,TS,DR,LastLogin)");
            strSql.Append(" values (");
            strSql.Append("@Username,@Password,@CustomerSysNo,@TS,@DR,@LastLogin)");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlCommand cmd = new SqlCommand(strSql.ToString());
            SqlParameter[] parameters = {
                 new SqlParameter("@Username",SqlDbType.VarChar,100),
                 new SqlParameter("@Password",SqlDbType.VarChar,100),
                 new SqlParameter("@CustomerSysNo",SqlDbType.Int,4),
                 new SqlParameter("@TS",SqlDbType.DateTime),
                 new SqlParameter("@DR",SqlDbType.TinyInt,1),
                 new SqlParameter("@LastLogin",SqlDbType.DateTime),
             };
            if (model.Username != AppConst.StringNull)
                parameters[0].Value = model.Username;
            else
                parameters[0].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[0]);
            if (model.Password != AppConst.StringNull)
                parameters[1].Value = model.Password;
            else
                parameters[1].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[1]);
            if (model.CustomerSysNo != AppConst.IntNull)
                parameters[2].Value = model.CustomerSysNo;
            else
                parameters[2].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[2]);
            if (model.TS != AppConst.DateTimeNull)
                parameters[3].Value = model.TS;
            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.LastLogin != AppConst.DateTimeNull)
                parameters[5].Value = model.LastLogin;
            else
                parameters[5].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[5]);

            return SqlHelper.ExecuteNonQuery(cmd,parameters);
        }
Esempio n. 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     base.Login(base.Request.RawUrl);
     base.CheckPrivilege(base.Request.RawUrl);
     WebForAdmin.Master.AdminMaster m_master = (WebForAdmin.Master.AdminMaster)base.Master;
     m_master.PageName = "权限设置";
     m_master.SetCate(WebForAdmin.Master.AdminMaster.CateType.Privilege3);
     if (!base.IsPostBack)
     {
         this.BindContent();
         SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().GetModel(SysNo);
         Literal1.Text = m_admin.Username + "的权限";
     }
 }
Esempio n. 7
0
 protected void Delete()
 {
     try
     {
         SYS_AdminMod m_customer = SYS_AdminBll.GetInstance().GetModel(int.Parse(base.Request.QueryString["delete"]));
         m_customer.DR = 1;
         SYS_AdminBll.GetInstance().Update(m_customer);
         this.ltrNotice.Text = "该记录已删除!";
         base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
     }
     catch
     {
         this.ltrError.Text = "系统错误,冻结失败!";
         base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('errordiv').style.display='';", true);
     }
 }
Esempio n. 8
0
        public void LoginCheck(string username, string password)
        {
            SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().CheckAdmin(username, password);

            if (m_admin.CustomerSysNo != AppConst.IntNull)//COOKIES验证成功
            {
                WebForAnalyse.SessionInfo m_session = new SessionInfo();
                m_session.AdminEntity           = m_admin;
                m_session.PrivilegeDt           = SYS_AdminBll.GetInstance().GetAdminPrivilege(m_admin.CustomerSysNo);
                Session[AppConfig.AdminSession] = m_session;
                //记住我
                if (CheckBox1.Checked)
                {
                    HttpCookie Cookie = CookiesHelper.GetCookie("upup1000Admin");
                    if (Cookie == null || Cookie.Value == null || Cookie.Value == "")
                    {
                        Cookie = new HttpCookie("upup1000Admin");
                        Cookie.Values.Add("uname", CommonTools.Encode(username));
                        Cookie.Values.Add("psd", CommonTools.Encode(password));
                        //设置Cookie过期时间
                        Cookie.Expires = DateTime.Now.AddYears(50);
                        CookiesHelper.AddCookie(Cookie);
                    }
                    else
                    {
                        CookiesHelper.SetCookie("upup1000Admin", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50));
                        CookiesHelper.SetCookie("upup1000Admin", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50));
                    }
                }
                LogManagement.getInstance().WriteTrace(m_session.AdminEntity, "Login", "IP:" + Request.UserHostAddress + "|AdminID:" + m_session.AdminEntity.Username);
                //跳转
                if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
                {
                    Response.Redirect(Request.QueryString["url"]);
                }
                else
                {
                    Response.Redirect("BaZi/PatternList.aspx");
                }
            }
            else
            {
                this.ltrNotice.Text = "用户名或密码错误!";
                base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('" + divNotice.ClientID + "').style.display='';", true);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>

        public SYS_AdminMod GetModel(int SysNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SysNo, Username, Password, CustomerSysNo, TS, DR, LastLogin from  SYS_Admin");
            strSql.Append(" where SysNo=@SysNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo", SqlDbType.Int, 4)
            };
            parameters[0].Value = SysNo;
            SYS_AdminMod model = new SYS_AdminMod();
            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.Username = ds.Tables[0].Rows[0]["Username"].ToString();
                model.Password = ds.Tables[0].Rows[0]["Password"].ToString();
                if (ds.Tables[0].Rows[0]["CustomerSysNo"].ToString() != "")
                {
                    model.CustomerSysNo = int.Parse(ds.Tables[0].Rows[0]["CustomerSysNo"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TS"].ToString() != "")
                {
                    model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].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]["LastLogin"].ToString() != "")
                {
                    model.LastLogin = DateTime.Parse(ds.Tables[0].Rows[0]["LastLogin"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            try
            {
                SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().GetModel(GetSession().AdminEntity.SysNo);
                if (txtOldPsd.Text.Trim() == m_admin.Password)
                {
                    if (txtNewPsd.Text.Trim() == txtNewAgain.Text.Trim())
                    {
                        m_admin.Password = txtNewPsd.Text.Trim();
                        SYS_AdminBll.GetInstance().Update(m_admin);

                        ltrNotice.Text = "密码修改成功!";
                        masternoticediv.Style["display"] = "";
                    }
                    else
                    {
                        ltrError.Text = "两次密码输入不一致,请重新输入!";
                        mastererrordiv.Style["display"] = "";
                    }
                }
                else
                {
                    ltrError.Text = "旧密码错误,请重新输入!";
                    mastererrordiv.Style["display"] = "";
                }
            }
            catch
            {
                ltrError.Text = "系统错误,密码修改失败!";
                mastererrordiv.Style["display"] = "";
            }
            finally
            {
                txtOldPsd.Text   = "";
                txtNewAgain.Text = "";
                txtNewPsd.Text   = "";
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "closeforseconds();", true);
            }
        }
Esempio n. 11
0
 public SYS_AdminMod CheckAdmin(string username, string password)
 {
     SYS_AdminMod model = new SYS_AdminMod();
     using (SQLData data = new SQLData())
     {
         StringBuilder builder = new StringBuilder();
         builder.Append("select SysNo from SYS_Admin where Username='******' and Password='******' and DR=").Append(0);
         try
         {
             model.CustomerSysNo =int.Parse(data.CmdtoDataRow(builder.ToString())["SysNo"].ToString());
         }
         catch (Exception exception)
         {
             //throw exception;
         }
     }
     if (model.CustomerSysNo != -999999)
     {
         model = this.GetModel(model.CustomerSysNo);
         model.LastLogin = DateTime.Now;
         this.Update(model);
     }
     return model;
 }
Esempio n. 12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(SYS_AdminMod model)
 {
     return dal.Add(model);
 }
Esempio n. 13
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(SYS_AdminMod model)
 {
     dal.Update(model);
 }
Esempio n. 14
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(SYS_AdminMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SYS_Admin(");
            strSql.Append("Username,Password,CustomerSysNo,TS,DR,LastLogin)");
            strSql.Append(" values (");
            strSql.Append("@Username,@Password,@CustomerSysNo,@TS,@DR,@LastLogin)");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@Username",      SqlDbType.VarChar,   100),
                new SqlParameter("@Password",      SqlDbType.VarChar,   100),
                new SqlParameter("@CustomerSysNo", SqlDbType.Int,         4),
                new SqlParameter("@TS",            SqlDbType.DateTime),
                new SqlParameter("@DR",            SqlDbType.TinyInt,     1),
                new SqlParameter("@LastLogin",     SqlDbType.DateTime),
            };
            if (model.Username != AppConst.StringNull)
            {
                parameters[0].Value = model.Username;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.Password != AppConst.StringNull)
            {
                parameters[1].Value = model.Password;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                parameters[2].Value = model.CustomerSysNo;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.TS != AppConst.DateTimeNull)
            {
                parameters[3].Value = model.TS;
            }
            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.LastLogin != AppConst.DateTimeNull)
            {
                parameters[5].Value = model.LastLogin;
            }
            else
            {
                parameters[5].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[5]);

            return(SqlHelper.ExecuteNonQuery(cmd, parameters));
        }
Esempio n. 15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public void Update(SYS_AdminMod model)
        {
            dal.Update(model);
        }
Esempio n. 16
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(SYS_AdminMod model)
        {
            return(dal.Add(model));
        }
Esempio n. 17
0
        protected void PrepareForm()
        {
            #region  项绑定
            //drpGender.DataSource = AppEnum.GetGender();
            //drpGender.DataTextField = "Value";
            //drpGender.DataValueField = "Key";
            //drpGender.DataBind();
            //drpGender.SelectedIndex = 2;

            //drpLevel.DataSource = AppEnum.GetCustomerType();
            //drpLevel.DataTextField = "Value";
            //drpLevel.DataValueField = "Key";
            //drpLevel.DataBind();
            //drpLevel.SelectedIndex = 2;
            //drpLevel.Items.Insert(0, new ListItem("请选择会员等级", "0"));

            int tmptotal = 0;
            drpPrivilege.DataSource     = SYS_AdminBll.GetInstance().GetList(1000, 1, "", "", 0, ref tmptotal);
            drpPrivilege.DataTextField  = "NickName";
            drpPrivilege.DataValueField = "SysNo";
            drpPrivilege.DataBind();
            drpPrivilege.Items.Insert(0, new ListItem("选择后台用户", "0"));

            #endregion

            if (type == "ADD")
            {
                if (Request.QueryString["user"] != null && Request.QueryString["user"] != "")
                {
                    try
                    {
                        if (SYS_AdminBll.GetInstance().IsAdmin(int.Parse(Request.QueryString["user"])))
                        {
                            Response.Redirect("../Error.aspx?msg=");
                            return;
                        }
                        txtName.Text = USR_CustomerBll.GetInstance().GetModel(int.Parse(Request.QueryString["user"])).NickName;
                    }
                    catch
                    {
                        Response.Redirect("../Error.aspx?msg=");
                        return;
                    }
                }
                else
                {
                    Response.Redirect("../Error.aspx?msg=");
                    return;
                }
            }
            else if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    try
                    {
                        SysNo = int.Parse(Request.QueryString["id"]);
                        SYS_AdminMod m_cms = SYS_AdminBll.GetInstance().GetModel(SysNo);

                        txtSysNo.Text    = m_cms.SysNo.ToString();
                        txtName.Text     = USR_CustomerBll.GetInstance().GetModel(m_cms.CustomerSysNo).NickName;
                        txtUserName.Text = m_cms.Username;
                        //txtPass.Enabled = false;
                        txtPass.Text = "加密存储";
                        //txtPass.ReadOnly = true;
                    }
                    catch
                    {
                        Response.Redirect("../Error.aspx?msg=");
                        return;
                    }
                }
            }
        }
Esempio n. 18
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SYS_AdminMod model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("update SYS_Admin set ");
     strSql.Append("Username=@Username,");
     strSql.Append("Password=@Password,");
     strSql.Append("CustomerSysNo=@CustomerSysNo,");
     strSql.Append("TS=@TS,");
     strSql.Append("DR=@DR,");
     strSql.Append("LastLogin=@LastLogin");
     strSql.Append(" where SysNo=@SysNo ");
     SqlCommand cmd = new SqlCommand(strSql.ToString());
     SqlParameter[] parameters = {
          new SqlParameter("@SysNo",SqlDbType.Int,4),
          new SqlParameter("@Username",SqlDbType.VarChar,100),
          new SqlParameter("@Password",SqlDbType.VarChar,100),
          new SqlParameter("@CustomerSysNo",SqlDbType.Int,4),
          new SqlParameter("@TS",SqlDbType.DateTime),
          new SqlParameter("@DR",SqlDbType.TinyInt,1),
          new SqlParameter("@LastLogin",SqlDbType.DateTime)
      };
     if (model.SysNo != AppConst.IntNull)
         parameters[0].Value = model.SysNo;
     else
         parameters[0].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[0]);
     if (model.Username != AppConst.StringNull)
         parameters[1].Value = model.Username;
     else
         parameters[1].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[1]);
     if (model.Password != AppConst.StringNull)
         parameters[2].Value = model.Password;
     else
         parameters[2].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[2]);
     if (model.CustomerSysNo != AppConst.IntNull)
         parameters[3].Value = model.CustomerSysNo;
     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.DR != AppConst.IntNull)
         parameters[5].Value = model.DR;
     else
         parameters[5].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[5]);
     if (model.LastLogin != AppConst.DateTimeNull)
         parameters[6].Value = model.LastLogin;
     else
         parameters[6].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[6]);
     return SqlHelper.ExecuteNonQuery(cmd,parameters);
 }
Esempio n. 19
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SYS_AdminMod GetModel(int SysNo)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select SysNo, Username, Password, CustomerSysNo, TS, DR, LastLogin from  SYS_Admin");
     strSql.Append(" where SysNo=@SysNo ");
     SqlParameter[] parameters = {
     new SqlParameter("@SysNo", SqlDbType.Int,4 )
      		};
     parameters[0].Value = SysNo;
     SYS_AdminMod model = new SYS_AdminMod();
     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.Username = ds.Tables[0].Rows[0]["Username"].ToString();
         model.Password = ds.Tables[0].Rows[0]["Password"].ToString();
         if (ds.Tables[0].Rows[0]["CustomerSysNo"].ToString() != "")
         {
             model.CustomerSysNo = int.Parse(ds.Tables[0].Rows[0]["CustomerSysNo"].ToString());
         }
         if (ds.Tables[0].Rows[0]["TS"].ToString() != "")
         {
             model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].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]["LastLogin"].ToString() != "")
         {
             model.LastLogin = DateTime.Parse(ds.Tables[0].Rows[0]["LastLogin"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Esempio n. 20
0
        protected void Unnamed3_Click(object sender, EventArgs e)
        {
            SYS_AdminMod m_supplier = new SYS_AdminMod();
            if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    SysNo = int.Parse(Request.QueryString["id"]);
                }
                m_supplier = SYS_AdminBll.GetInstance().GetModel(SysNo);
            }
            if (txtUserName.Text.Trim() == "")
            {
                ltrError.Text = "请填写用户登录名!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            if (txtPass.Text.Trim() == "" && type == "ADD")
            {
                ltrError.Text = "请输入初始密码!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            m_supplier.CustomerSysNo = int.Parse(Request.QueryString["user"]);
            m_supplier.Username = txtUserName.Text;

            try
            {
                if (type == "ADD")
                {
                    m_supplier.DR = 0;
                    m_supplier.Password = txtPass.Text;
                    m_supplier.TS = DateTime.Now;
                    m_supplier.LastLogin = DateTime.Now;
                    m_supplier.SysNo = SYS_AdminBll.GetInstance().Add(m_supplier);

                    SetPrivilege(m_supplier.SysNo);
                    LogManagement.getInstance().WriteTrace(m_supplier.SysNo, "Article.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
                }
                else if (type == "EDIT")
                {
                    if (txtPass.Text.Trim() != "加密存储")
                    {
                        m_supplier.Password = txtPass.Text;
                    }
                    SYS_AdminBll.GetInstance().Update(m_supplier);
                    SetPrivilege(m_supplier.SysNo);
                    LogManagement.getInstance().WriteTrace(m_supplier.SysNo, "Article.Edit", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
                }
                ltrNotice.Text = "该记录已保存成功!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
            }
            catch (Exception ex)
            {
                ltrError.Text = "系统错误,保存失败!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                LogManagement.getInstance().WriteException(ex, "Article.Save", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public int Update(SYS_AdminMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SYS_Admin set ");
            strSql.Append("Username=@Username,");
            strSql.Append("Password=@Password,");
            strSql.Append("CustomerSysNo=@CustomerSysNo,");
            strSql.Append("TS=@TS,");
            strSql.Append("DR=@DR,");
            strSql.Append("LastLogin=@LastLogin");
            strSql.Append(" where SysNo=@SysNo ");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo",         SqlDbType.Int,         4),
                new SqlParameter("@Username",      SqlDbType.VarChar,   100),
                new SqlParameter("@Password",      SqlDbType.VarChar,   100),
                new SqlParameter("@CustomerSysNo", SqlDbType.Int,         4),
                new SqlParameter("@TS",            SqlDbType.DateTime),
                new SqlParameter("@DR",            SqlDbType.TinyInt,     1),
                new SqlParameter("@LastLogin",     SqlDbType.DateTime)
            };
            if (model.SysNo != AppConst.IntNull)
            {
                parameters[0].Value = model.SysNo;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.Username != AppConst.StringNull)
            {
                parameters[1].Value = model.Username;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.Password != AppConst.StringNull)
            {
                parameters[2].Value = model.Password;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                parameters[3].Value = model.CustomerSysNo;
            }
            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.DR != AppConst.IntNull)
            {
                parameters[5].Value = model.DR;
            }
            else
            {
                parameters[5].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[5]);
            if (model.LastLogin != AppConst.DateTimeNull)
            {
                parameters[6].Value = model.LastLogin;
            }
            else
            {
                parameters[6].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[6]);
            return(SqlHelper.ExecuteNonQuery(cmd, parameters));
        }