Esempio n. 1
0
        //lcy
        public static List <AdminsMDL> Getlist(AdminsMDL a)
        {
            string sql = "select * from admins where 1=1";
            List <SqlParameter> list  = new List <SqlParameter>();
            List <AdminsMDL>    list1 = new List <AdminsMDL>();

            if (a != null)
            {
                if (a.userid > 0)
                {
                    sql += " and userid=@userid";
                    list.Add(new SqlParameter("@username", a.UserName));
                }
            }
            using (SqlDataReader sda = DBhelper.MySqlDataReader(sql, list.ToArray()))
            {
                while (sda.Read())
                {
                    AdminsMDL ad = new AdminsMDL();
                    ad.userid           = Convert.ToInt32(sda[0]);
                    ad.UserName         = sda[1].ToString();
                    ad.UserCompellation = sda[3].ToString();
                    list1.Add(ad);
                }
                return(list1);
            }
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox2.Text == "")
     {
         new Warning("信息填写不完整", 图标.Erro).Show();
         return;
     }
     try
     {
         AdminsMDL ad = new AdminsMDL();
         ad.userid           = AdminsMDL.USERID;
         ad.UserName         = textBox1.Text;
         ad.UserCompellation = textBox2.Text;
         int i = AdminsBLL.updateadmin(ad);
         if (i > 0)
         {
             this.Close();
         }
         else
         {
             MessageBox.Show("修改失败");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("发生未只的异常,请联系开发者", "未知异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 3
0
        public static int deleteadmin(AdminsMDL a)
        {
            string sql = "delete from admins where userid=@userid";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@userid", a.userid));
            return(DBhelper.MyExecuteNonQuery(sql, list.ToArray()));
        }
Esempio n. 4
0
        public static int insertadmin(AdminsMDL ad)
        {
            string sql = "insert into admins values(@username,@userpwd,@usercompellation,1,1,1,1)";

            SqlParameter[] spt = { new SqlParameter("@username",         ad.UserName),
                                   new SqlParameter("@userpwd",          ad.UserPWD),
                                   new SqlParameter("@usercompellation", ad.UserCompellation) };
            return(DBhelper.MyExecuteNonQuery(sql, spt));
        }
Esempio n. 5
0
        public static string selectpwd(AdminsMDL a)
        {
            string sql = "select usercompellation from admins where username=@username and userpwd=@userpwd";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@username", a.UserName));
            list.Add(new SqlParameter("@userpwd", a.UserPWD));
            return(DBhelper.MyExecuteScalar(sql, list.ToArray()).ToString());
        }
Esempio n. 6
0
        public static int updatepwd(AdminsMDL a, AdminsMDL aa)
        {
            string sql = "update admins set userpwd=@Uerpwd where username=@username and userpwd=@Userpwd";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@username", a.UserName));
            list.Add(new SqlParameter("@userpwd", a.UserPWD));
            list.Add(new SqlParameter("@Uerpwd", aa.UserPWD));
            return(DBhelper.MyExecuteNonQuery(sql, list.ToArray()));
        }
Esempio n. 7
0
        public static int logintype(AdminsMDL a)
        {
            string sql = "update admins set LoginType=@logintype where username=@username ";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@username", a.UserName));

            list.Add(new SqlParameter("@logintype", a.LoginType));
            return(Convert.ToInt32(DBhelper.MyExecuteNonQuery(sql, list.ToArray())));
        }
Esempio n. 8
0
        public static int updateadmin(AdminsMDL a)
        {
            string sql = "update admins set username=@username,usercompellation=@usercompellation where userid=@userid";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@username", a.UserName));
            list.Add(new SqlParameter("@usercompellation", a.UserCompellation));
            list.Add(new SqlParameter("@userid", a.userid));
            return(DBhelper.MyExecuteNonQuery(sql, list.ToArray()));
        }
Esempio n. 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username = txtUser.Text;
            string userpwd  = txtPwd.Text;

            if (username == "请输入用户名")
            {
                new Warning("请输入用户名", 图标.Erro).Show();


                //MessageBox.Show("请输入账号!");
                return;
            }
            if (userpwd == "")
            {
                new Warning("请输入密码", 图标.Erro).Show();
                return;
            }
            try
            {
                List <AdminsMDL> list = AdminsBLL.GetLogin(username);
                if (list.Count > 0)
                {
                    if (list[0].LoginType == 1)
                    {
                        //登录成功

                        admins.UserCompellation = list[0].UserCompellation;
                        admins.name             = list[0].UserName;
                        admins.id     = list[0].headID;
                        admins.UserId = list[0].userid;
                        AdminsMDL a = new AdminsMDL();
                        a.LoginType = 2;
                        a.UserName  = username;
                        AdminsBLL.logintype(a);
                        FrmMain f = new FrmMain();
                        f.Show();
                        this.Hide();
                    }
                    else if (list[0].LoginType == 2)
                    {
                        new Warning("请勿重复登录", 图标.Erro).Show();
                    }
                }
                else
                {
                    new Warning("密码错误", 图标.Erro).Show();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("发生未只的异常,请联系开发者", "未知异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            //主窗体关闭事件
            AdminsMDL a = new AdminsMDL();

            a.LoginType = 1;
            a.UserName  = admins.name;

            AdminsBLL.logintype(a);
            Application.Exit();
        }
Esempio n. 11
0
        private void pictureBox7_Click(object sender, EventArgs e)
        {
            //锁定
            AdminsMDL a = new AdminsMDL();

            a.LoginType = 1;
            a.UserName  = admins.name;

            AdminsBLL.logintype(a);
            this.Hide();
            new FrmLogin().Show();
        }
Esempio n. 12
0
 private void button17_Click(object sender, EventArgs e)
 {
     if (listView4.SelectedItems.Count > 0)
     {
         if (listView4.SelectedItems[0].SubItems[0].Text == admins.UserId.ToString())
         {
             new Warning("不能删除当前用户", 图标.Erro).Show();
             return;
         }
         AdminsMDL ad = new AdminsMDL();
         ad.userid = Convert.ToInt32(listView4.SelectedItems[0].SubItems[0].Text);
         AdminsBLL.deleteadmin(ad);
         panel4_VisibleChanged(null, null);
     }
 }
Esempio n. 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            string a  = textBox1.Text;
            string a1 = textBox2.Text;
            string a2 = textBox3.Text;
            string a3 = textBox4.Text;

            if (a == "" || a1 == "" || a2 == "" || a3 == "")
            {
                new Warning("信息填写不完整", 图标.Erro).Show();
                return;
            }
            if (a2 != a3)
            {
                new Warning("两次输入密码不一致", 图标.Erro).Show();
                return;
            }
            try
            {
                AdminsMDL ad = new AdminsMDL();
                ad.UserName = a;
                ad.UserPWD  = a1;
                string aa = AdminsBLL.selectpwd(ad);
                if (aa == "")
                {
                    new Warning("用户名不存在", 图标.Erro).Show();
                    return;
                }
                AdminsMDL am = new AdminsMDL();
                am.UserPWD = a2;
                int b = AdminsBLL.updatepwd(ad, am);
                if (b > 0)
                {
                    new Warning("密码修改成功", 图标.Yes).Show();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("修改失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            string UserName         = textBox1.Text;
            string UserPWD          = textBox2.Text;
            string userpwd          = textBox3.Text;
            string UserCompellation = textBox4.Text;

            if (UserName == "" || UserPWD == "" || userpwd == "" || UserCompellation == "")
            {
                new Warning("信息填写不完整", 图标.Erro).Show();
                return;
            }
            if (UserPWD != userpwd)
            {
                new Warning("两次密码填写不一致,请重新填写", 图标.Erro).Show();
                return;
            }
            try
            {
                AdminsMDL ad = new AdminsMDL();
                ad.UserName         = textBox1.Text;
                ad.UserPWD          = textBox2.Text;
                ad.UserCompellation = textBox4.Text;
                int i = AdminsBLL.insertadmin(ad);
                if (i > 0)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("发生未只的异常,请联系开发者", "未知异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 15
0
        public static List <AdminsMDL> GetLogin(string user)
        {
            string sql = "select * from admins where Username=@username";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@username", user));

            SqlDataReader    dr = DBhelper.MySqlDataReader(sql, list.ToArray());
            List <AdminsMDL> ad = new List <AdminsMDL>();

            while (dr.Read())
            {
                AdminsMDL adm = new AdminsMDL();
                adm.userid           = Convert.ToInt32(dr[0]);
                adm.UserName         = dr[1].ToString();
                adm.UserPWD          = dr[2].ToString();
                adm.UserCompellation = dr[3].ToString();
                adm.LoginType        = Convert.ToInt32(dr[6]);
                adm.headID           = Convert.ToInt32(dr[7]);
                ad.Add(adm);
            }
            dr.Close();
            return(ad);
        }
Esempio n. 16
0
 public static int deleteadmin(AdminsMDL a)
 {
     return(AdminsDAL.deleteadmin(a));
 }
Esempio n. 17
0
 public static int updateadmin(AdminsMDL a)
 {
     return(AdminsDAL.updateadmin(a));
 }
Esempio n. 18
0
 public static int insertadmin(AdminsMDL a)
 {
     return(AdminsDAL.insertadmin(a));
 }
Esempio n. 19
0
 //lcy
 public static List <AdminsMDL> getlist(AdminsMDL a)
 {
     return(AdminsDAL.Getlist(a));
 }
Esempio n. 20
0
 public static int updatepwd(AdminsMDL aa, AdminsMDL am)
 {
     return(AdminsDAL.updatepwd(aa, am));
 }
Esempio n. 21
0
 public static string selectpwd(AdminsMDL a)
 {
     return(AdminsDAL.selectpwd(a));
 }
Esempio n. 22
0
 public static int logintype(AdminsMDL a)
 {
     return(AdminsDAL.logintype(a));
 }