Exemplo n.º 1
0
 private void tabControl1_Selected(object sender, TabControlEventArgs e)
 {
     if (tabControl1.SelectedIndex == 1)
     {
         FormNV fnv = new FormNV();
         fnv.ShowDialog();
     }
     if (tabControl1.SelectedIndex == 2)
     {
         FormKhachHang fkh = new FormKhachHang();
         fkh.ShowDialog();
     }
     if (tabControl1.SelectedIndex == 3)
     {
         FormSanPham fsp = new FormSanPham();
         fsp.ShowDialog();
     }
     if (tabControl1.SelectedIndex == 4)
     {
         FormLoaiSP f = new FormLoaiSP();
         f.ShowDialog();
     }
     if (tabControl1.SelectedIndex == 5)
     {
         FormHoaDon fdh = new FormHoaDon();
         fdh.ShowDialog();
     }
     //if(tabControl1.SelectedIndex==6)
     //{
     //    FormThongKe tk = new FormThongKe();
     //    tk.ShowDialog();
     //}
 }
Exemplo n.º 2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Trim() == "")
            {
                MessageBox.Show("Tài khoản đăng nhập không được trống", "", MessageBoxButtons.OK);
                return;
            }

            DBMain.mlogin   = txtUser.Text.Trim();
            DBMain.password = txtPass.Text;
            if (DBMain.KetNoi() == 0)
            {
                return;
            }
            // 0 - trả về chi nhánh hiện tại
            SqlDataReader myReader;

            DBMain.mChinhanh = cbServer.SelectedIndex;
            //DBMain.bds_dspm = ds;

            DBMain.mloginDN   = DBMain.mlogin;
            DBMain.passwordDN = DBMain.password;
            string strLenh = "exec KiemTraDangNhap '" + DBMain.mlogin + "'";

            myReader = DBMain.ExecSqlDataReader(strLenh);
            if (myReader == null)
            {
                return;
            }
            myReader.Read();


            DBMain.username = myReader.GetString(0);     // Lay user name
            if (Convert.IsDBNull(DBMain.username))
            {
                MessageBox.Show("User không đủ quyền truy cập ! Xin vui lòng xem lại cơ sở dữ liệu.", "", MessageBoxButtons.OK);
                return;
            }
            DBMain.mHoten = myReader.GetString(1);
            DBMain.mGroup = myReader.GetString(2);
            //myReader.Close();
            //DBMain.conn.Close();
            //DBMain.frmChinh.HienThiMenu();
            MessageBox.Show("Đăng nhập thành công !!!", "", MessageBoxButtons.OK);
            if (txtUser.Text == "QuanLy01" || txtUser.Text == "QuanLy02")
            {
                FormNV frm = new FormNV();
                frm.ShowDialog();
            }
            else
            {
                Main frm = new Main();
                frm.ShowDialog();
            }
        }