private void menuQuanly_Click(object sender, EventArgs e) { Form frm = this.MdiChildren.OfType <QuanLy>().FirstOrDefault(); Form frmm = this.MdiChildren.OfType <QlTaiKhoan>().FirstOrDefault(); if (frmm != null) { frmm.Close(); } if (frm != null) { } else { if (loainv == 1) { QuanLy ql = new QuanLy(tk, ten); ql.MdiParent = this; ql.StartPosition = FormStartPosition.CenterScreen; ql.Show(); } else { QuanLy2 ql = new QuanLy2(tk, ten); ql.MdiParent = this; ql.StartPosition = FormStartPosition.CenterScreen; ql.Show(); } } }
/// <summary> /// load du lieu len form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <summary> /// bat su kien dang nhap tai khoan /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { try { TaiKhoanDTO tk = new TaiKhoanDTO(); tk.username = txtusername.Text; tk.password = txtpassword.Text; //tk.ma_cv = cbxCV.SelectedValue.ToString(); tk.trang_thai = true; if (TaiKhoanBUS.Dang_nhap(tk) != "") { string quyenhan = TaiKhoanBUS.Dang_nhap(tk); switch (quyenhan) { case "BH": this.Hide(); frmBanHang bh = new frmBanHang(); bh.Show(); bh.STR = txtusername.Text; break; case "NH": this.Hide(); NhapHang nh = new NhapHang(); nh.Show(); nh.STR = txtusername.Text; break; case "QL": this.Hide(); QuanLy ql = new QuanLy(); ql.Show(); ql.STR = txtusername.Text; break; default: MessageBox.Show("Error!", "Thông báo", MessageBoxButtons.OK); break; } } else { MessageBox.Show("Tài khoản của bạn có người đã đăng nhập hoặc bạn nhập sai thông tin !", "Thông báo", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void logInBut_Click(object sender, EventArgs e) { SqlCommand command = new SqlCommand(); command.Connection = con; command.CommandType = CommandType.Text; command.CommandText = "Select username,passworduser from NGUOIDUNG where (username=@user) and (passworduser=@pass)"; command.Parameters.Add("@user", SqlDbType.NVarChar, 50).Value = uNameBox.Text; command.Parameters.Add("@pass", SqlDbType.NVarChar, 50).Value = pWordBox.Text; da.SelectCommand = command; da.Fill(dt); if (dt.Rows.Count > 0) { QuanLy ql = new QuanLy(); delPassData del = new delPassData(ql.funData); del(this.txtTaikhoan); ql.Show(); Hide(); } else { MessageBox.Show("Đăng nhập thất bại. Sai mật khẩu hoặc tên tài khoản"); } }