protected void btnSaveDetail_Click(object sender, EventArgs e) { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; int iNextID = 0; try { _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); MPF23.Shared.Mapper.UIToDB.Map(UpExpenseClaimDetail.Controls, _htParameters); Utility.ApplyDefaultProp(_htParameters); if (lbljudulCost.Text == "Ubah") { _htParameters["p_ID"] = lblIdDetail.Text; _htParameters["p_ExClaim_No"] = txtExClaim_No.Text; _dalEmpExclaimDetailDAL.Update(_htParameters); iNextID = Int32.Parse(lblIdDetail.Text); } else { _htParameters["p_ExClaim_No"] = txtExClaim_No.Text; _dalEmpExclaimDetailDAL.Insert(_htParameters, ref iNextID); } Utility.ShowMessageBox(this, Utility.SAVE_DATA_SUCCESS_MESSAGE, null, null); BindGridClaim(); panelDetail.Visible = false; } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.SAVE_DATA_FAIL_MESSAGE, ex, null); } }
public static void BindGrvEmpExclaim(GridView gvw, string ExClaim_No) { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; try { _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); _htParameters["p_ExClaim_No"] = ExClaim_No; DataTable dt = new DataTable(); dt = _dalEmpExclaimDetailDAL.GetRows(_htParameters); gvw.DataSource = dt; gvw.DataBind(); if (dt.Rows.Count > 0) { decimal total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total_Cost")); gvw.FooterRow.Cells[14].Text = "Total"; gvw.FooterRow.Cells[14].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[14].Font.Bold = true; gvw.FooterRow.Cells[15].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[15].Font.Bold = true; gvw.FooterRow.Cells[15].Text = total.ToString("N2"); } } catch (Exception ex) { throw ex; } }
//------------------------- end SPD --------------------------------------------------------- #endregion #region Cost protected void grvExpenseClaimDetail_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "EditRow": try { GridViewRow gvr = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); int RowIndex = gvr.RowIndex; lblIdDetail.Text = e.CommandArgument.ToString(); txtTravel_Date.Text = gvr.Cells[1].Text; txtCost_Code.Text = gvr.Cells[2].Text; txtCost_Description.Text = gvr.Cells[3].Text; txtCost_Value.Text = gvr.Cells[4].Text; txtQty.Text = gvr.Cells[5].Text; txtTotal_Cost.Text = gvr.Cells[6].Text; lbljudulCost.Text = "Ubah"; panelDetail.Visible = true; } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null); } break; case "DeleteRow ": try { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); _htParameters["p_ID"] = e.CommandArgument.ToString(); _dalEmpExclaimDetailDAL.Delete(_htParameters); BindGridClaim(); } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null); } break; } }
private void BindGridClaim() { EmpExclaimDetailDAL _dalEmpExclaimDetailDAL = null; Hashtable _htParameters = null; try { _dalEmpExclaimDetailDAL = new EmpExclaimDetailDAL(); _htParameters = new Hashtable(); if (txtExClaim_No.Text != "") { //Shared.BindGrvEmpExclaim(grvExpenseClaimDetail, txtSPD_No.Text); _htParameters["p_ExClaim_No"] = txtExClaim_No.Text; } else { _htParameters["p_SPD_No"] = txtSPD_No.Text; //Shared.BindGrvEmpExclaim(grvExpenseClaimDetail, txtExClaim_No.Text); } DataTable dt = new DataTable(); dt = _dalEmpExclaimDetailDAL.GetRows(_htParameters); grvExpenseClaimDetail.DataSource = dt; grvExpenseClaimDetail.DataBind(); if (dt.Rows.Count > 0) { decimal total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total_Cost")); grvExpenseClaimDetail.FooterRow.Cells[5].Text = "Total"; grvExpenseClaimDetail.FooterRow.Cells[5].HorizontalAlign = HorizontalAlign.Right; grvExpenseClaimDetail.FooterRow.Cells[5].Font.Bold = true; grvExpenseClaimDetail.FooterRow.Cells[6].HorizontalAlign = HorizontalAlign.Right; grvExpenseClaimDetail.FooterRow.Cells[6].Font.Bold = true; grvExpenseClaimDetail.FooterRow.Cells[6].Text = total.ToString("N2"); } } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null); } }