private bool GenerateInvoice(EightHundredEntities context, tbl_Job job, Guid userId) { ClearJobTasks(context, job.JobID); UpdatePaymentsInJob(context, job.JobID); var jsonData = context.tbl_HVAC_Answers.Single( item => item.tbl_HVAC_CustomersAnswers.JobID == job.JobID && item.tbl_HVAC_CustomersAnswers.UserID == userId && item.QuestionID == 35).Data; /*{"Jobs": * [ [ * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1} * ],"id":1337316467855}, * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd3","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":2,"TotalPrice":"$14,760.00"} * ],"id":1337316467857}, * {"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","JobCode":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","ResAccountCode":"41000","Count":1,"Price":895,"TotalPrice":"$895.00"}, * {"id":"ACC-HUM001","isAccessory":true,"Code":"ACC-HUM001","JobCode":"ACC-HUM001","Description":"Humidifier","ResAccountCode":"41000","Count":3,"Price":595,"TotalPrice":"$1,785.00"} * ], * "MainSystem":{"Parts":[{"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1}],"TotalPrice":7380,"id":"LE","AFUE":"80","SEER":"12","JobCodeId":0,"JobCode":"LE-HPAH136","ResAccountCode":"41000","Description":"SEER Rating 12, AFUE 80, LE-3 Ton Air Handler Electric Heat - 10KW","Count":1,"Price":7380},"TotalAmount":24820,"Tax":0,"GrandTotal":24820,"TaxRate":0} */ //{"Jobs":[{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863188},{"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","Count":1,"Price":895,"TotalPrice":"$895.00"},{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863190}],"MainSystem":{"Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"TotalPrice":12488,"id":"SE","AFUE":"29","SEER":"16","JobCodeId":0,"JobCode":"SE-HPGFV30","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Count":1,"Price":12488},"TotalAmount":25871,"Tax":0,"GrandTotal":25871,"TaxRate":0} //var jsonData = "{\"Jobs\":[" + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863188}," + // "{\"id\":\"ACC-CMF001\",\"isAccessory\":true,\"Code\":\"ACC-CMF001\",\"JobCode\":\"ACC-CMF001\",,\"Description\":\"1\\\" Charged Media Filter, 20 x 25\",\"Count\":1,\"Price\":895,\"TotalPrice\":\"$895.00\"}," + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863190}]," + // "\"MainSystem\":{\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"TotalPrice\":12488,\"id\":\"SE\",\"AFUE\":\"29\",\"SEER\":\"16\",\"JobCodeId\":0,\"JobCode\":\"SE-HPGFV30\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Count\":1,\"Price\":12488}," + // "\"TotalAmount\":25871," + // "\"Tax\":0," + // "\"GrandTotal\":25871," + // "\"TaxRate\":0}"; //var jsonData33 = context.tbl_HVAC_Answers.Single( // item => // item.tbl_HVAC_CustomersAnswers.JobID == jobId && item.tbl_HVAC_CustomersAnswers.UserID == userId && // item.QuestionID == 33).Data; var prMainJobs = DeserialiseMainJobs(jsonData); var prAccessories = DeserialiseAccessoriesJobs(jsonData); SetJobTasks(context, prMainJobs, prAccessories); var pr = JSONHelper.Deserialise <PriceListModel <SystemInfoModelWithParts> >(jsonData); job.SubTotal = decimal.Parse(pr.TotalAmount); job.TaxAmount = decimal.Parse(pr.Tax); job.TotalSales = decimal.Parse(pr.GrandTotal); context.SaveChanges(); return(true); }
private void MarkInvoiced(int id, DateTime invoiceDate) { var job = new tbl_Job { JobID = id }; using (var ctx = new EightHundredEntities(UserKey)) { ctx.tbl_Job.Attach(job); job.InvoicedDate = invoiceDate; ctx.SaveChanges(); } }
public JsonResult AddNganh(tbl_Job md) { var service = new S(ConfigurationManager.ConnectionStrings["CotoidayCon"].ConnectionString, true); //isDebug = true -> show error message in response object, uid is logged user id var obj = new GCRequest { _a = "Inserttbl_Job", //Action prefix f,p for get data; gc_App is table name _d = new Dictionary <string, object> { { "Name", md.Name }, { "Code", md.Code } } }; var robj = service.P(obj); // {Result: 0 is failed, 1 is success, Records: List object array, TotalRecordCount: number of records, Message: error content } return(Json(robj.Result)); }
public JsonResult DeleteNganh(tbl_Job md) { var service = new S(ConfigurationManager.ConnectionStrings["CotoidayCon"].ConnectionString, true); //isDebug = true -> show error message in response object, uid is logged user id var obj = new GCRequest { _a = "Updatetbl_Job", //Action prefix f,p for get data; gc_App is table name _c = new Dictionary <string, object> { { "Id", md.Id } }, _d = new Dictionary <string, object> { { "Status", 0 } } }; var robj = service.P(obj); return(Json(robj.Result)); }
private bool WaitEstimateJob(EightHundredEntities contex, tbl_Job job) { job.StatusID = 13; contex.SaveChanges(); return(true); }
private bool CompleteJob(EightHundredEntities context, tbl_Job job) { job.StatusID = 6; context.SaveChanges(); return(true); }
public JsonResult SaveJob(tbl_Job job, string trackId) { var messages = new List <string>(); var result = new SaveResult(); result.Success = false; try { job.ScheduleStart = GetJobStartDate(job.ServiceWindowID, job.ServiceDate.GetValueOrDefault()); job.ScheduleEnd = job.ScheduleStart.GetValueOrDefault().AddHours(job.ServiceLength.GetValueOrDefault()); job.ServiceProID = 127; // default to N/A if (job.CustomerID == 0) { messages.Add("No customer selected for this job."); } if (job.LocationID == 0) { messages.Add("No job location selected for this job."); } if (job.ServiceDate.GetValueOrDefault() == default(DateTime)) { messages.Add("Please select a Service Date for the job."); } if (job.ExpectedPayTypeID == 7 && !CheckCreditTermsInternal(job.FranchiseID, job.CustomerID)) { messages.Add("The customer has no credit terms set up with this franchise. Please select a different payment type."); } if (job.ScheduleStart < DateTime.Now) { messages.Add("The Service Date for this job occurs in the past."); } using (var jobContext = GetContext()) { if (job.AreaID != 0) { var dba = jobContext.tbl_Dispatch_DBA.Select(d => new { d.DBAID, d.DBAName, d.FranchiseID }).FirstOrDefault(d => d.DBAID == job.AreaID); if (dba == null) { messages.Add("The specified DBA cannot be found."); } else { if (dba.FranchiseID != job.FranchiseID) { messages.Add(string.Format("The specified DBA ({0}) is not valid for the selected franchise.", dba.DBAName)); } } } if (messages.Count != 0) { result.Messages = messages.ToArray(); } else { var hasInfoRecord = jobContext.tbl_Customer_Info.Any(c => c.CustomerID == job.CustomerID); if (!hasInfoRecord) { var newInfo = tbl_Customer_Info.Createtbl_Customer_Info(default(int), job.FranchiseID, job.CustomerID, 2, 0, 2, 0, 0); jobContext.AddTotbl_Customer_Info(newInfo); } job.CallTaker = UserInfo.UserKey.ToString(); jobContext.AddTotbl_Job(job); jobContext.SaveChanges(); try { int trackNum; if (int.TryParse(trackId, out trackNum)) { var stat = db.StatisticTracks.SingleOrDefault(s => s.TrackId == trackNum); if (stat != null) { stat.Duration = DateTime.Now - stat.StartDate; stat.OptionId = 1; stat.Jobid = job.JobID; db.SaveChanges(); } } }catch (Exception ex) { Logger.Log("Could not track call statistic", ex, LogLevel.Error); } result.Success = true; result.SavedId = job.JobID; result.Messages = new[] { "Job saved successfully." }; } } } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } result.Messages = new[] { ex.Message }; } if (result.Success) { var type = job.JobPriorityID == 4 ? AlertType.RecallBooked : (job.ServiceID == 10 ? AlertType.HvacSalesAlert : AlertType.AppointmentBooked); AbstractBusinessService.Create <AlertEngine>(UserInfo.UserKey).SendAlert(type, job.FranchiseID); } return(Json(result)); }
partial void Deletetbl_Job(tbl_Job instance);
partial void Updatetbl_Job(tbl_Job instance);
partial void Inserttbl_Job(tbl_Job instance);