protected void grdHotels_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Validate general data Page.Validate("hotelEdit"); if (Page.IsValid) { int costingSheetId = (int)e.Keys["CostingSheetID"]; int hotelId = (int)e.Keys["HotelID"]; int refId = (int)e.Keys["RefID"]; int companyId = Int32.Parse(hdfCompanyId.Value); decimal rate = Decimal.Parse(((TextBox)grdHotels.Rows[e.RowIndex].Cells[0].FindControl("tbxRateEdit")).Text.Trim()); DateTime startDate = ((RadDatePicker)grdHotels.Rows[e.RowIndex].Cells[0].FindControl("tkrdpStartDateEdit")).SelectedDate.Value; DateTime endDate = ((RadDatePicker)grdHotels.Rows[e.RowIndex].Cells[0].FindControl("tkrdpEndDateEdit")).SelectedDate.Value; // Update data ProjectCostingSheetAddHotelsInformation model = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); model.Update(costingSheetId, hotelId, refId, rate, false, companyId, startDate, endDate); // Store dataset hotelsInformation = (ProjectCostingSheetAddTDS.HotelsInformationDataTable)model.Table; Session["hotelsInformation"] = hotelsInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepHotelsInformationProcessGrid(); } else { e.Cancel = true; } }
protected void grdHotels_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Hotels Gridview, if the gridview is edition mode if (grdHotels.EditIndex >= 0) { grdHotels.UpdateRow(grdHotels.EditIndex, true); } // Delete hotel int costingSheetId = (int)e.Keys["CostingSheetID"]; int hotelId = (int)e.Keys["HotelID"]; int refId = (int)e.Keys["RefID"]; ProjectCostingSheetAddHotelsInformation model = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); model.Delete(costingSheetId, hotelId, refId); // Store dataset hotelsInformation = (ProjectCostingSheetAddTDS.HotelsInformationDataTable)model.Table; Session["hotelsInformation"] = hotelsInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepHotelsInformationProcessGrid(); }
private void UpdateDatabase() { DB.Open(); DB.BeginTransaction(); try { int companyId = Int32.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); if (cbxEndConfirm.Checked) { ProjectCostingSheetAddBasicInformation projectCostingSheetAddBasicInformation = new ProjectCostingSheetAddBasicInformation(projectCostingSheetAddTDS); int costingSheetId = projectCostingSheetAddBasicInformation.Save(companyId); hdfCostingSheetId.Value = costingSheetId.ToString(); // Save costs information ProjectCostingSheetAddLabourHoursInformation projectCostingSheetAddLabourHoursInformation = new ProjectCostingSheetAddLabourHoursInformation(projectCostingSheetAddTDS); projectCostingSheetAddLabourHoursInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddUnitsInformation projectCostingSheetAddUnitsInformation = new ProjectCostingSheetAddUnitsInformation(projectCostingSheetAddTDS); projectCostingSheetAddUnitsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddMaterialsInformation projectCostingSheetAddMaterialsInformation = new ProjectCostingSheetAddMaterialsInformation(projectCostingSheetAddTDS); projectCostingSheetAddMaterialsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddSubcontractorsInformation projectCostingSheetAddSubcontractorsInformation = new ProjectCostingSheetAddSubcontractorsInformation(projectCostingSheetAddTDS); projectCostingSheetAddSubcontractorsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddOtherCostsInformation projectCostingSheetAddOtherCostsInformation = new ProjectCostingSheetAddOtherCostsInformation(projectCostingSheetAddTDS); projectCostingSheetAddOtherCostsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddHotelsInformation projectCostingSheetAddHotelsInformation = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); projectCostingSheetAddHotelsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddBondingsInformation projectCostingSheetAddBondingsInformation = new ProjectCostingSheetAddBondingsInformation(projectCostingSheetAddTDS); projectCostingSheetAddBondingsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddInsurancesInformation projectCostingSheetAddInsurancesInformation = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); projectCostingSheetAddInsurancesInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddOtherCategoryInformation projectCostingSheetAddOtherCategoryInformation = new ProjectCostingSheetAddOtherCategoryInformation(projectCostingSheetAddTDS); projectCostingSheetAddOtherCategoryInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddRevenueInformation projectCostingSheetAddRevenueInformation = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); projectCostingSheetAddRevenueInformation.Save(companyId, costingSheetId); if (rbtnBeginTemplate.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } } else { if (cbxEndSave.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } else { if (rbtnBeginTemplate.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } } } DB.CommitTransaction(); // Store datasets projectCostingSheetAddTDS.AcceptChanges(); Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP7 - HOTEL INFORMATION // // //////////////////////////////////////////////////////////////////////// // STEP7 - HOTEL INFORMATION - EVENTS // protected void grdHotels_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Add": // Hotels Gridview, if the gridview is edition mode if (grdHotels.EditIndex >= 0) { grdHotels.UpdateRow(grdHotels.EditIndex, true); } // Validate general data Page.Validate("hotelNew"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); int hotelId = Int32.Parse(((DropDownList)grdHotels.FooterRow.FindControl("ddlHotelNew")).SelectedValue); string hotel = ((DropDownList)grdHotels.FooterRow.FindControl("ddlHotelNew")).SelectedItem.Text; decimal rate = Decimal.Parse(((TextBox)grdHotels.FooterRow.FindControl("tbxRateNew")).Text.Trim()); DateTime startDate = ((RadDatePicker)grdHotels.FooterRow.FindControl("tkrdpStartDateNew")).SelectedDate.Value; DateTime endDate = ((RadDatePicker)grdHotels.FooterRow.FindControl("tkrdpEndDateNew")).SelectedDate.Value; ProjectCostingSheetAddHotelsInformation model = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); model.Insert(0, hotelId, rate, false, companyId, startDate, endDate, hotel); Session.Remove("hotelsInformationDummy"); hotelsInformation = (ProjectCostingSheetAddTDS.HotelsInformationDataTable)model.Table; Session["hotelsInformation"] = hotelsInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; grdHotels.DataBind(); StepHotelsInformationProcessGrid(); } break; } }
// //////////////////////////////////////////////////////////////////////// // STEP7 - HOTEL INFORMATION - METHODS // private void StepHotelsInformationIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please verify Hotels information"; // Load ProjectCostingSheetAddHotelsInformation model = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); if (projectCostingSheetAddTDS.HotelsInformation.Rows.Count <= 0) { model.Load(int.Parse(hdfProjectId.Value), tkrdpFrom.SelectedDate.Value, tkrdpTo.SelectedDate.Value, int.Parse(hdfCompanyId.Value)); } // Store tables Session.Remove("hotelsInformationDummy"); hotelsInformation = (ProjectCostingSheetAddTDS.HotelsInformationDataTable)model.Table; Session["hotelsInformation"] = hotelsInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; // Validate grid columns int projectId = Int32.Parse(hdfProjectId.Value); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); if (projectGateway.GetCountryID(projectId) == 1) //Canada { // Hotels Grid lblHotelsTotalCosts.Text = "Total Cost (CAD) : "; tbxHotelsTotalCostsCAD.Visible = true; tbxHotelsTotalCostsUSD.Visible = false; } else { // Hotels Grid lblHotelsTotalCosts.Text = "Total Cost (USD) : "; tbxHotelsTotalCostsCAD.Visible = false; tbxHotelsTotalCostsUSD.Visible = true; } grdHotels.DataBind(); StepHotelsInformationProcessGrid(); }