public void Delete() { //Delivery Note WO_Shipping ws = _db.WO_Shipping.FirstOrDefault(x => x.WoID == _woID); if (ws == null) { return; } _db.Entry(ws).State = EntityState.Deleted; _db.SaveChanges(); //Shipping Items List <WO_ShippingItem> items = _db.WO_ShippingItem.Where(x => x.WoID == _woID).ToList(); if (items.Count == 0) { return; } foreach (WO_ShippingItem item in items) { _db.Entry(item).State = EntityState.Deleted; } _db.SaveChanges(); }
public void UpdateSpecialFieldFromEstimation() { List <Quote_Item> items = _db.Quote_Item.Where(x => x.quoteRevID == _quoteRevID && (_quoteItemID == 0 || x.quoteItemID == _quoteItemID) ).ToList(); if (items.Count == 0) { return; } foreach (Quote_Item item in items) { int estItemID = item.estItemID; if (estItemID == 0) { continue; } var estItem = new MyEstItem(estItemID); item.SerialID = estItem.Value.SerialID.ToString(""); item.Position = estItem.Value.Position; item.qiDescription = estItem.GetDescriptionWithHtmlBreak(); _db.Entry(item).State = EntityState.Modified; } _db.SaveChanges(); }
private void UpdateInvoiceItem(int estRevID, string salesforceItemID, long invoiceItemID, string itemName, string requirement, string description, double?itemCost, double?quality, double?itemOrder) { try { var invoiceItem = _db.Invoice_Item.Where(x => x.quoteItemID == invoiceItemID).FirstOrDefault(); if (invoiceItem != null) { int estItemID = CommonMethods.GetEstimationItemID(estRevID, itemName); if (estItemID != 0) { invoiceItem.estItemID = estItemID; } invoiceItem.qiItemTitle = itemName; if (description != null) { invoiceItem.qiDescription = description; } else { invoiceItem.qiDescription = ""; } int requirementID = 10; var jobType = _db.FW_JOB_TYPE.Where(x => x.JOB_TYPE.Trim() == requirement.Trim()).FirstOrDefault(); if (jobType != null) { requirementID = jobType.QUOTE_SUPPLY_TYPE; } else { LogMethods.Log.Warn("UpdateInvoiceItem:Warn:" + "Requirement of " + requirement + " doesn't exist on FW_JOB_TYPE table."); } invoiceItem.supplyType = Convert.ToInt16(requirementID); if (itemCost != null) { invoiceItem.qiAmount = Convert.ToDecimal(itemCost); invoiceItem.qiAmountText = "$" + itemCost; } if (quality != null) { invoiceItem.qiQty = Convert.ToInt16(quality); } if (itemOrder != null) { invoiceItem.qiPrintOrder = Convert.ToInt16(itemOrder); } _db.Entry(invoiceItem).State = EntityState.Modified; _db.SaveChanges(); } } catch (Exception e) { LogMethods.Log.Error("UpdateInvoiceItem:Error:" + e.Message); } }
public void Submit() { Value.Status = 603; Value.SubmitTime = DateTime.Now; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); }
private void UpdateLOSSNContract(int quoteRevID) { var sales_JobMasterList_quoteRev = _db.Sales_JobMasterList_QuoteRev.Where(x => x.quoteRevID == quoteRevID).FirstOrDefault(); if (sales_JobMasterList_quoteRev != null) { sales_JobMasterList_quoteRev.quoteStatus = (int)NJobStatus.Loss; //WIN status is defined in Sales_JobStatus _db.Entry(sales_JobMasterList_quoteRev).State = EntityState.Modified; _db.SaveChanges(); } }
public void GenerateMySelfSerialID() { Sales_JobMasterList_Invoice invoice = _db.Sales_JobMasterList_Invoice.Find(_invoiceID); int jobID = invoice.jobID; Sales_JobMasterList project = _db.Sales_JobMasterList.Find(jobID); int lastItemID = project.LastInvoiceItemID; project.LastInvoiceItemID = lastItemID + 1; _db.Entry(project).State = EntityState.Modified; Invoice_Item item = _db.Invoice_Item.Find(_itemID); item.SerialID = "I" + (lastItemID + 1).ToString("D2"); _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); }
public void Delete() { if (_task != null) { _dbml.Entry(_task).State = EntityState.Deleted; _dbml.SaveChanges(); } }
public void GenerateMySelfSerialID() { Sales_JobMasterList_WO wo = _db.Sales_JobMasterList_WO.Find(_woID); int jobID = wo.jobID; Sales_JobMasterList project = _db.Sales_JobMasterList.Find(jobID); int lastItemID = project.LastWorkorderItemID; project.LastWorkorderItemID = lastItemID + 1; _db.Entry(project).State = EntityState.Modified; WO_Item item = _db.WO_Item.Find(_itemID); item.SerialID = "W" + (lastItemID + 1).ToString("D2"); _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); }
public void UpdateWorkorderAmount() { double currentWorkorderItemAmount = _db.WO_Item.Where(x => x.woID == _woID).Sum(y => y.qiAmount); Value.WorkorderAmount = currentWorkorderItemAmount; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); }
public void UpdateTaskes() { List <Sales_Wip> internalTaskes = _dbml.Sales_Wip.Where(x => x.JobID == _jobID).ToList(); foreach (Sales_Wip task in internalTaskes) { task.Status = 90; task.LastUpdatedAt = DateTime.Now; task.LastUpdatedBy = _employeeID; _dbml.Entry(task).State = EntityState.Modified; } _dbml.SaveChanges(); }
public void UpdateWinner(string winnerName, double winningAmount) { if (_bid == null) { return; } try { _bid.Winner = winnerName; _bid.WinnerAmount = winningAmount; _db.Entry(_bid).State = EntityState.Modified; _db.SaveChanges(); } catch (Exception e) { var s = e.Message; throw; } finally { } }
private void UpdateNewDueTime(DateTime requiredTime) { int taskCategory = Convert.ToInt32(_task.TaskType); var tp = new TaskPropertyResponseLeadtime(taskCategory); int leadTime = tp.Leadtime; _task.Rush = false; int hours = MyDateTime.GetDiffHoursOfWeekday(Convert.ToDateTime(_task.SubmitTime), requiredTime); if (hours < leadTime) { _task.Rush = true; } _task.RequiredTime = requiredTime; _task.LastUpdateTime = DateTime.Now; _db.Entry(_task).State = EntityState.Modified; _db.SaveChanges(); }
private void HandleApprovalStatus(string sfWorkOrderID, int jobId, int estRevID, int woId, int userEmployeeID, string remarks, DateTime?dueDate, string rush, string woType, enterprise.QueryResult result, double?version, DateTime?issueDateTime) { try { if (version == null) { return; } short ver = Convert.ToInt16(version); var sales_Dispatching = _db.Sales_Dispatching.Where(x => x.JobID == jobId && x.TaskType == 720 && x.WoID == woId && x.Importance == ver).FirstOrDefault(); if (sales_Dispatching == null) { //create service client to call API endpoint using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr)) { if (result == null || (result != null && result.size == 0)) { return; } //cast query results IEnumerable <enterprise.ProcessInstance> processInstanceList = result.records.Cast <enterprise.ProcessInstance>(); //show results foreach (var el in processInstanceList) { if (el.Status == "Pending") { int taskCategory = 720; //-- [Work order Approval] is defined in Sales_Dispatching_Task_Category int submitBy = userEmployeeID; string taskFromWhere = "wip"; // coresponding to stage of 2 TaskSubmitFactory foTaskSubmit = new TaskSubmitFactory(taskCategory, submitBy, taskFromWhere); TaskSubmit dp = foTaskSubmit.ObjTaskSubmit; dp.ParameterDispatchingTask.Responsible = 8; // Mr. Fan is approved it dp.ParameterDispatchingTask.JobId = jobId; dp.ParameterDispatchingTask.EstRevId = estRevID; dp.ParameterDispatchingTask.WoId = woId; dp.ParameterDispatchingTask.Subject = "Workorder approval"; //DispatchingTaskEN.NDispatchingTaskPurpose.WorkorderApproval if (!string.IsNullOrEmpty(remarks)) { dp.ParameterDispatchingTask.Description = remarks.Trim(); } if (dueDate != null) { dp.ParameterDispatchingTask.RequiredTime = (DateTime)dueDate; } else { dp.ParameterDispatchingTask.RequiredTime = DateTime.Now.AddDays(1); } if (issueDateTime != null) { dp.ParameterDispatchingTask.SubmitTime = issueDateTime.Value.ToLocalTime(); } else { dp.ParameterDispatchingTask.SubmitTime = DateTime.Now; } switch (rush) { case "Yes": dp.ParameterDispatchingTask.Rush = true; break; default: dp.ParameterDispatchingTask.Rush = false; break; } switch (woType) { case "Production": dp.ParameterDispatchingTask.WorkorderType = 10; break; case "Service": dp.ParameterDispatchingTask.WorkorderType = 20; break; case "Site Check": dp.ParameterDispatchingTask.WorkorderType = 30; break; default: break; } dp.EnableDuplicateSubmit = true; dp.Insert(ver); } } LogMethods.Log.Debug("HandleApprovalStatus:Debug:" + "Done"); } } else { // this work order has been submitted using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr)) { if (result == null || (result != null && result.size == 0)) { return; } //cast query results IEnumerable <enterprise.ProcessInstance> processInstanceList = result.records.Cast <enterprise.ProcessInstance>(); //show results foreach (var el in processInstanceList) { if (el.Status == "Removed") { var workOrder = _db.Sales_JobMasterList_WO.Where(x => x.woID == sales_Dispatching.WoID).FirstOrDefault(); if (workOrder != null) { workOrder.woStatus = (short)NJobStatus.woNew; } _db.Entry(workOrder).State = EntityState.Modified; _db.SaveChanges(); /* delete a row in Sales_Dispatching */ _db.Sales_Dispatching.Remove(sales_Dispatching); _db.SaveChanges(); } } } } } catch (Exception e) { LogMethods.Log.Error("HandleApprovalStatus:Error:" + e.Message); } }
public void UpdateGivenBy(int givenByCompanyID) { Value.ProjectGiveBy = givenByCompanyID; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); }
private void UpdateProjectID() { _biddingJob.JobID = NewJobID; _db.Entry(_biddingJob).State = EntityState.Modified; _db.SaveChanges(); }
public void ImportAddressFromCustomer(string importCustomerType) { //Subcontract-->Project-->IsInstallTo->Contact and Customer var workorder = new MyWorkorder(Value.WoID); var msc = new MySalesJobMasterListCustomer(workorder.Value.jobID); if (importCustomerType == "InstallTo") { msc.SetInstallTo(); } if (importCustomerType == "QuoteTo") { msc.SetQuoteTo(); } if (importCustomerType == "BillTo") { msc.SetBillTo(); } var mc = new MyCustomer(msc.CustomerID); _customer = mc.Value; var mcc = new MyCustomerContact(msc.ContactID); _contact = mcc.Value; if (_customer != null) { string addr = _customer.ADDR_1; if (!Convert.IsDBNull(_customer.ADDR_2)) { addr = addr + " " + _customer.ADDR_2; } Value.Address = addr; Value.City = _customer.CITY; Value.Postcode = _customer.ZIPCODE; Value.Province = _customer.STATE; Value.ShipToName = _customer.NAME; string attenName = MyConvert.ConvertToString(_contact.CONTACT_HONORIFIC) + " "; attenName += MyConvert.ConvertToString(_contact.CONTACT_FIRST_NAME) + " "; attenName += MyConvert.ConvertToString(_contact.CONTACT_LAST_NAME); Value.AttnName = attenName.Trim(); Value.AttnPhone = MyConvert.ConvertToString(_contact.CONTACT_PHONE); //For Delivery Note Value.DeliveryDate = DateTime.Today; Value.WorkorderNumber = workorder.Value.WorkorderNumber; var emp = new FsEmployee(Convert.ToInt32(workorder.Value.Sales)); Value.AeName = emp.NickName; Value.AePhone = emp.GetCompanyPhoneExtension(); Value.InvoiceNumber = workorder.GetInvoices(); Value.NoteTypeID = 0; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); Result = "ok"; } else { Result = "Could not find the specified Customer."; } }