コード例 #1
0
        public InventoryManagement(Form callingForm)
        {
            main = callingForm as MainScreen;
            InitializeComponent();
            LoadDataByResetButton();
            Color c = Color.FromArgb(0, 189, 69);

            ChangeColor(c);
            dgvTonKho.RowTemplate.Resizable = DataGridViewTriState.True;
            dgvTonKho.RowTemplate.Height    = 50;
        }
コード例 #2
0
ファイル: Products.cs プロジェクト: luan51900761/Pham_Luan
        public Products(Form callingForm)
        {
            main = callingForm as MainScreen;
            InitializeComponent();
            LoadDataByResetButton();
            Color c = Color.FromArgb(0, 189, 69);

            ChangeColor(c);
            dataGridViewListProduct.RowTemplate.Resizable = DataGridViewTriState.True;
            dataGridViewListProduct.RowTemplate.Height    = 50;
        }
コード例 #3
0
ファイル: login.cs プロジェクト: luan51900761/Pham_Luan
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (rd_Admin.Checked == true)
            {
                try
                {
                    string      password = Script.MD5Hash(txtPassword.Text);
                    string      connect  = "data source=DESKTOP-BELSK30\\HOST;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework";
                    DBContextSV db       = new DBContextSV(connect);

                    var result = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password);

                    if (result != null)
                    {
                        if (result.nhanvien.chucvu != "ADMIN")
                        {
                            MessageBox.Show("Bạn không có quyền truy cập");
                        }
                        else
                        {
                            Program.connectionString = connect;
                            if (cb_cn.Text == "Chi Nhánh 1")
                            {
                                Program.station = "CN01";
                            }
                            else if (cb_cn.Text == "Chi Nhánh 2")
                            {
                                Program.station = "CN02";
                            }
                            else
                            {
                                Program.station = "CN01";
                            }
                            Program.idLoged = txtUsername.Text;
                            MainScreen ms = new MainScreen();
                            ms.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Đăng nhập thất bại");
                    }
                }
                catch
                {
                    MessageBox.Show("Đăng nhập thất bại");
                }
            }
            else
            {
                if (cb_cn.Text != "" && txtPassword.Text != "" && txtUsername.Text != "")
                {
                    if (cb_cn.Text == "Chi Nhánh 1")
                    {
                        try
                        {
                            string      password = Script.MD5Hash(txtPassword.Text);
                            string      connect  = "data source=DESKTOP-BELSK30\\STORE1;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework";
                            DBContextSV db       = new DBContextSV(connect);
                            var         result   = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password);
                            if (result != null)
                            {
                                Program.connectionString = connect;
                                Program.station          = "CN01";
                                Program.idLoged          = txtUsername.Text;
                                MainScreen ms = new MainScreen();
                                ms.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("Đăng nhập thất bại");
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Đăng nhập thất bại");
                        }
                    }
                    else
                    {
                        try
                        {
                            string      password = Script.MD5Hash(txtPassword.Text);
                            string      connect  = "data source=DESKTOP-BELSK30\\STORE2;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework";
                            DBContextSV db       = new DBContextSV(connect);
                            var         result   = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password);
                            if (result != null)
                            {
                                Program.connectionString = connect;
                                Program.station          = "CN02";
                                Program.idLoged          = txtUsername.Text;
                                MainScreen ms = new MainScreen();
                                ms.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("Đăng nhập thất bại");
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Đăng nhập thất bại");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin");
                }
            }
        }