private void btnSignup_Click(object sender, EventArgs e) { //insert on Account. if (!TM.AddAccount(txtUsername.Text, MD5.CreateMD5(txtPassword.Text), 2, 1)) { //if add faild, show notification MessageBox.Show("Failed"); } else { //get id of it var rs = TM.GetListOfAccount().OrderByDescending(s => s.ID).First(); //insert on Driver. if (!TM.AddDriver((int)rs.ID, txtFullname.Text, txtIDCard.Text, txtAddress.Text, txtPhone.Text)) { //if add failed. show notification MessageBox.Show("Add info failed, please sign in and update your profile"); } else { //if 2 success, show notification MessageBox.Show("Sign up successed"); } } }
void Reload_Data() { var ls = TM.GetListOfDriver(); dgvDriverData.DataSource = ls; var ls2 = TM.GetListOfAccount().Where(s => s.TYPEID == 2).ToList(); dgvAccountDriver.AutoGenerateColumns = false; dgvAccountDriver.DataSource = ls2; }
private void Menu_Load(object sender, EventArgs e) { //load list driver var ls = TM.GetListOfDriver(); dgvDriverData.DataSource = ls; //load list account driver var ls2 = TM.GetListOfAccount().Where(s => s.TYPEID == 2).ToList(); dgvAccountDriver.AutoGenerateColumns = false; dgvAccountDriver.DataSource = ls2; if (String.IsNullOrEmpty(txtFullname.Text)) { btnDel.Enabled = btnUpdate.Enabled = false; btnSubmit.Enabled = false; } }
private void btnDangNhap_Click(object sender, EventArgs e) { //Check textbox Empty if (string.IsNullOrEmpty(txtUser.Text) | string.IsNullOrEmpty(txtPassword.Text)) { //if empty, show error MessageBox.Show("Don't empty username or password."); } else { //if not empty //check valid account var acc = TM.GetListOfAccount(); var rs = acc.Where(s => (s.USERNAME.Trim() == txtUser.Text) & (s.PASSWORD.Trim() == MD5.CreateMD5(txtPassword.Text))).SingleOrDefault(); if (rs != null) { //1: is Admin, 2: is Driver if (rs.TYPEID == 1) { //1: status actived, 2: blocked if (rs.STATUS == 1) { //Show notification MessageBox.Show("Sign in success as Admin"); //call form admin manage Menu fmn = new Menu((int)rs.ID); fmn.StartPosition = FormStartPosition.CenterScreen; fmn.FormClosed += new FormClosedEventHandler(fmn_FormClosed); Hide(); fmn.ShowDialog(); } else { MessageBox.Show("Account is blocked"); } } else if (rs.TYPEID == 2) { //1: status actived, 2: blocked if (rs.STATUS == 1) { //Show notification MessageBox.Show("Sign in success as Driver"); //call form admin manage FormDriver fd = new FormDriver((int)rs.ID); fd.StartPosition = FormStartPosition.CenterScreen; fd.FormClosed += new FormClosedEventHandler(fd_FormClosed); Hide(); fd.ShowDialog(); } else { MessageBox.Show("Account is blocked"); } } } else { //Show Exception MessageBox.Show("Username or Password is incorrect!"); } } }