protected void Button1_Click(object sender, EventArgs e) { using (ChasierCRUD chasierCRUD = new ChasierCRUD()) { string fname = TextName.Text; string pass = TextPassword.Text; string passconf = TextPassConf.Text; string email = TextEmail.Text; string tipe = gender.SelectedItem.ToString(); Chasier chasier = new Chasier(); chasier.Password = pass; chasier.Email = email; chasierCRUD.CalEmail(chasier); chasierCRUD.Encrypt(chasier); string passEncrypt = chasier.EncryptPass.ToString(); Response.Write(chasier.EncryptPass); if (chasier.TotalEmail != 0) { ClientScript.RegisterStartupScript(this.GetType(), "random", "Fail()", true); } if (chasier.TotalEmail == 0) { chasierCRUD.Register(new Chasier { Fname = fname, Password = chasier.EncryptPass, Email = email, Gender = tipe }); ClientScript.RegisterStartupScript(this.GetType(), "random", "Berhasil()", true); } Response.Write(chasier.Password); }; }
protected void EmployeeGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { using (ChasierCRUD crud = new ChasierCRUD()) { //cara ambil Id //kalo gridview itu mengambil 1 table, gridviewrow untuk mengambil 1 row saja atau 1 id GridViewRow row = EmployeeGrid.Rows[e.RowIndex]; int employeeId = int.Parse(row.Cells[0].Text); crud.Delete(employeeId); } UpdateDataGrid(); }
private void UpdateDataGrid() { using (ChasierCRUD chasierCRUD = new ChasierCRUD()) { DataTable data = new DataTable("employee"); data.Columns.Add("EmployeeId"); data.Columns.Add("FirstName"); data.Columns.Add("LastName"); data.Columns.Add("Email"); List <Chasier> cs = chasierCRUD.SelectEmployees(); foreach (Chasier emp in cs) { data.Rows.Add(emp.Id_Item, emp.Nama_Item, emp.Kode_Item, emp.Harga_Item); } EmployeeGrid.DataSource = data; EmployeeGrid.DataBind(); } }
protected void Login_btn_Click(object sender, EventArgs e) { using (ChasierCRUD chasierCRUD = new ChasierCRUD()) { string email = TextEmail.Text; string pass = Password.Text; Chasier chasier = new Chasier(); chasier.Email = email; chasier.Password = pass; chasierCRUD.Encrypt(chasier); Response.Write(chasier.EncryptPass); chasierCRUD.CalEmail(chasier); chasierCRUD.Login(chasier); if (chasier.TotalEmail != 0) { if (chasier.CekPassword == true) { Session["UserLogin"] = TextEmail.Text; ClientScript.RegisterStartupScript(this.GetType(), "random", "Berhasil()", true); } else if (chasier.CekPassword == false) { //Response.Write(chasier.CekPassword); //Response.Write("Login Gagal"); ClientScript.RegisterStartupScript(this.GetType(), "random", "PassFail()", true); } } else { //Response.Write("Email Belum Terdaftar"); ClientScript.RegisterStartupScript(this.GetType(), "random", "EmailFail()", true); } TextEmail.Text = string.Empty; Password.Text = string.Empty; chasier.Password = string.Empty; chasier.Email = string.Empty; } }
protected void EmployeeGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (ChasierCRUD crud = new ChasierCRUD()) { GridViewRow row = EmployeeGrid.Rows[e.RowIndex]; //control[0] karna 1 cell hanya ada 1 control saja //artinya 1 row disini hanya ada 1 textbox saja TextBox textmployeeId = row.Cells[0].Controls[0] as TextBox; int idItem = int.Parse(textmployeeId.Text); TextBox textFirstName = row.Cells[1].Controls[0] as TextBox; string namaItem = textFirstName.Text; TextBox textLastName = row.Cells[2].Controls[0] as TextBox; string kodeItem = textLastName.Text; TextBox textEmail = row.Cells[3].Controls[0] as TextBox; int harga = int.Parse(textEmail.Text); crud.updateItem(idItem, namaItem, kodeItem, harga); } EmployeeGrid.EditIndex = GetHashCode(); UpdateDataGrid(); }
protected void btnAdd_Click(object sender, EventArgs e) { using (ChasierCRUD crud = new ChasierCRUD()) { int itemId = int.Parse(txtEmployeeId.Text); string namaItem = txtFirstName.Text; string kodeItem = txtLastName.Text; int hargaItem = int.Parse(txtEmail.Text); crud.InsertEmployee(new Chasier { Id_Item = itemId, Nama_Item = namaItem, Kode_Item = kodeItem, Harga_Item = hargaItem }); txtEmployeeId.Text = string.Empty; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; txtEmail.Text = string.Empty; } UpdateDataGrid(); }
public void load(string email) { using (ChasierCRUD chasierCRUD = new ChasierCRUD()) { Chasier chasier = new Chasier(); string password = textPasswor.Value; email = textEmail.Value; chasier.Email = email; chasier.Password = password; chasierCRUD.CalEmail(chasier); chasierCRUD.Login(chasier); if (chasier.TotalEmail != 0) { if (chasier.CekPassword == true) { Session["UserLogin"] = email; ClientScript.RegisterStartupScript(this.GetType(), "random", "Berhasil()", true); } else if (chasier.CekPassword == false) { ClientScript.RegisterStartupScript(this.GetType(), "random", "PassFail()", true); } } else { //Response.Write("Email Belum Terdaftar"); Response.Write(email); ClientScript.RegisterStartupScript(this.GetType(), "random", "EmailFail()", true); } textEmail.Value = string.Empty; textPasswor.Value = string.Empty; chasier.Password = string.Empty; chasier.Email = string.Empty; } }
protected void btnLogin_Click(object sender, EventArgs e) { using (ChasierCRUD chasierCRUD = new ChasierCRUD()) { string email = textEmail.Value; string pass = textPassword.Value; Chasier chasier = new Chasier(); chasier.Email = email; chasier.Password = pass; chasierCRUD.Encrypt(chasier); Response.Write(chasier.EncryptPass); chasierCRUD.CalEmail(chasier); chasierCRUD.Login(chasier); if (chasier.TotalEmail != 0) { if (chasier.CekPassword == true) { Session["UserLogin"] = email; ClientScript.RegisterStartupScript(this.GetType(), "random", "Berhasil()", true); } else if (chasier.CekPassword == false) { ClientScript.RegisterStartupScript(this.GetType(), "random", "PassFail()", true); } } else { ClientScript.RegisterStartupScript(this.GetType(), "random", "EmailFail()", true); } textEmail.Value = string.Empty; textPassword.Value = string.Empty; chasier.Password = string.Empty; chasier.Email = string.Empty; } }