public static void BindGrvEmpSPDCost(GridView gvw, string p_SPD_No) { EmpSPDCostDAL _dalEmpSPDCostDAL = null; Hashtable _htParameters = null; try { _dalEmpSPDCostDAL = new EmpSPDCostDAL(); _htParameters = new Hashtable(); _htParameters["p_SPD_No"] = p_SPD_No; DataTable dt = new DataTable(); dt = _dalEmpSPDCostDAL.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[2].Text = "Total"; gvw.FooterRow.Cells[2].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[5].HorizontalAlign = HorizontalAlign.Right; gvw.FooterRow.Cells[2].Font.Bold = true; gvw.FooterRow.Cells[5].Font.Bold = true; gvw.FooterRow.Cells[5].Text = total.ToString("N2"); } } catch (Exception ex) { throw ex; } }
protected void grvCost_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "EditRow": try { GridViewRow gvr = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); int RowIndex = gvr.RowIndex; txtCost_Code.Text = gvr.Cells[1].Text; txtCost_Description.Text = gvr.Cells[2].Text; txtCost_Value.Text = gvr.Cells[3].Text; txtQty.Text = gvr.Cells[4].Text; txtTotal_Cost.Text = gvr.Cells[5].Text; lblIDCost.Text = e.CommandArgument.ToString(); //mdlPopupGetCost.Show(); lbljudulCost.Text = "Ubah"; panelDetail.Visible = true; } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null); } break; case "DeleteRow ": try { EmpSPDCostDAL _dalEmpSPDCostDAL = null; Hashtable _htParameters = null; _dalEmpSPDCostDAL = new EmpSPDCostDAL(); _htParameters = new Hashtable(); _htParameters["p_ID"] = e.CommandArgument.ToString(); _dalEmpSPDCostDAL.Delete(_htParameters); Shared.BindGrvEmpSPDCost(grvCost, txtSPD_No.Text); Utility.ShowMessageBox(this, Utility.DELETE_VALIDATION_SUCCESS_MESSAGE, null, "spddtl.aspx?action=edt&page=2&id=" + Request.Params["id"]); } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null); } break; } }
protected void btnSaveCost_Click(object sender, EventArgs e) { EmpSPDCostDAL _dalEmpSPDCostDAL = null; Hashtable _htParameters = null; int iNextID = 0; try { _dalEmpSPDCostDAL = new EmpSPDCostDAL(); _htParameters = new Hashtable(); MPF23.Shared.Mapper.UIToDB.Map(UpCost.Controls, _htParameters); Utility.ApplyDefaultProp(_htParameters); if (lbljudulCost.Text == "Ubah") { _htParameters["p_ID"] = lblIDCost.Text; _htParameters["p_SPD_No"] = txtSPD_No.Text; _dalEmpSPDCostDAL.Update(_htParameters); iNextID = Int32.Parse(lblIDCost.Text); } else { _htParameters["p_SPD_No"] = txtSPD_No.Text; _dalEmpSPDCostDAL.Insert(_htParameters, ref iNextID); } //Utility.ShowMessageBox(this, Utility.SAVE_DATA_SUCCESS_MESSAGE, null, null); mdlPopupGetCost.Hide(); Utility.ShowMessageBox(this, Utility.SAVE_DATA_SUCCESS_MESSAGE, null, "spddtl.aspx?action=edt&page=2&id=" + Request.Params["id"]); //LoadData(); //LoadDataCost(); // } catch (Exception ex) { Utility.ShowMessageBox(this, Utility.SAVE_DATA_FAIL_MESSAGE, ex, null); } }