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(); }
private int CreateNewProject() { //Insert New Record var job = new Sales_JobMasterList(); job.jobNumber = "ToBeAssigned"; job.sales = _ep.Kam; job.sa1ID = Convert.ToInt32(EmployeeEN.NEmployeeIDDefault.NullSales110); job.startTimeStamp = DateTime.Now; job.JobStatus = Convert.ToInt16(NJobStatus.ProjectNew); job.subProject = 0; job.yearNumber = Convert.ToInt16(System.DateTime.Today.Year - 2000); job.jobTitle = "From Lead -" + _ep.CustomString1; job.StatusChanged = true; job.ProductLine = 1; // Convert.ToInt32(CommissionEN.ProductLine.Signage); job.Rush = true; job.Customer = _ep.CustomerID; job.LeadID = _ep.CustomInt2; job.targetDate = DateTime.Today.AddMonths(1); _dbProject.Sales_JobMasterList.Add(job); _dbProject.SaveChanges(); //Job Number job.jobNumber = GetJobNumber(job.jobID); return(job.jobID); }
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 DeleteAllDeletedInvoiceItems(string[] items, string sfInvoiceID) { try { List <string> ids = CommonMethods.GetAllSalesForceID(TableName.Invoice_Item, sfInvoiceID, salesForceProjectID); foreach (string i in ids) { // not found if (Array.IndexOf(items, i) == -1) { // get MISID int itemIDTemp = CommonMethods.GetMISID(TableName.Invoice_Item, i, sfInvoiceID, salesForceProjectID); // get a row var invoiceItem = _db.Invoice_Item.Where(x => x.quoteItemID == itemIDTemp).FirstOrDefault(); if (invoiceItem != null) { _db.Invoice_Item.Remove(invoiceItem); _db.SaveChanges(); } // remove MISID out of MISSalesForceMapping CommonMethods.Delete(TableName.Invoice_Item, i, sfInvoiceID, salesForceProjectID); } } } catch (Exception e) { LogMethods.Log.Error("DeleteAllDeletedInvoiceItems: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 CreateNewTaskes() { var dbml = new ProjectModelDbEntities(); List <tblWipTask> taskes = dbml.tblWipTasks.Where(x => x.IsPublic).ToList(); foreach (tblWipTask task in taskes) { var newTask = new Sales_WipPublic { JobID = _jobID, estRevID = 0, quoteRevID = 0, woID = 0, invoiceID = 0, Priority = 0, ContentID = task.ContentID, Contents = task.PublicContentName, Status = 0, ScheduleStartDate = DateTime.Today, ScheduleFinishDate = DateTime.Today.AddDays(task.LeadTime), Responsible = _employeeID, CreatedBy = _employeeID, LastUpdatedAt = DateTime.Now, LastUpdatedBy = _employeeID }; dbml.Sales_WipPublic.Add(newTask); } dbml.SaveChanges(); }
public void AddOtherTask() { var dbml = new ProjectModelDbEntities(); var newTask = new Sales_WipPublic { JobID = _jobID, estRevID = 0, quoteRevID = 0, woID = 0, invoiceID = 0, Priority = 0, ContentID = 65531, Contents = "My Contents Here", Status = 0, ScheduleStartDate = DateTime.Today, ScheduleFinishDate = DateTime.Today, Responsible = _employeeID, CreatedBy = _employeeID, LastUpdatedAt = DateTime.Now, LastUpdatedBy = _employeeID }; dbml.Sales_WipPublic.Add(newTask); dbml.SaveChanges(); }
public void Create() { var specialMaterial = new Sales_SpecialMaterial { JobID = _jobID, StatusID = 0, LsmID = 0, Leadtime = 0, ItemNum = 0, HandlingProcess = "Choose" }; _db.Sales_SpecialMaterial.Add(specialMaterial); try { //Check Validation Errors IEnumerable error = _db.GetValidationErrors(); _db.SaveChanges(); ID = specialMaterial.JobSpecialMaterialID; } catch (DbEntityValidationException dbEx) { var s = dbEx.Message; } }
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 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 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 { } }
public void Create(Sales_Dispatching salesDispatching) { salesDispatching = OverrideResponsible(salesDispatching); _db.Sales_Dispatching.Add(salesDispatching); try { //Check Validation Errors var error = _db.GetValidationErrors(); _db.SaveChanges(); ID = salesDispatching.TaskID; } catch (DbEntityValidationException dbEx) { var s = dbEx.Message; } }
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(); }
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(); }
public void Create() { try { var t1 = MyCommon.MyConvert.ConvertToDate(_project.startTimeStamp); var bid = new Sales_JobMaster_BiddingJob() { //public int BiddingID { get; set; } JobID = _project.jobID, BillToID = _project.Customer, InstallToID = 0, QuoteToID = 0, SubmitID = 0, IsValid = true, TempCompanyName = "NA, Customer Has been Assigned", BiddingSourceID = 0, BiddingTypeID = 0, ProductRequired = "", CreatedBy = _project.sales, AeAssignedDate = t1, BidDeadline = t1.AddDays(14), TempProjectName = _project.jobTitle, TempTargetDate = _project.targetDate, TempAE = _project.sales, TempAmount = 0, }; _db.Sales_JobMaster_BiddingJob.Add(bid); _db.SaveChanges(); } catch (Exception e) { var s = e.Message; throw; } finally { } }
public void UpdateTaskes() { List <tblWipTask> taskes = _dbml.tblWipTasks.Where(x => x.IsPublic).ToList(); List <Sales_Wip> internalTaskes = _dbml.Sales_Wip.Where(x => x.JobID == _jobID).ToList(); foreach (tblWipTask task in taskes) { int contentID = task.ContentID; Sales_Wip internalTask = GetInternalTask(internalTaskes, contentID); Sales_WipPublic newTask; if (internalTask == null) { newTask = GetNewTask(task); } else { newTask = GetNewTask(internalTask); } _dbml.Sales_WipPublic.Add(newTask); } _dbml.SaveChanges(); }
public void Create(short statusID) { var newStatus = new Sales_JobStatusTable { jobID = _jobID, jobStatus = statusID, Performer = _eID, accomplishDate = DateTime.Now }; _db.Sales_JobStatusTable.Add(newStatus); try { //Check Validation Errors var error = _db.GetValidationErrors(); _db.SaveChanges(); } catch (DbEntityValidationException dbEx) { var s = dbEx.Message; } }
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."; } }
public void UpdateGivenBy(int givenByCompanyID) { Value.ProjectGiveBy = givenByCompanyID; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); }
//// Create and add a new Order to the Orders collection. public void AddNew() { _dbml.Sales_Wip.Add(_task); _dbml.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); } }
private void UpdateProjectID() { _biddingJob.JobID = NewJobID; _db.Entry(_biddingJob).State = EntityState.Modified; _db.SaveChanges(); }