private void BtnLogin_Click(object sender, EventArgs e) { LogAdminBLL logAdminBLL = new LogAdminBLL(); tblAdmin admin = new tblAdmin(); admin.Username = txtUserName.Text; admin.Password = txtPassword.Text; if (logAdminBLL.getLogin(admin).HasRows) { tblLogTrail log = new tblLogTrail(); LogTrailBLL bll = new LogTrailBLL(); log.Dater = lblDateTime.Text; log.Descrip = "User: "******" has successfully Logged In!"; log.Authority = "Admin"; bll.Insert(log); frmStart frmStart = (frmStart)Application.OpenForms["frmStart"]; frmStart.Hide(); frmAdminMenu frmAdminMenu = new frmAdminMenu(); frmAdminMenu.Show(); this.Hide(); } else { DialogResult = MessageBox.Show("Không được phép truy cập! ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void BtnBack_Click(object sender, EventArgs e) { tblLogTrail log = new tblLogTrail(); LogTrailBLL bll = new LogTrailBLL(); log.Dater = DateTime.Now.ToString(); log.Descrip = "User: "******" has successfully logged Out!"; log.Authority = "Cashier"; bll.Insert(log); this.Close(); frmStart frmStart = new frmStart(); frmStart.Show(); }
public bool Insert(tblLogTrail log) { //tương tác csdl để thêm mới string sql = @"INSERT INTO tblLogTrail VALUES(@Dater,@Description,@Authority)"; SqlParameter parDater = new SqlParameter("@Dater", SqlDbType.VarChar); parDater.Value = log.Dater; SqlParameter parDes = new SqlParameter("@Description", SqlDbType.VarChar); parDes.Value = log.Descrip; SqlParameter parAuth = new SqlParameter("@Authority", SqlDbType.VarChar); parAuth.Value = log.Authority; bool kq = WriteData(sql, new[] { parDater, parDes, parAuth }); return(kq); }
public List <tblLogTrail> GetTblLogTrails() { SqlDataReader reader = ReadData("select * from tblLogTrail"); List <tblLogTrail> dsLogTrail = new List <tblLogTrail>(); while (reader.Read()) { string Dater = reader.GetString(0); string Descrip = reader.GetString(1); string Authority = reader.GetString(2); tblLogTrail lh = new tblLogTrail(); lh.Dater = Dater; lh.Descrip = Descrip; lh.Authority = Authority; dsLogTrail.Add(lh); } reader.Close(); return(dsLogTrail); }
private void LblUser_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure? ", "Log Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { tblLogTrail log = new tblLogTrail(); LogTrailBLL bll = new LogTrailBLL(); log.Dater = DateTime.Now.ToString(); log.Descrip = "User: "******" has successfully logged Out!"; log.Authority = "Admin"; bll.Insert(log); this.Close(); frmStart frmStart = new frmStart(); frmStart.Show(); frmLogAdmin frmLogAdmin = new frmLogAdmin(); frmLogAdmin.Show(); } }
public List <tblLogTrail> RemoveLogTrailsDAL() { SqlDataReader reader = ReadData("delete from tblLogTrail"); List <tblLogTrail> dslog = new List <tblLogTrail>(); while (reader.Read()) { string Dater = reader.GetString(0); string Descrip = reader.GetString(1); string Authority = reader.GetString(2); tblLogTrail log = new tblLogTrail(); log.Dater = Dater; log.Descrip = Descrip; log.Authority = Authority; dslog.Add(log); } reader.Close(); return(dslog); }
public bool Insert(tblLogTrail log) { LogTrailDAL dal = new LogTrailDAL(); return(dal.Insert(log)); }