예제 #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Login_Click(object sender, EventArgs e)
        {
            try
            {
                ModTS_USER modUser = bllUser.GetModel(txt_Name.Text.Trim(), Common.MD5(txt_Pwd.Text.Trim()));

                if (modUser != null)
                {
                    if (modUser.N_STATUS != 1)
                    {
                        MessageBox.Show("该账号已经冻结,请联系管理员!");
                        return;
                    }

                    UserInfo.userID      = modUser.C_ID;
                    UserInfo.userAccount = modUser.C_ACCOUNT;
                    UserInfo.userName    = modUser.C_NAME;

                    this.DialogResult = DialogResult.OK;
                    //Main frm = new Main();
                    //frm.ShowDialog();
                    //this.Dispose();
                    //this.Close();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModTS_USER GetModel(string C_ACCOUNT, string C_PASSWORD)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select C_ID,C_NAME,C_ACCOUNT,C_PASSWORD,C_EMAIL,C_MOBILE,N_STATUS,N_TYPE,C_DESC,D_LASTLOGINTIME,C_EMP_ID,C_EMP_NAME,D_MOD_DT,C_MOBILE2,C_PHONE,C_SHORTNAME from TS_USER ");
            strSql.Append(" where N_TYPE=2 and  C_ACCOUNT=:C_ACCOUNT and C_PASSWORD=:C_PASSWORD ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ACCOUNT",  OracleDbType.Varchar2, 50),
                new OracleParameter(":C_PASSWORD", OracleDbType.Varchar2, 50)
            };
            parameters[0].Value = C_ACCOUNT;
            parameters[1].Value = C_PASSWORD;

            ModTS_USER model = new ModTS_USER();
            DataSet    ds    = DbHelperOra.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ModTS_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TS_USER(");
            strSql.Append("C_NAME,C_ACCOUNT,C_PASSWORD,C_EMAIL,C_MOBILE,N_STATUS,N_TYPE,C_DESC,D_LASTLOGINTIME,C_EMP_ID,C_EMP_NAME,D_MOD_DT,C_MOBILE2,C_PHONE,C_SHORTNAME)");
            strSql.Append(" values (");
            strSql.Append(":C_NAME,:C_ACCOUNT,:C_PASSWORD,:C_EMAIL,:C_MOBILE,:N_STATUS,:N_TYPE,:C_DESC,:D_LASTLOGINTIME,:C_EMP_ID,:C_EMP_NAME,:D_MOD_DT,:C_MOBILE2,:C_PHONE,:C_SHORTNAME)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_NAME",          OracleDbType.Varchar2, 200),
                new OracleParameter(":C_ACCOUNT",       OracleDbType.Varchar2,  50),
                new OracleParameter(":C_PASSWORD",      OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMAIL",         OracleDbType.Varchar2,  50),
                new OracleParameter(":C_MOBILE",        OracleDbType.Varchar2,  50),
                new OracleParameter(":N_STATUS",        OracleDbType.Int16,      1),
                new OracleParameter(":N_TYPE",          OracleDbType.Int16,      1),
                new OracleParameter(":C_DESC",          OracleDbType.Varchar2,  50),
                new OracleParameter(":D_LASTLOGINTIME", OracleDbType.Date),
                new OracleParameter(":C_EMP_ID",        OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMP_NAME",      OracleDbType.Varchar2,  20),
                new OracleParameter(":D_MOD_DT",        OracleDbType.Date),
                new OracleParameter(":C_MOBILE2",       OracleDbType.Varchar2,  50),
                new OracleParameter(":C_PHONE",         OracleDbType.Varchar2,  50),
                new OracleParameter(":C_SHORTNAME",     OracleDbType.Varchar2, 200)
            };
            parameters[0].Value  = model.C_NAME;
            parameters[1].Value  = model.C_ACCOUNT;
            parameters[2].Value  = model.C_PASSWORD;
            parameters[3].Value  = model.C_EMAIL;
            parameters[4].Value  = model.C_MOBILE;
            parameters[5].Value  = model.N_STATUS;
            parameters[6].Value  = model.N_TYPE;
            parameters[7].Value  = model.C_DESC;
            parameters[8].Value  = model.D_LASTLOGINTIME;
            parameters[9].Value  = model.C_EMP_ID;
            parameters[10].Value = model.C_EMP_NAME;
            parameters[11].Value = model.D_MOD_DT;
            parameters[12].Value = model.C_MOBILE2;
            parameters[13].Value = model.C_PHONE;
            parameters[14].Value = model.C_SHORTNAME;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_Pwd1.Text.Trim()))
                {
                    MessageBox.Show("密码不能为空!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_Pwd2.Text.Trim()))
                {
                    MessageBox.Show("密码不能为空!");
                    return;
                }

                if (txt_Pwd1.Text.Trim() == txt_Pwd2.Text.Trim())
                {
                    ModTS_USER mod = bll.GetModel(UserInfo.userID);
                    if (mod != null)
                    {
                        mod.C_PASSWORD = Common.MD5(txt_Pwd1.Text.Trim()); //密码
                        mod.D_MOD_DT   = ServerTime.timeNow();             //系统操作时间

                        if (bll.Update(mod))
                        {
                            MessageBox.Show("密码修改成功!");
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("两次密码输入不一致!");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #5
0
        private void BindInfo()
        {
            try
            {
                ModTS_USER mod = bll.GetModel(strUserID);
                if (mod != null)
                {
                    txt_UserName.Text  = mod.C_NAME;                //姓名
                    txt_LoginName.Text = mod.C_ACCOUNT;             //登录名
                    txt_Email.Text     = mod.C_EMAIL;               //邮箱
                    txt_Tel.Text       = mod.C_MOBILE;              //电话

                    icbo_State.EditValue = mod.N_STATUS.ToString(); //状态
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #6
0
        private void btn_Reset_Click(object sender, EventArgs e)
        {
            try
            {
                ModTS_USER mod = bll.GetModel(strUserID);
                if (mod != null)
                {
                    mod.C_PASSWORD = Common.MD5("123456"); //密码
                    mod.C_EMP_ID   = UserInfo.userID;      //系统操作人编号
                    mod.C_EMP_NAME = UserInfo.userName;    //系统操作人姓名
                    mod.D_MOD_DT   = ServerTime.timeNow(); //系系统操作时间

                    if (bll.Update(mod))
                    {
                        MessageBox.Show("密码重置成功!");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_UserName.Text.Trim()))
                {
                    MessageBox.Show("姓名不能为空!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_LoginName.Text.Trim()))
                {
                    MessageBox.Show("账号不能为空!");
                    return;
                }

                //if (string.IsNullOrEmpty(txt_Email.Text.Trim()))
                //{
                //    MessageBox.Show("邮箱不能为空!");
                //    return;
                //}

                //if (string.IsNullOrEmpty(txt_Tel.Text.Trim()))
                //{
                //    MessageBox.Show("电话不能为空!");
                //    return;
                //}

                ModTS_USER mod = bll.GetModel(strUserID);
                if (mod != null)
                {
                    mod.C_NAME     = txt_UserName.Text.Trim();              //姓名
                    mod.C_EMAIL    = txt_Email.Text.Trim();                 //邮箱
                    mod.C_MOBILE   = txt_Tel.Text.Trim();                   //电话
                    mod.N_STATUS   = Convert.ToInt32(icbo_State.EditValue); //状态(1正常,2,3,4冻结)
                    mod.C_EMP_ID   = UserInfo.userID;                       //系统操作人编号
                    mod.C_EMP_NAME = UserInfo.userName;                     //系统操作人姓名
                    mod.D_MOD_DT   = ServerTime.timeNow();                  //系系统操作时间

                    if (bll.Update(mod))
                    {
                        if (!string.IsNullOrEmpty(btnEdit_Dept.Text.Trim()))
                        {
                            BllTS_USER_DEPT bllUserDept = new BllTS_USER_DEPT();

                            ModTS_USER_DEPT model = bllUserDept.Get_Model(strUserID);
                            if (model != null)
                            {
                                model.C_DEPT_ID = strDeptID;
                                bllUserDept.Update(model);
                            }
                            else
                            {
                                model           = new ModTS_USER_DEPT();
                                model.C_DEPT_ID = strDeptID;
                                model.C_USER_ID = strUserID;

                                bllUserDept.Add(model);
                            }
                        }

                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                BllTS_USER bll = new BllTS_USER();

                if (string.IsNullOrEmpty(txt_UserName.Text.Trim()))
                {
                    MessageBox.Show("姓名不能为空!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_LoginName.Text.Trim()))
                {
                    MessageBox.Show("账号不能为空!");
                    return;
                }
                else
                {
                    if (bll.Exists(txt_LoginName.Text.Trim()))
                    {
                        MessageBox.Show("该账号已存在,不能重复添加!");
                        return;
                    }
                }

                //if (string.IsNullOrEmpty(txt_Email.Text.Trim()))
                //{
                //    MessageBox.Show("邮箱不能为空!");
                //    return;
                //}

                //if (string.IsNullOrEmpty(txt_Tel.Text.Trim()))
                //{
                //    MessageBox.Show("电话不能为空!");
                //    return;
                //}

                ModTS_USER mod = new ModTS_USER();
                mod.C_NAME     = txt_UserName.Text.Trim();  //姓名
                mod.C_ACCOUNT  = txt_LoginName.Text.Trim(); //登录名
                mod.C_PASSWORD = Common.MD5("123456");      //密码
                mod.C_EMAIL    = txt_Email.Text.Trim();     //邮箱
                mod.C_MOBILE   = txt_Tel.Text.Trim();       //电话
                mod.N_TYPE     = 3;                         //用户类型(1内部,2新用户,3PCI用户)
                mod.N_STATUS   = 1;                         //状态(1正常,2,3,4冻结)
                mod.C_EMP_ID   = UserInfo.userID;           //系统操作人编号
                mod.C_EMP_NAME = UserInfo.userName;         //系统操作人姓名
                mod.D_MOD_DT   = ServerTime.timeNow();      //系系统操作时间

                if (bll.Add(mod))
                {
                    txt_UserName.Text  = "";
                    txt_LoginName.Text = "";
                    txt_Email.Text     = "";
                    txt_Tel.Text       = "";

                    if (!string.IsNullOrEmpty(btnEdit_Dept.Text.Trim()))
                    {
                        BllTS_USER_DEPT bllUserDept = new BllTS_USER_DEPT();

                        ModTS_USER_DEPT model = new ModTS_USER_DEPT();
                        model.C_DEPT_ID = strDeptID;
                        model.C_USER_ID = mod.C_ACCOUNT;
                        bllUserDept.Add(model);
                    }

                    MessageBox.Show("添加成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ModTS_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TS_USER set ");
            strSql.Append("C_NAME=:C_NAME,");
            strSql.Append("C_ACCOUNT=:C_ACCOUNT,");
            strSql.Append("C_PASSWORD=:C_PASSWORD,");
            strSql.Append("C_EMAIL=:C_EMAIL,");
            strSql.Append("C_MOBILE=:C_MOBILE,");
            strSql.Append("N_STATUS=:N_STATUS,");
            strSql.Append("N_TYPE=:N_TYPE,");
            strSql.Append("C_DESC=:C_DESC,");
            strSql.Append("D_LASTLOGINTIME=:D_LASTLOGINTIME,");
            strSql.Append("C_EMP_ID=:C_EMP_ID,");
            strSql.Append("C_EMP_NAME=:C_EMP_NAME,");
            strSql.Append("D_MOD_DT=:D_MOD_DT,");
            strSql.Append("C_MOBILE2=:C_MOBILE2,");
            strSql.Append("C_PHONE=:C_PHONE,");
            strSql.Append("C_SHORTNAME=:C_SHORTNAME");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_NAME",          OracleDbType.Varchar2, 200),
                new OracleParameter(":C_ACCOUNT",       OracleDbType.Varchar2,  50),
                new OracleParameter(":C_PASSWORD",      OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMAIL",         OracleDbType.Varchar2,  50),
                new OracleParameter(":C_MOBILE",        OracleDbType.Varchar2,  50),
                new OracleParameter(":N_STATUS",        OracleDbType.Int16,      1),
                new OracleParameter(":N_TYPE",          OracleDbType.Int16,      1),
                new OracleParameter(":C_DESC",          OracleDbType.Varchar2,  50),
                new OracleParameter(":D_LASTLOGINTIME", OracleDbType.Date),
                new OracleParameter(":C_EMP_ID",        OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMP_NAME",      OracleDbType.Varchar2,  20),
                new OracleParameter(":D_MOD_DT",        OracleDbType.Date),
                new OracleParameter(":C_MOBILE2",       OracleDbType.Varchar2,  50),
                new OracleParameter(":C_PHONE",         OracleDbType.Varchar2,  50),
                new OracleParameter(":C_SHORTNAME",     OracleDbType.Varchar2, 200),
                new OracleParameter(":C_ID",            OracleDbType.Varchar2, 50)
            };
            parameters[0].Value  = model.C_NAME;
            parameters[1].Value  = model.C_ACCOUNT;
            parameters[2].Value  = model.C_PASSWORD;
            parameters[3].Value  = model.C_EMAIL;
            parameters[4].Value  = model.C_MOBILE;
            parameters[5].Value  = model.N_STATUS;
            parameters[6].Value  = model.N_TYPE;
            parameters[7].Value  = model.C_DESC;
            parameters[8].Value  = model.D_LASTLOGINTIME;
            parameters[9].Value  = model.C_EMP_ID;
            parameters[10].Value = model.C_EMP_NAME;
            parameters[11].Value = model.D_MOD_DT;
            parameters[12].Value = model.C_MOBILE2;
            parameters[13].Value = model.C_PHONE;
            parameters[14].Value = model.C_SHORTNAME;
            parameters[15].Value = model.C_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModTS_USER DataRowToModel(DataRow row)
        {
            ModTS_USER model = new ModTS_USER();

            if (row != null)
            {
                if (row["C_ID"] != null)
                {
                    model.C_ID = row["C_ID"].ToString();
                }
                if (row["C_NAME"] != null)
                {
                    model.C_NAME = row["C_NAME"].ToString();
                }
                if (row["C_ACCOUNT"] != null)
                {
                    model.C_ACCOUNT = row["C_ACCOUNT"].ToString();
                }
                if (row["C_PASSWORD"] != null)
                {
                    model.C_PASSWORD = row["C_PASSWORD"].ToString();
                }
                if (row["C_EMAIL"] != null)
                {
                    model.C_EMAIL = row["C_EMAIL"].ToString();
                }
                if (row["C_MOBILE"] != null)
                {
                    model.C_MOBILE = row["C_MOBILE"].ToString();
                }
                if (row["N_STATUS"] != null && row["N_STATUS"].ToString() != "")
                {
                    model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString());
                }
                if (row["N_TYPE"] != null && row["N_TYPE"].ToString() != "")
                {
                    model.N_TYPE = decimal.Parse(row["N_TYPE"].ToString());
                }
                if (row["C_DESC"] != null)
                {
                    model.C_DESC = row["C_DESC"].ToString();
                }
                if (row["D_LASTLOGINTIME"] != null && row["D_LASTLOGINTIME"].ToString() != "")
                {
                    model.D_LASTLOGINTIME = DateTime.Parse(row["D_LASTLOGINTIME"].ToString());
                }
                if (row["C_EMP_ID"] != null)
                {
                    model.C_EMP_ID = row["C_EMP_ID"].ToString();
                }
                if (row["C_EMP_NAME"] != null)
                {
                    model.C_EMP_NAME = row["C_EMP_NAME"].ToString();
                }
                if (row["D_MOD_DT"] != null && row["D_MOD_DT"].ToString() != "")
                {
                    model.D_MOD_DT = DateTime.Parse(row["D_MOD_DT"].ToString());
                }
                if (row["C_MOBILE2"] != null)
                {
                    model.C_MOBILE2 = row["C_MOBILE2"].ToString();
                }
                if (row["C_PHONE"] != null)
                {
                    model.C_PHONE = row["C_PHONE"].ToString();
                }
                if (row["C_SHORTNAME"] != null)
                {
                    model.C_SHORTNAME = row["C_SHORTNAME"].ToString();
                }
            }
            return(model);
        }
예제 #11
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ModTS_USER model)
 {
     return(dal.Update(model));
 }
예제 #12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ModTS_USER model)
 {
     return(dal.Add(model));
 }