protected void grdOtherCostsByClientProject_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Other Gridview, if the gridview is edition mode if (grdOtherCostsByClientProject.EditIndex >= 0) { grdOtherCostsByClientProject.UpdateRow(grdOtherCostsByClientProject.EditIndex, true); } // Delete Other int projectId = (int)e.Keys["ProjectID"]; int refId = (int)e.Keys["RefID"]; // Delete costs details ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Delete(projectId, refId); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; }
protected void AddOtherCostsNewEmptyFix(GridView grdOtherCostsByClientProject) { if (grdOtherCostsByClientProject.Rows.Count == 0) { int companyId = Int32.Parse(hdfCompanyId.Value); ActualCostsAddTDS.OtherCostsDataTable dt = new ActualCostsAddTDS.OtherCostsDataTable(); dt.AddOtherCostsRow(-1, "", DateTime.Now, -1, -1, "", false, companyId, false, "", 0, "", "", 1); Session["otherCostsByClientProjectDummy"] = dt; grdOtherCostsByClientProject.DataBind(); } // normally executes at all postbacks if (grdOtherCostsByClientProject.Rows.Count == 1) { ActualCostsAddTDS.OtherCostsDataTable dt = (ActualCostsAddTDS.OtherCostsDataTable)Session["otherCostsByClientProjectDummy"]; if (dt != null) { grdOtherCostsByClientProject.Rows[0].Visible = false; grdOtherCostsByClientProject.Rows[0].Controls.Clear(); } } }
// //////////////////////////////////////////////////////////////////////// // STEP7 - OTHER COMPANIES COST BY CLIENT AND PROJECT - PUBLIC METHODS // public ActualCostsAddTDS.OtherCostsDataTable GetOtherDetailOtherByClientProject() { otherCosts = (ActualCostsAddTDS.OtherCostsDataTable)Session["otherCostsByClientProjectDummy"]; if (otherCosts == null) { otherCosts = ((ActualCostsAddTDS.OtherCostsDataTable)Session["otherCosts"]); } return otherCosts; }
private void grdOtherCostsByClientProjectDetailAdd() { if (FooterValidateOtherByClientProject()) { Page.Validate("DataNewOtherByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); DateTime date = (DateTime)((RadDatePicker)grdOtherCostsByClientProject.FooterRow.FindControl("tkrdpDateFooterOtherByClientProject")).SelectedDate; string category = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlCategoryFooterOtherByClientProject")).Text; string name = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlCategoryFooterOtherByClientProject")).SelectedItem.Text; int clientId = Int32.Parse(((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlClientFooterOtherByClientProject")).SelectedValue); string client = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlClientFooterOtherByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlProjectFooterOtherByClientProject")).SelectedValue); string project = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlProjectFooterOtherByClientProject")).SelectedItem.Text; decimal rate = decimal.Round(decimal.Parse(((TextBox)grdOtherCostsByClientProject.FooterRow.FindControl("tbxRateFooterOtherByClientProject")).Text), 2); string comment = ((TextBox)grdOtherCostsByClientProject.FooterRow.FindControl("tbxCommentFooterOtherByClientProject")).Text; bool deleted = false; bool inDatabase = false; decimal rateCad = 0; decimal rateUsd = 0; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); if (projectGateway.GetCountryID(projectId) == 1) //Canada { rateCad = rate; rateUsd = rate; } else { rateCad = rate; rateUsd = rate; } // Insert Data ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Insert(projectId, category, date, rateCad, rateUsd, comment, deleted, companyId, inDatabase, name, client, project, clientId); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; grdOtherCostsByClientProject.DataBind(); grdOtherCostsByClientProject.PageIndex = grdOtherCostsByClientProject.PageCount - 1; } } }
protected void grdOtherCostsByClientProject_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("DataEditOtherByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); int refId = Int32.Parse(((Label)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("lblRefIdEditOtherByClientProject")).Text); DateTime date = (DateTime)((RadDatePicker)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tkrdpDateEditOtherByClientProject")).SelectedDate; string category = ((DropDownList)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("ddlCategoryEditOtherByClientProject")).Text; string name = ((DropDownList)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("ddlCategoryEditOtherByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((Label)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("lblProjectIdEditOtherByClientProject")).Text); decimal rate = decimal.Round(decimal.Parse(((TextBox)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tbxRateEditOtherByClientProject")).Text), 2); decimal rateCad = 0; decimal rateUsd = 0; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); if (projectGateway.GetCountryID(projectId) == 1) //Canada { rateCad = rate; } else { rateUsd = rate; } string comment = ((TextBox)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tbxCommentEditOtherByClientProject")).Text; bool deleted = false; // Update Data ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Update(projectId, refId, category, date, rateCad, rateUsd, comment, deleted, companyId, name); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; } else { e.Cancel = true; } }