protected void lbDelete_Click(object sender, EventArgs e) { dsSPDDataContext data = new dsSPDDataContext(); LinkButton link = (LinkButton)sender; GridViewRow gv = (GridViewRow)(link.NamingContainer); string nrp = gv.Cells[0].Text; string idRole = gv.Cells[2].Text; try { var query = (from r in data.msUsers where r.nrp == nrp && r.roleId.ToString() == idRole select r).FirstOrDefault(); msUser user = new msUser(); data.msUsers.DeleteOnSubmit((msUser)query); data.SubmitChanges(); fillGridView(cmbxUser.Value.ToString()); } catch (Exception ex) { Response.Write("Penghapusan data gagal " + ex.Message); } finally { data.Dispose(); } }
protected void txtLogin_TextChanged(object sender, EventArgs e) { using (var ctx = new dsSPDDataContext()) { if (String.IsNullOrEmpty(txtLogin.Text)) { txtLogin.Text = SetLabelWelcome(); } strLoginID = txtLogin.Text; Session["IDLogin"] = strLoginID; classSpd oSPD = new classSpd(); karyawan = oSPD.getKaryawan(strLoginID); Session["nrpLogin"] = karyawan.nrp; dsSPDDataContext data = new dsSPDDataContext(); msUser sekretaris = (from u in data.msUsers where u.nrp == karyawan.nrp && u.roleId == Konstan.SEKRETARIS select u).FirstOrDefault(); if (sekretaris != null) { Session["sekretaris"] = true; } else { Session["sekretaris"] = false; } } }
public msUser fillK() { msUser cost = new msUser(); cost.nrp = txtCostDesc.Text; cost.roleId = Convert.ToInt32(cmbCompanyName.SelectedItem.Value); cost.status = 1; return(cost); }
protected void lbDelete_Click(object sender, EventArgs e) { dsSPDDataContext data = new dsSPDDataContext(); LinkButton link = (LinkButton)sender; GridViewRow gv = (GridViewRow)(link.NamingContainer); Label costId = (Label)gv.FindControl("id"); msUser cost = data.msUsers.Where(f => f.id.ToString() == costId.Text).Single(); data.msUsers.DeleteOnSubmit(cost); data.SubmitChanges(); data.Dispose(); fillGV(); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { bool authLog = AuthenticateUser(Login1.UserName.Trim(), Login1.Password.Trim()); List <string> roles = new List <string>(); //dsSPDDataContext data = new dsSPDDataContext(); if (authLog == true) { Session.Add("UserLog", Login1.UserName.Trim()); roles.Add("Karyawan"); msUser user = new msUser(); //P.O.Box Response.Redirect("frmHome.aspx"); } }
protected void btnAdd_Click(object sender, EventArgs e) { dsSPDDataContext data = new dsSPDDataContext(); msUser user = new msUser(); user.nrp = cmbxUser.Value.ToString(); user.roleId = Convert.ToInt32(cmbxUserRole.Value); try { data.msUsers.InsertOnSubmit(user); data.SubmitChanges(); fillGridView(cmbxUser.Value.ToString()); } catch (Exception ex) { Response.Write("Gagal dalam memasukkan data " + ex.Message); } finally { data.Dispose(); } }
protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); msUser cst = (from k in dss.msUsers where k.id.ToString().Trim() == hfCostId.Value.Trim() select k).FirstOrDefault(); if (cst == null) { msUser cost = new msUser(); cost = fillK(); dss.msUsers.InsertOnSubmit(cost); dss.SubmitChanges(); dss.Dispose(); clear_form(); notif.Text = "Data berhasil disimpan"; fillGV(); } else { //clear_form(); //if (mode == "add") //{ // notif.Text = "Simpan gagal : NRP Karyawan Sudah Terdaftar"; //} //else //{ fillEdit(ref cst); dss.SubmitChanges(); dss.Dispose(); clear_form(); notif.Text = "Data berhasil disimpan"; fillGV(); //} } }
public void fillEdit(ref msUser cost) { cost.nrp = txtCostDesc.Text; cost.roleId = Convert.ToInt32(cmbCompanyName.SelectedItem.Value); cost.id = Convert.ToInt32(hfCostId.Value); }
protected void Page_Load(object sender, EventArgs e) { try { using (var ctx = new dsSPDDataContext()) { if (!Page.IsPostBack) { //strLoginID = SetLabelWelcome();//production //strLoginID = "benny00002704"; //strLoginID = "titin008704"; //strLoginID = "siska90000308"; //strLoginID = "HP"; strLoginID = ConfigurationManager.AppSettings["DevstrLoginID"].ToString();//development Session["IDLogin"] = strLoginID; classSpd oSPD = new classSpd(); karyawan = oSPD.getKaryawan(strLoginID); Session["nrpLogin"] = karyawan.nrp; if (string.IsNullOrEmpty(karyawan.nrp)) { errorLogin += "User (karyawan) tidak ditemukan, session login kosong, silahkan close browser anda, lalu login ulang."; } msUser sekretaris = (from u in ctx.msUsers where u.nrp == karyawan.nrp && u.roleId == Konstan.SEKRETARIS select u).FirstOrDefault(); if (sekretaris != null) { Session["sekretaris"] = true; } else { Session["sekretaris"] = false; } } } ////debug //txtLogin.Visible = true; //if (Page.IsPostBack) txtLogin_TextChanged(null, null); } catch (Exception) { // sorry broo saya cuman ngakal2in crash loginnya soalnya minta login ke server laen -_-" bool recIt = ApplicationPoolRecycle.RecycleCurrentApplicationPool(); HttpRuntime.UnloadAppDomain(); Response.Redirect("~/FormError.aspx?e=Applikasi sedang merefresh, silahkan close browser anda, lalu login ulang."); } finally { ////debug only //if (Page.IsPostBack) //{ // Response.Redirect("~/newFormHome.aspx"); //} //production if (!string.IsNullOrEmpty(errorLogin)) { Response.Redirect("~/FormError.aspx?e=" + errorLogin); } else { Response.Redirect("~/newFormHome.aspx"); } } }