protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); if (mode == "add") { msAngkutan cst = (from k in dss.msAngkutans where k.nama.ToString().Trim() == txtNrp.Text.Trim() select k).FirstOrDefault(); if (cst == null) { bool b = cmbUser.SelectedValue == "Aktif" ? true : false; msAngkutan role = new msAngkutan(); //role.id = Convert.ToInt32(hdnRoleID.Value); role.nama = txtNrp.Text.Trim(); role.status = b; role.dibuatOleh = userLoginID; role.dibuatTanggal = DateTime.Now; role.diubahOleh = userLoginID; role.diubahTanggal = DateTime.Now; dss.msAngkutans.InsertOnSubmit(role); dss.SubmitChanges(); dss.Dispose(); //clear_form(); notif.Text = "Data berhasil disimpan"; //fillGV(""); } else { notif.Text = "Angkutan sudah terdaftar"; } } ////mode edit gadipake else if (mode == "edit") { msAngkutan cst = (from k in dss.msAngkutans where k.id.ToString().Trim() == (hdnRoleID.Value) select k).FirstOrDefault(); bool b = cmbUser.SelectedValue == "Aktif" ? true : false; cst.id = Convert.ToInt32(hdnRoleID.Value); cst.nama = txtNrp.Text; cst.status = b; cst.diubahOleh = userLoginID; cst.diubahTanggal = DateTime.Now; //dss.msAngkutans.InsertOnSubmit(role); dss.SubmitChanges(); dss.Dispose(); notif.Text = "Data berhasil disimpan"; } fillGV(txtFilterName.Text.Trim()); }
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(); } }
private void fillGV(string filter) { dsSPDDataContext dsp = new dsSPDDataContext(); if (!String.IsNullOrEmpty(filter)) { var query = (from m in dsp.msPlafons select new { m.id, m.plafon, status = m.status.Equals("AKTIF") ? "Aktif" : "Tidak Aktif" } ).Where(o => o.plafon.Contains(filter)); gvRole.DataSource = query.ToList(); } else { var query = (from m in dsp.msPlafons select new { m.id, m.plafon, status = m.status.Equals("AKTIF") ? "Aktif" : "Tidak Aktif" } ); gvRole.DataSource = query.ToList(); } gvRole.DataBind(); dsp.Dispose(); gvRole.Visible = true; }
private void fillGV() { dsSPDDataContext dsp = new dsSPDDataContext(); //var query = (from k in dsp.msKaryawans where k.statusKaryawan.Trim() == "Active" select k); var query = (from m in dsp.msCosts select m); gvCostCenter.DataSource = query.ToList(); gvCostCenter.DataBind(); dsp.Dispose(); }
private void fillGV() { dsSPDDataContext dsp = new dsSPDDataContext(); var query = (from m in dsp.v_userRoles select new { m.nrp, m.namaLengkap, m.roleId, m.namaRole, m.id } ); gvUser.DataSource = query.ToList(); gvUser.DataBind(); dsp.Dispose(); gvUser.Visible = true; }
protected void fillCmbUser() { dsSPDDataContext dsp = new dsSPDDataContext(); var query = (from m in dsp.v_karyawanMappings select new { m.Nrp, m.namaLengkap, m.posisi } ).OrderBy(o => o.namaLengkap); cmbUser.DataSource = query.ToList(); cmbUser.DataBind(); dsp.Dispose(); cmbUser.Visible = true; }
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; msKaryawan kr = (from k in data.msKaryawans where k.nrp.Trim() == nrp.Trim() select k).FirstOrDefault(); kr.statusKaryawan = "Not Active"; data.SubmitChanges(); data.Dispose(); fillGV(); }
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("lblIdCost"); msCost cost = data.msCosts.Where(f => f.costId.ToString() == costId.Text).Single(); data.msCosts.DeleteOnSubmit(cost); data.SubmitChanges(); data.Dispose(); fillGV(); }
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"); msRole role = data.msRoles.Where(f => f.id.ToString() == costId.Text).Single(); data.msRoles.DeleteOnSubmit(role); data.SubmitChanges(); data.Dispose(); fillGV(txtFilterName.Text.Trim()); }
protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); msCost cst = (from k in dss.msCosts where k.costId.ToString().Trim() == hfCostId.Value.Trim() select k).FirstOrDefault(); if (cst == null) { msCost cost = new msCost(); cost = fillK(); dss.msCosts.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(); //} } }
protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); msKaryawan kr = (from k in dss.msKaryawans where k.nrp.Trim() == txtNRP.Text.Trim() select k).FirstOrDefault(); if (kr == null) { msKaryawan krs = new msKaryawan(); krs = fillK(); dss.msKaryawans.InsertOnSubmit(krs); 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 kr); dss.SubmitChanges(); dss.Dispose(); clear_form(); notif.Text = "Data berhasil disimpan"; fillGV(); } } }
private void fillGV(string filter) { dsSPDDataContext dsp = new dsSPDDataContext(); if (!String.IsNullOrEmpty(filter)) { var query = (from m in dsp.msGolonganPlafons join n in dsp.msPlafons on m.idPlafon equals n.id select new { id = m.id, jenisSPD = m.jenisSPD, wilayah = m.wilayah, golongan = m.golongan, Plafon = n.plafon, harga = m.harga, deskripsi = m.deskripsi, status = m.status.Equals("AKTIF") ? "Aktif" : "Tidak Aktif", idPlafon = m.idPlafon }).Where(o => o.golongan.Contains(filter)); gvRole.DataSource = query.ToList(); } else { var query = from m in dsp.msGolonganPlafons join n in dsp.msPlafons on m.idPlafon equals n.id select new { id = m.id, jenisSPD = m.jenisSPD, wilayah = m.wilayah, golongan = m.golongan, plafon = n.plafon, harga = m.harga, deskripsi = m.deskripsi, status = m.status.Equals("AKTIF") ? "Aktif" : "Tidak Aktif", idPlafon = m.idPlafon }; gvRole.DataSource = query.ToList(); } gvRole.DataBind(); dsp.Dispose(); gvRole.Visible = true; }
private void fillGridView(object p) { dsSPDDataContext data = new dsSPDDataContext(); string nrp = (string)p; var query = (from u in data.msUsers join r in data.msRoles on u.roleId equals r.id join k in data.msKaryawans on u.nrp equals k.nrp where u.nrp == p.ToString() select new { nrp = u.nrp, nama = k.namaLengkap, roleid = r.id, role = r.namaRole }); gvRole.DataSource = query.ToList(); gvRole.DataBind(); data.Dispose(); }
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(); } }
private void fillGV(string filter) { dsSPDDataContext dsp = new dsSPDDataContext(); if (!String.IsNullOrEmpty(filter)) { var query = (from m in dsp.msRoles select new { m.id, m.namaRole, m.status } ).Where(o => o.status == true && o.namaRole.Contains(filter)); gvRole.DataSource = query.ToList(); } else { var query = (from m in dsp.msRoles select new { m.id, m.namaRole, m.status } ).Where(o => o.status == true); gvRole.DataSource = query.ToList(); } gvRole.DataBind(); dsp.Dispose(); gvRole.Visible = true; }
private void ubahStatusSPD(string strNoSpd, string stat, string subject, HttpContext ctx) { string role = string.Empty, Approver = string.Empty; bool sending = false; dsSPDDataContext data = new dsSPDDataContext(); trSPD oSpd = (from spd in data.trSPDs where spd.noSPD == strNoSpd select spd).FirstOrDefault(); msKaryawan kary = new msKaryawan(); if (oSpd.nrp != "99999999") { kary = (from kar in data.msKaryawans where kar.nrp == oSpd.nrp select kar).FirstOrDefault(); } //Ditambahkan oleh martha else if (oSpd.nrp == "2950") { kary.EMail = "*****@*****.**"; kary.nrp = oSpd.nrp; kary.namaLengkap = oSpd.namaLengkap; kary.golongan = "III"; kary.Job = oSpd.jabatan; kary.posisi = oSpd.jabatan; kary.coCd = "1"; kary.kodePSubArea = "1"; kary.kodePA = "1"; } else { kary.EMail = oSpd.email; kary.nrp = oSpd.nrp; kary.namaLengkap = oSpd.namaLengkap; kary.golongan = "III"; kary.Job = oSpd.jabatan; kary.posisi = oSpd.jabatan; kary.coCd = "1"; kary.kodePSubArea = "1"; kary.kodePA = "1"; } if (subject.ToLower().Trim() == "atasan") { if (stat.ToLower().Trim() == "approve") { if (oSpd.status.Split('-')[0] == "2") { oSpd.status = "3-Atasan Approve"; ctx.Response.Write("Berhasil di approve"); sending = true; } else { ctx.Response.Write("SPD Sudah Diapprove sebelumnya"); sending = false; } } else { if (oSpd.status.Split('-')[0] == "2") { oSpd.status = "12-SPD Tolak (Atasan)"; ctx.Response.Write("Berhasil di reject"); sending = true; } else { ctx.Response.Write("SPD Sudah di tolak sebelumnya"); sending = false; } } role = "1"; Approver = oSpd.nrpAtasan; } else if (subject.ToLower().Trim() == "tujuan") { if (oSpd.tglBerangkat.Date > DateTime.Now.Date) { ctx.Response.Write("SPD belum bisa approve/reject karena tanggal berangkat harus sesudah atau sama dengan hari ini"); sending = false; return; } if (stat.ToLower().Trim() == "approve") { if (oSpd.status.Split('-')[0] == "3") { oSpd.status = "7-Tempat Tujuan Approve"; ctx.Response.Write("Berhasil di approve"); sending = true; } else { ctx.Response.Write("SPD Sudah Diapprove sebelumnya"); sending = false; } } else { if (oSpd.status.Split('-')[0] == "3") { oSpd.status = "13-SPD Tolak (Tujuan)"; ctx.Response.Write("Berhasil di reject"); sending = true; } else { ctx.Response.Write("SPD sudah ditolak sebelumnya"); sending = false; } } role = "2"; Approver = oSpd.nrpApprovalTujuan; } if (sending) { trApprovalHistory ah = new trApprovalHistory(); ah.noSPD = strNoSpd; ah.idRole = role; ah.statusApproval = oSpd.status; ah.nrpApprover = Approver; ah.approvalDatetime = DateTime.Now; data.trApprovalHistories.InsertOnSubmit(ah); data.SubmitChanges(); classSpd oClassSPD = new classSpd(); switch (oSpd.status.Split('-')[0]) { case "2": oClassSPD.sendMail(oSpd, "Atasan", kary); break; case "3": oClassSPD.sendMail(oSpd, "Pembuat", kary); oClassSPD.sendMail(oSpd, "Tujuan", kary); oClassSPD.sendMail(oSpd, "GA", kary); break; case "6": oClassSPD.sendMail(oSpd, "Pembuat", kary); oClassSPD.sendMail(oSpd, "Tujuan", kary); oClassSPD.sendMail(oSpd, "GA", kary); break; case "7": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "8": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "9": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "12": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "13": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; } } data.Dispose(); }
private void ubahStatusClaim(string strNoSpd, string stat, string subject, HttpContext ctx) { string role = string.Empty, Approver = string.Empty; dsSPDDataContext data = new dsSPDDataContext(); bool sending = false; trSPD oSpd = (from spd in data.trSPDs where spd.noSPD == strNoSpd select spd).First(); trClaim oClaim = (from spd in data.trClaims where spd.noSPD == strNoSpd select spd).First(); msKaryawan kary = new msKaryawan(); if (oSpd.nrp != "99999999") { kary = (from kar in data.msKaryawans where kar.nrp == oSpd.nrp select kar).FirstOrDefault(); } else { kary.EMail = oSpd.email; kary.nrp = oSpd.nrp; kary.namaLengkap = oSpd.namaLengkap; kary.golongan = "III"; kary.Job = oSpd.jabatan; kary.posisi = oSpd.jabatan; kary.coCd = "1"; kary.kodePSubArea = "1"; kary.kodePA = "1"; } if (subject.ToLower().Trim() == "atasan") { if (stat.ToLower().Trim() == "approve") { if (oSpd.status.Split('-')[0] == "11") { oClaim.status = "16-Claim Approve (Atasan)"; oSpd.status = "16-Claim Approve (Atasan)"; ctx.Response.Write("Berhasil di approve"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil Di approve sebelumnya"); sending = false; } } else { if (oSpd.status.Split('-')[0] == "11") { oClaim.status = "14-Claim Tolak (Atasan)"; oSpd.status = "14-Claim Tolak (Atasan)"; ctx.Response.Write("Berhasil di reject"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil ditolak sebelumnya"); sending = false; } } role = "1"; Approver = oSpd.nrpAtasan; } else if (subject.ToLower().Trim() == "ga") { if (stat.ToLower().Trim() == "approve") { if (oSpd.status.Split('-')[0] == "16") { oClaim.status = "17-Claim Approve (GA)"; oSpd.status = "17-Claim Approve (GA)"; ctx.Response.Write("Berhasil di approve"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil di-approve sebelumnya"); sending = false; } } else { if (oSpd.status.Split('-')[0] == "16") { oClaim.status = "15-Claim Tolak (GA)"; oSpd.status = "15-Claim Tolak (GA)"; ctx.Response.Write("Berhasil di reject"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil di-reject sebelumnya"); sending = false; } } role = "17"; Approver = oSpd.nrpAtasan; } else if (subject.ToLower().Trim() == "finance") { if (stat.ToLower().Trim() == "approve") { if (oSpd.status.Split('-')[0] == "17") { oClaim.status = "26-Finance Approve"; oSpd.status = "26-Finance Approve"; ctx.Response.Write("Berhasil di approve"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil di-Approve sebelumnya"); sending = false; } } else { if (oSpd.status.Split('-')[0] == "17") { oClaim.status = "27-Finance Tolak"; oSpd.status = "27-Finance Tolak"; ctx.Response.Write("Berhasil di reject"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil di-reject sebelumnya"); sending = false; } } role = "19"; Approver = oSpd.nrpAtasan; } else if (subject.ToLower().Trim() == "kasir") { if (oSpd.status.Split('-')[0] == "26") { oClaim.status = "20-Claim Close"; oSpd.status = "20-Claim Close"; ctx.Response.Write("Berhasil di Close"); sending = true; } else { ctx.Response.Write("Claim sudah berhasil di-Close sebelumnya"); sending = false; } role = "20"; Approver = oSpd.nrpAtasan; } //data.SubmitChanges(); if (sending) { classSpd oClassSPD = new classSpd(); trApprovalHistory ah = new trApprovalHistory(); ah.noSPD = strNoSpd; ah.idRole = role; ah.statusApproval = oSpd.status; ah.nrpApprover = Approver; ah.approvalDatetime = DateTime.Now; data.trApprovalHistories.InsertOnSubmit(ah); data.SubmitChanges(); switch (oSpd.status.Split('-')[0]) { case "2": oClassSPD.sendMail(oSpd, "Atasan", kary); break; case "3": oClassSPD.sendMail(oSpd, "Pembuat", kary); oClassSPD.sendMail(oSpd, "GA", kary); oClassSPD.sendMail(oSpd, "Tujuan", kary); break; case "6": oClassSPD.sendMail(oSpd, "Pembuat", kary); oClassSPD.sendMail(oSpd, "GA", kary); oClassSPD.sendMail(oSpd, "Tujuan", kary); break; case "8": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "9": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "12": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "13": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "14": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "16": oClassSPD.sendMail(oSpd, "GA", kary); oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "15": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "17": oClassSPD.sendMail(oSpd, "finance", kary); oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "27": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "26": //oClassSPD.sendMail(oSpd, "kasir", kary); oClassSPD.sendMail(oSpd, "Pembuat", kary); break; case "20": oClassSPD.sendMail(oSpd, "Pembuat", kary); break; } } data.Dispose(); }
void bindFindList() { dsSPDDataContext data = new dsSPDDataContext(); try { if (txtTglSpd.Text == "" || txtTglSpd == null) { var query = (from spd in data.trSPDs where spd.noSPD.Contains(txtNoSpd.Text) && spd.namaLengkap.Contains(txtNama.Text) && spd.nrp.Contains(txtNrp.Text) && (spd.statusUM.Equals(DropDownList1.SelectedValue) || spd.statusUM.Equals(null)) select new { noSPD = spd.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, uangMuka = spd.uangMuka, tglPenyelesaian = spd.tglPenyelesaian, status = spd.statusUM //spd.status }).OrderByDescending(spd => spd.noSPD).ToList(); grvList.DataSource = query; grvList.DataBind(); if (!query.Any()) { Panel5.Visible = true; } else { Panel5.Visible = true; } data.Dispose(); } else { DateTime str = Convert.ToDateTime(txtTglSpd.Text); var query = (from spd in data.trSPDs where spd.noSPD.Contains(txtNoSpd.Text) && spd.namaLengkap.Contains(txtNama.Text) && spd.nrp.Contains(txtNrp.Text) && (spd.statusUM.Equals(DropDownList1.SelectedValue) || spd.statusUM.Equals("")) && (spd.tglPenyelesaian >= str && spd.tglPenyelesaian <= str) select new { noSPD = spd.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, uangMuka = spd.uangMuka, tglPenyelesaian = spd.tglPenyelesaian, status = spd.statusUM }).OrderByDescending(spd => spd.noSPD).ToList(); grvList.DataSource = query; grvList.DataBind(); if (!query.Any()) { Panel5.Visible = true; } else { Panel5.Visible = true; } data.Dispose(); } } catch (Exception ex) { //Response.Write(ex.Message); } }
//protected void lbEdit_Click(object sender, EventArgs e) //{ // dsSPDDataContext dss = new dsSPDDataContext(); // LinkButton link = (LinkButton)sender; // GridViewRow gv = (GridViewRow)(link.NamingContainer); // string nrp = gv.Cells[0].Text; // Label costId = (Label)gv.FindControl("lblIdCost"); // //msCost cost = (from k in dss.msCosts where k.costId.ToString().Trim() == costId.Text.Trim() select k).FirstOrDefault(); // Label id = (Label)gv.FindControl("id"); // var x = (from m in dss.msRoles // where m.id.ToString().Trim() == id.Text.Trim() // select m).FirstOrDefault(); // fill_form(ref x); // hfmode.Value = "edit"; // pnlForm.Visible = true; // pnlGrid.Visible = false; //} protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); if (mode == "add") { msRole cst = (from k in dss.msRoles where k.namaRole.ToString().Trim() == txtPosisi.Text.Trim() select k).FirstOrDefault(); if (cst == null) { msRole role = new msRole(); //role.id = Convert.ToInt32(hdnRoleID.Value); role.namaRole = txtPosisi.Text.Trim(); role.status = true; role.dibuatOleh = userLoginID; role.dibuatTanggal = DateTime.Now; role.diubahOleh = userLoginID; role.diubahTanggal = DateTime.Now; dss.msRoles.InsertOnSubmit(role); dss.SubmitChanges(); dss.Dispose(); //clear_form(); notif.Text = "Data berhasil disimpan"; //fillGV(""); } else { notif.Text = "Nama Role atau Posisi sudah terdaftar"; } } ////mode edit gadipake //else if (mode == "edit") //{ // msRole cst = (from k in dss.msRoles // where k.namaRole.ToString().Trim() == txtPosisi.Text.Trim() // select k).FirstOrDefault(); // if (cst == null) // { // msRole role = new msRole(); // //role.id = Convert.ToInt32(hdnRoleID.Value); // role.namaRole = txtPosisi.Text.Trim(); // role.status = true; // role.dibuatOleh = userLoginID; // role.dibuatTanggal = DateTime.Now; // role.diubahOleh = userLoginID; // role.diubahTanggal = DateTime.Now; // dss.msRoles.InsertOnSubmit(role); // dss.SubmitChanges(); // dss.Dispose(); // notif.Text = "Data berhasil disimpan"; // } // else // { // cst.id = Convert.ToInt32(hdnRoleID.Value); // cst.namaRole = txtPosisi.Text.Trim(); // cst.diubahOleh = userLoginID; // cst.diubahTanggal = DateTime.Now; // dss.SubmitChanges(); // dss.Dispose(); // notif.Text = "Data berhasil disimpan"; // } //} }
private void historyApproval(object sender, string status) { if (Session["IDLogin"] == null) { Response.Redirect("frmHome.aspx"); } else { string strLoginID = (string)Session["IDLogin"]; classSpd oSPD = new classSpd(); msKaryawan karyawan = new msKaryawan(); karyawan = oSPD.getKaryawan(strLoginID); LinkButton link = (LinkButton)sender; GridViewRow gv = (GridViewRow)(link.NamingContainer); dsSPDDataContext data = new dsSPDDataContext(); string strNoSpd = gv.Cells[0].Text; string strNRP = strLoginID; string strStatus = status; //var role = (from msUser in data.msUsers.AsEnumerable() // where msUser.nrp == karyawan.nrp // select msUser).First(); //var role = (from msRole in data.msRoles.AsEnumerable() // where msRole.namaRole == karyawan.posisi // select msRole).First(); //string strRole = Convert.ToString(role.id); //string strRole = Convert.ToString(role.roleId); string strRole = ""; var role = (from msRole in data.msRoles.AsEnumerable() where msRole.namaRole == karyawan.posisi select msRole).First(); if (role != null) { strRole = Convert.ToString(role.id); } else { var user = (from msUser in data.msUsers.AsEnumerable() where msUser.nrp == karyawan.nrp select msUser).First(); if (user != null) { strRole = Convert.ToString(user.roleId); } else { strRole = "1"; } } DateTime dateApproval = DateTime.Now; trApprovalHistory AppHistory = new trApprovalHistory(); AppHistory.noSPD = strNoSpd; AppHistory.nrpApprover = strNRP; AppHistory.statusApproval = strStatus; AppHistory.idRole = strRole; AppHistory.approvalDatetime = dateApproval; data.trApprovalHistories.InsertOnSubmit(AppHistory); data.SubmitChanges(); data.Dispose(); } }
void bindFindList() { dsSPDDataContext data = new dsSPDDataContext(); try { if (txtTglSpd.Text == "" || txtTglSpd == null) { var query = (from spd in data.trSPDs join claim in data.trClaims on spd.noSPD equals claim.noSPD where spd.nrp == karyawan.nrp && claim.isApprovedFinance == true select new { noSPD = spd.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, cabangTujuan = spd.companyCodeTujuan != null ? spd.companyCodeTujuan + " - " + spd.personelAreaTujuan + " - " + spd.pSubAreaTujuan : spd.tempatTujuanLain, keperluan = spd.idKeperluan != null ? spd.msKeperluan.keperluan : spd.keperluanLain, tglBerangkat = spd.tglBerangkat.ToShortDateString(), tglKembali = spd.tglKembali.ToShortDateString(), status = claim.status //spd.status }).OrderByDescending(spd => spd.noSPD).ToList(); grvList.DataSource = query; grvList.DataBind(); if (!query.Any()) { Panel5.Visible = false; } else { Panel5.Visible = true; } data.Dispose(); } else { DateTime str = Convert.ToDateTime(txtTglSpd.Text); var query = (from spd in data.trSPDs join claim in data.trClaims on spd.noSPD equals claim.noSPD where spd.nrp == karyawan.nrp && claim.isApprovedFinance == true && spd.tglBerangkat == str select new { noSPD = spd.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, cabangTujuan = spd.companyCodeTujuan != null ? spd.companyCodeTujuan + " - " + spd.personelAreaTujuan + " - " + spd.pSubAreaTujuan : spd.tempatTujuanLain, keperluan = spd.idKeperluan != null ? spd.msKeperluan.keperluan : spd.keperluanLain, tglBerangkat = spd.tglBerangkat.ToShortDateString(), tglKembali = spd.tglKembali.ToShortDateString(), status = claim.status //spd.status }).OrderByDescending(spd => spd.noSPD).ToList(); grvList.DataSource = query; grvList.DataBind(); if (!query.Any()) { Panel5.Visible = false; } else { Panel5.Visible = true; } data.Dispose(); } } catch (Exception ex) { Response.Write(ex.Message); } }
protected void btnSubmit_Click(object sender, EventArgs e) { #region submit old if (Session["noSPDc"] == null) { Response.Redirect("frmClaimApproval.aspx"); } else { if (txtNoSPD.Text != string.Empty) { dsSPDDataContext data = new dsSPDDataContext(); trClaim claim = data.trClaims.FirstOrDefault(o => o.noSPD == txtNoSPD.Text); trSPD spd = data.trSPDs.FirstOrDefault(o => o.noSPD == claim.noSPD); if (spd.isApproved == true && spd.isCancel == null) { getFromForm(ref claim); try { btnSubmit.Enabled = false; btnSave.Enabled = false; claim.nrpAtasan = spd.nrpAtasan; claim.status = "Menunggu approval atasan"; claim.isSubmit = true; claim.isSubmitDate = DateTime.Now; claim.diubahOleh = karyawan.nrp; claim.diubahTanggal = DateTime.Now; msKaryawan kary = new msKaryawan(); if (spd.nrp == "99999999") { kary.EMail = spd.email; kary.nrp = spd.nrp; kary.namaLengkap = spd.namaLengkap; kary.golongan = "III"; kary.Job = spd.jabatan; kary.posisi = spd.jabatan; kary.coCd = "1"; kary.kodePSubArea = "1"; kary.kodePA = "1"; } else { kary = (from kar in data.msKaryawans where kar.nrp == spd.nrp select kar).First(); } data.SubmitChanges(); EmailCore.ApprovalClaim(claim.nrpAtasan, spd.noSPD, spd, "Atasan", claim.status); lblKet.Text = "Claim berhasil di Submit"; data.Dispose(); } catch (Exception ex) { Response.Write(ex.Message); } } } } #endregion }
protected void btnSimpan_Click(object sender, EventArgs e) { dsSPDDataContext dss = new dsSPDDataContext(); string mode = "add"; mode = hfmode.Value.ToString(); if (mode == "add") { msGolonganPlafon cst = (from k in dss.msGolonganPlafons where k.id.ToString().Trim() == hdnRoleID.Value select k).FirstOrDefault(); if (cst == null) { msGolonganPlafon role = new msGolonganPlafon(); role.jenisSPD = ddlJenisSPD.SelectedValue.ToString(); role.wilayah = ddlWilayah.SelectedValue.ToString(); role.golongan = ddlGolongan.SelectedValue.ToString(); role.idPlafon = Convert.ToInt32(ddlPlafon.SelectedValue.ToString()); role.harga = Convert.ToInt32(txtHarga.Text); role.deskripsi = txtNrp.Text.Trim(); role.status = cmbUser.SelectedValue.ToString() == "AKTIF" ? "aktif" : "tidak aktif"; role.dibuatOleh = userLoginID; role.dibuatTanggal = DateTime.Now; role.diubahOleh = userLoginID; role.diubahTanggal = DateTime.Now; dss.msGolonganPlafons.InsertOnSubmit(role); dss.SubmitChanges(); dss.Dispose(); //clear_form(); notif.Text = "Data berhasil disimpan"; //fillGV(""); } else { notif.Text = "Data sudah terdaftar"; } } ////mode edit gadipake else if (mode == "edit") { msGolonganPlafon cst = (from k in dss.msGolonganPlafons where k.id.ToString().Trim() == hdnRoleID.Value select k).FirstOrDefault(); cst.id = Convert.ToInt32(hdnRoleID.Value); cst.jenisSPD = ddlJenisSPD.SelectedValue.ToString(); cst.wilayah = ddlWilayah.SelectedValue.ToString(); cst.golongan = ddlGolongan.SelectedValue.ToString(); cst.idPlafon = Convert.ToInt32(ddlPlafon.SelectedValue.ToString()); cst.harga = Convert.ToInt32(txtHarga.Text); cst.deskripsi = txtNrp.Text.Trim(); cst.diubahOleh = userLoginID; cst.diubahTanggal = DateTime.Now; cst.status = cmbUser.SelectedValue.ToString() == "AKTIF" ? "aktif" : "tidak aktif"; dss.SubmitChanges(); dss.Dispose(); notif.Text = "Data berhasil disimpan"; //} } fillGV(txtFilterName.Text.Trim()); }
void finder() { dsSPDDataContext data = new dsSPDDataContext(); bool SPD = true; string filter = string.Empty; try { // filter = getFilter(); if (ddlTipe.SelectedValue == "spd") { SPD = true; } else { SPD = false; } if (SPD) { var query = from spd in data.trSPDs.AsEnumerable() join k in data.msKaryawans on spd.nrp equals k.nrp select new { noSPD = spd.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, cabangTujuan = spd.companyCodeTujuan != null ? spd.companyCodeTujuan + " - " + spd.personelAreaTujuan + " - " + spd.pSubAreaTujuan : spd.tempatTujuanLain, keperluan = spd.idKeperluan != null ? spd.msKeperluan.keperluan : spd.keperluanLain, tglBerangkat = spd.tglBerangkat.ToShortDateString(), tglKembali = spd.tglKembali.ToShortDateString(), status = spd.status //.Split('-')[1] }; if (txtNama.Text != null && txtNama.Text != "") { query = query.Where(namaLengkap => namaLengkap.ToString().ToLower().Contains(txtNama.Text.Trim().ToLower())); } if (txtTglBerangkat.Text != null && txtTglBerangkat.Text != "") { String str = Convert.ToDateTime(txtTglBerangkat.Text).ToShortDateString().ToString().Trim(); query = query.Where(tglBerangkat => tglBerangkat.ToString().Contains(str)); } if (ddlStatus.SelectedValue.ToLower() != "all") { String val = ddlStatus.SelectedValue.ToString().Trim(); query = query.Where(status => status.ToString().Contains(val)); } grSPD.DataSource = query.ToList(); grSPD.DataBind(); if (!query.Any()) { PanelSPD.Visible = false; } else { PanelSPD.Visible = true; } PanelClaim.Visible = false; data.Dispose(); } else { var query = (from claim in data.trClaims.AsEnumerable() join spd in data.trSPDs.AsEnumerable() on claim.noSPD equals spd.noSPD join k in data.msKaryawans on spd.nrp equals k.nrp select new { noSPD = claim.noSPD, nrp = spd.nrp, namaLengkap = spd.namaLengkap, cabangTujuan = spd.companyCodeTujuan != null ? spd.companyCodeTujuan + " - " + spd.personelAreaTujuan + " - " + spd.pSubAreaTujuan : spd.tempatTujuanLain, tglBerangkat = spd.tglBerangkat.ToShortDateString(), tglKembali = spd.tglKembali.ToShortDateString(), uangMakan = claim.biayaMakan, uangSaku = claim.uangSaku, Tiket = claim.tiket, Hotel = claim.hotel, BBM = claim.BBM, Tol = claim.tol, Taxi = claim.taxi, AirportTax = claim.airportTax, laundry = claim.laundry, Parkir = claim.parkir, Lain = claim.biayaLainLain, Total = claim.biayaMakan + claim.uangSaku + claim.tiket + claim.hotel + claim.BBM + claim.tol + claim.taxi + claim.airportTax + claim.laundry + claim.parkir + claim.biayaLainLain + claim.komunikasi, status = claim.status //.Split('-')[1] }); if (txtNama.Text != null && txtNama.Text != "") { query = query.Where(namaLengkap => namaLengkap.ToString().ToLower().Contains(txtNama.Text.Trim().ToLower())); } if (txtTglBerangkat.Text != null && txtTglBerangkat.Text != "") { String str = Convert.ToDateTime(txtTglBerangkat.Text).ToShortDateString().ToString(); query = query.Where(tglBerangkat => tglBerangkat.ToString().Contains(str)); } if (ddlStatus.SelectedValue.ToLower() != "all") { query = query.Where(status => status.ToString() == ddlStatus.SelectedValue.ToString()); } grClaim.DataSource = query.ToList(); grClaim.DataBind(); if (!query.Any()) { PanelClaim.Visible = false; } else { PanelClaim.Visible = true; } PanelSPD.Visible = false; data.Dispose(); } } catch (Exception ex) { Response.Write(ex.Message); } }