private void PostPageChanges() { // Unit int unitId = Int32.Parse(hdfUnitId.Value); // Service state string serviceState = "Unassigned"; if ((rbtnAssignToMyself.Checked) || (rbtnAssignToTeamMember.Checked) || (rbtnAssignToThirdPartyVendor.Checked)) serviceState = "Assigned"; if (ckbxAcceptSR.Checked) serviceState = "Accepted"; if (ckbxStartSR.Checked) serviceState = "In Progress"; if (ckbxCompleteSR.Checked) serviceState = "Completed"; // basic variables int companyId = Int32.Parse(hdfCompanyId.Value); bool mtoDot = Boolean.Parse(hdfMtoDto.Value); string serviceDescription = hdfDescription.Value; DateTime? assignDeadlineDate = null; if (hdfDeadlineDate.Value != "") assignDeadlineDate = DateTime.Parse(hdfDeadlineDate.Value); bool assignTeamMember = false; int? assignTeamMemberId = null; if ((hdfAssignToMyself.Value == "True") || (hdfAssignToTeamMember.Value == "True")) { assignTeamMember = true; assignTeamMemberId = Int32.Parse(hdfTeamMemberId.Value); } string assignThirdPartyVendor = ""; if (hdfThirdPartyVendor.Value != "") { assignThirdPartyVendor = hdfThirdPartyVendor.Value; } DateTime? assignDateTime = null; if (!rbtnUnassigned.Checked) assignDateTime = DateTime.Now; DateTime? acceptDateTime = null; if (ckbxAcceptSR.Checked) acceptDateTime = DateTime.Now; DateTime? unitOutOfServiceDate = null; if (hdfUnitOutOfServiceDate.Value != "") unitOutOfServiceDate = DateTime.Parse(hdfUnitOutOfServiceDate.Value); string unitOutOfServiceTime = hdfUnitOutOfServiceTime.Value; DateTime? completeWorkDateTime = null; if (ckbxCompleteSR.Checked) completeWorkDateTime = DateTime.Now; DateTime? unitBackInServiceDate = null; if (hdfUnitBackInServiceDate.Value != "") unitBackInServiceDate = DateTime.Parse(hdfUnitBackInServiceDate.Value); string unitBackInServiceTime = hdfUnitBackInServiceTime.Value; string completeWorkDetailDescription = hdfCompleteWorkDescription.Value; bool completeWorkDetailPreventable = Boolean.Parse(hdfCompleteWorkPreventable.Value); Decimal? completeWorkDetailTMLabourHours = null; if (hdfCompleteWorkLabourHours.Value != "") completeWorkDetailTMLabourHours = decimal.Parse(hdfCompleteWorkLabourHours.Value); Decimal? completeWorkDetailTMCost = null; if (hdfCompleteWorkCosts.Value != "") completeWorkDetailTMCost = decimal.Parse(hdfCompleteWorkCosts.Value); string completeWorkInvoiceNumber = ""; if (hdfInvoiceNumber.Value != "") completeWorkInvoiceNumber = hdfInvoiceNumber.Value; Decimal? completeWorkInvoiceAmount = null; if (hdfInvoiceAmount.Value != "") completeWorkInvoiceAmount = decimal.Parse(hdfInvoiceAmount.Value); string mileage = ""; if (hdfMileage.Value != "") mileage = hdfMileage.Value; string startWorkMileage = ""; if (hdfStartMileage.Value != "") startWorkMileage = hdfStartMileage.Value; string completeWorkMileage = ""; if (hdfCompleteWorkMileage.Value != "") completeWorkMileage = hdfCompleteWorkMileage.Value; int? ruleId = null; if (hdfRuleId.Value != "") ruleId = Int32.Parse(hdfRuleId.Value); // Insert to dataset ServicesAddRequestBasicInformation servicesAddRequestBasicInformation = new ServicesAddRequestBasicInformation(servicesAddRequestTDS); servicesAddRequestBasicInformation.Insert(serviceState, mtoDot, serviceDescription, assignDeadlineDate, assignDateTime, assignTeamMember, assignTeamMemberId, assignThirdPartyVendor, acceptDateTime, unitOutOfServiceDate, unitOutOfServiceTime, completeWorkDateTime, unitBackInServiceDate, unitBackInServiceTime, completeWorkDetailDescription, completeWorkDetailPreventable, completeWorkDetailTMLabourHours, completeWorkDetailTMCost, completeWorkInvoiceNumber, completeWorkInvoiceAmount, unitId, mileage, startWorkMileage, completeWorkMileage, false, companyId, ruleId); // Store session Session["servicesAddRequestTDS"] = servicesAddRequestTDS; }
private void UpdateDatabase() { DB.Open(); DB.BeginTransaction(); try { int companyId = Int32.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet()); int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId); DateTime dateTime_ = DateTime.Now; ServicesAddRequestBasicInformation servicesAddRequestBasicInformation = new ServicesAddRequestBasicInformation(servicesAddRequestTDS); int? serviceId = servicesAddRequestBasicInformation.Save(dateTime_, employeeId, companyId); // Save costs information if (serviceId.HasValue) { hdfNewServiceId.Value = serviceId.ToString(); ServicesAddRequestCostInformation servicesAddRequestCostInformation = new ServicesAddRequestCostInformation(servicesAddRequestTDS); servicesAddRequestCostInformation.Save((int)serviceId, companyId); } DB.CommitTransaction(); // Store datasets servicesAddRequestTDS.AcceptChanges(); Session["servicesAddRequestTDS"] = servicesAddRequestTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }