コード例 #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmManager fM = new frmManager();

            fM.MdiParent = this;
            fM.Show();
        }
コード例 #2
0
        //Perform login. Gets data from view and calls model.
        public bool Login()
        {
            string EmpID    = View.EmpID;
            string Password = View.Password;
            int    RoleID;
            bool   IsValid = false;

            EmployeeModel Employee = Model.CheckLogin(EmpID, Password);

            if (Employee != null)
            {
                RoleID = Employee.RoleID;
                RoleModel Role = Model.GetRole(RoleID);

                string RoleName = Role.RoleName;

                switch (RoleName)
                {
                case "Manager":
                    frmManager frmManager = new frmManager(Employee);
                    frmManager.ShowDialog();
                    break;

                case "Employee":
                    frmAddOrder frmAddOrder = new frmAddOrder(EmpID);
                    frmAddOrder.ShowDialog();
                    break;
                }
                IsValid = true;
            }

            return(IsValid);
        }
コード例 #3
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            using (var contexto = new ContextSqlite())
            {
                sqliteuser = contexto.SqliteUsers.Find(Cripto.Encrypt(txtLogin.Text));
                if (sqliteuser == null)
                {
                    XtraMessageBox.Show("Usuário e/ou senha inválidos ", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (txtPassword.Text != Cripto.Decrypt(sqliteuser.Password))
                {
                    XtraMessageBox.Show("Usuário e/ou senha inválidos ", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                servTest  = (Cripto.Decrypt(sqliteuser.LastBase) == "T");
                loginUser = Cripto.Decrypt(sqliteuser.Login);
                var _permissions = Cripto.Decrypt(sqliteuser.Permissions);
                permissions = _permissions.Substring(_permissions.IndexOf("[") + 1, 5);
                //XtraMessageBox.Show(permissions, "Permissões", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                administrator = permissions.Substring(0, 1) == "S";
                warehouse     = permissions.Substring(1, 1) == "S";


                if (!File.Exists(Directory.GetCurrentDirectory() + @"\Data\config.db"))
                {
                    File.Copy(Directory.GetCurrentDirectory() + @"\sqlite.dll", Directory.GetCurrentDirectory() + @"\Data\config.db", true);
                }
                //servTest = false;
                //loginUser = "******";

                //this.Hide();
                frmManager frm = new frmManager();
                frm.Show();
            }
        }
コード例 #4
0
ファイル: frmLogin.cs プロジェクト: wiwatch/VRUBookShop64
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // ตรวจสอบการป้อนข้อมูล
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("ป้อนข้อมูลให้ครับก่อน", "ผิดพลาด",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // มีการป้อนข้อมูลแล้ว นำ username, password ไปตรวจสอบกับข้อมูลในตาราง
            string connectionString = "server=.\\sqlexpress;database=dbBookShop;integrated security=true";

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                // MessageBox.Show("connect ok");
                // คลาสที่ใช้งานในการ SELECT ข้อมูล sqlDataAdapter, DataTable, คำสั่ง SQL
                //     string sql = "SELECT * FROM tbEmployee WHERE  Username='******' AND Password='******' ";
                string         sql = "SELECT * FROM tbEmployee WHERE Username=@Username AND Password=@Password";
                SqlDataAdapter da  = new SqlDataAdapter(sql, con);
                da.SelectCommand.Parameters.AddWithValue("@Username", txtUsername.Text);
                da.SelectCommand.Parameters.AddWithValue("@Password", txtPassword.Text);
                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count < 1)
                {
                    MessageBox.Show("ไม่พบข้อมูล", "ผิดพลาด",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // กรณีพบข้อมูล ตรวจสอบสถานะผู้ใช้งาน
                if (dt.Rows[0]["PosID"].ToString() == "1")
                {
                    // MessageBox.Show("พนักงานขาย");
                    frmSaleMenu frm = new frmSaleMenu(dt.Rows[0]["EmpName"].ToString(), dt.Rows[0]["EmpID"].ToString());
                    frm.Show();
                    this.Hide();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "2")
                {
                    // MessageBox.Show("พนักงานคลังสินค้า");
                    int      EmpID = int.Parse(dt.Rows[0]["EmpID"].ToString());
                    frmStock frm   = new frmStock(EmpID);
                    frm.Show();
                    this.Hide();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "3")
                {
                    //  MessageBox.Show("ผู้จัดการร้าน");
                    frmManager frm = new frmManager();
                    frm.Show();
                }
                else if (dt.Rows[0]["PosID"].ToString() == "4")
                {
                    /// MessageBox.Show("ผู้ดูแลระบบ");
                    frmAdmin frm = new frmAdmin(dt.Rows[0]["EmpName"].ToString());
                    frm.Show();
                }
            }
        }
コード例 #5
0
        private void btnManagerAccount_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmManager account = new frmManager();

            account.ShowDialog();
        }
コード例 #6
0
        private void buttonIn_Click(object sender, EventArgs e)
        {
            string          constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\DatabaseC#.accdb";
            OleDbConnection conn   = new OleDbConnection(constr);

            conn.Open();
            if (tBID.Text == "" && tBPassword.Text != "")
            {
                MessageBox.Show("请输入用户名");
            }
            if (tBPassword.Text == "" && tBID.Text != "")
            {
                MessageBox.Show("请输入密码");
            }
            if (tBID.Text == "" && tBPassword.Text == "")
            {
                MessageBox.Show("请输入用户名和密码");
            }
            else
            {
                if (rBStu.Checked == false && rBMG.Checked == false && rBTch.Checked == false)
                {
                    MessageBox.Show("请选择登录身份");
                }
                else
                {
                    if (rBStu.Checked == true)
                    {
                        string          cstr = "select * from 登录 where 用户名='" + tBID.Text.Trim() + "'and 密码=" + tBPassword.Text.Trim() + "and 属性=1";
                        OleDbCommand    comm = new OleDbCommand(cstr, conn);
                        OleDbDataReader dr   = comm.ExecuteReader();
                        if (dr.Read())
                        {
                            Num = tBID.Text.Trim();
                            this.Hide();
                            stu = new frmstudent();
                            string           SQL   = "select 课程编号,课程名称,教师姓名,学分 from 课程,教师 where 课程.教师编号=教师.教师编号";
                            DataSet          myds  = new DataSet();
                            OleDbDataAdapter adper = new OleDbDataAdapter(SQL, conn);
                            adper.Fill(myds);
                            stu.dataGridView1.AllowUserToAddRows = false;
                            stu.dataGridView1.DataSource         = myds.Tables[0];
                            stu.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码输入错误,请重新输入!");
                            tBID.Text       = "";
                            tBPassword.Text = "";
                        }
                    }
                    if (rBMG.Checked == true)
                    {
                        string          cstr = "select * from 登录 where 用户名='" + tBID.Text.Trim() + "'and 密码=" + tBPassword.Text.Trim() + "and 属性=3";
                        OleDbCommand    comm = new OleDbCommand(cstr, conn);
                        OleDbDataReader dr   = comm.ExecuteReader();
                        if (dr.Read())
                        {
                            Num = tBID.Text.Trim();
                            this.Hide();
                            mge = new frmManager();
                            string mypath = Application.StartupPath + "\\DatabaseC#.accdb";
                            constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + mypath;
                            OleDbConnection  con    = new OleDbConnection(constr);
                            string           mysql  = "select 学号,学生姓名,班级,联系方式,密码,民族,出生年月 from 学生,登录 where 学生.学号=登录.用户名";
                            OleDbDataAdapter myada1 = new OleDbDataAdapter(mysql, con);
                            DataSet          myds   = new DataSet();
                            myada1.Fill(myds);
                            mge.dataGridViewStu.DataSource = myds.Tables[0].DefaultView;
                            mge.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码输入错误,请重新输入!");
                            tBID.Text       = "";
                            tBPassword.Text = "";
                        }
                    }
                    if (rBTch.Checked == true)
                    {
                        string          cstr = "select * from 登录 where 用户名='" + tBID.Text.Trim() + "'and 密码=" + tBPassword.Text.Trim() + "and 属性=2";
                        OleDbCommand    comm = new OleDbCommand(cstr, conn);
                        OleDbDataReader dr   = comm.ExecuteReader();
                        if (dr.Read())
                        {
                            Num = tBID.Text.Trim();
                            this.Hide();
                            tea = new frmTeacher();
                            tea.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码输入错误,请重新输入!");
                            tBID.Text       = "";
                            tBPassword.Text = "";
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: Jo-Hunter/BudgCalc
        private void logToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmManager mgr = new frmManager();

            mgr.Show();
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: Jo-Hunter/BudgCalc
        // opens 'adjust budget' window
        private void btnBudget_Click(object sender, EventArgs e)
        {
            frmManager bud = new frmManager();

            bud.ShowDialog();
        }
コード例 #9
0
 /// <summary>
 /// Instancie un nouveau controller associé à une frmManager
 /// </summary>
 /// <param name="view">vue associé au controller</param>
 public frmManagerController(frmManager view)
 {
     Manager = SyndicationManager.getInstance();
     View = view;
 }