public void SaveChanges() { if (!ValidateForm()) { return; } EquipemntBindingSource.EndEdit(); PurchaseBindingSource.EndEdit(); InsuranceListBindingSource.EndEdit(); expirationBindingSource.EndEdit(); _equipment = (Equipment)EquipemntBindingSource.DataSource; _equipmentPurchase = (EquipmentPurchase)PurchaseBindingSource.DataSource; if (_equipmentPurchase.PurchaseId == 0)//if it is a new purchase. { _context.EquipmentPurchases.AddObject(_equipmentPurchase); } try { _context.SaveChanges(); } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current equipment.", ex); } BtnSave.Enabled = false; EquipemntBindingSource.DataSource = _equipment; if (ContractDetailView != null) { ContractDetailView.RefreshEquipmentList(); } }
public void SaveChanges() { if (!ValidateForm()) { return; } WorkOrderBindingSource.EndEdit(); _workOrder = (WorkOrder)WorkOrderBindingSource.DataSource; foreach (var t in _workOrder.Tasks) { foreach (var p in t.Parts) { //p.WorkOrderId = _workOrder.WorkOrderId; _workOrder.Parts.Add(p); } foreach (var l in t.Labours) { //l.WorkOrderId = _workOrder.WorkOrderId; _workOrder.LaborUnits.Add(l); } } if (_newMode) { double pt = 0; double lt = 0; foreach (var p in _workOrder.Parts) { pt += Convert.ToDouble(p.UnitCost * p.Quantity); } foreach (var l in _workOrder.LaborUnits) { lt = Convert.ToDouble(l.LabourRate * l.Hour); } double t = _workOrder.Tax == null ? 0 : Convert.ToDouble(_workOrder.Tax) / 100; double d = _workOrder.Discount == null ? 0 : Convert.ToDouble(_workOrder.Discount) / 100; var tc = (double)(pt + lt); _workOrder.TotalCost = Convert.ToDecimal(tc + (t * tc) - (d * tc)); _context.WorkOrders.AddObject(_workOrder); } try { _context.SaveChanges(); //ShowObject(_workOrder.WorkOrderId); if (_newMode) { _context.SaveChanges(); _newMode = false; } } catch (Exception) { ViewHelper.ShowSaveError(); return; } }
public void SaveChanges() { InvoiceDetailbindingSource.EndEdit(); _invoice = (Invoice)InvoiceDetailbindingSource.DataSource; try { _context.SaveChanges(); } catch (Exception) { ViewHelper.ShowSaveError(); return; } }
private void toolStripButton3_Click(object sender, EventArgs e) { DialogResult result = ViewHelper.Conformation("Are you sure you want to delete this vendor information?"); if (result == DialogResult.Yes) { if (_newMode) { return; } VendorDateBindingSource.EndEdit(); try { _context.Vendors.DeleteObject(_venldor); _context.SaveChanges(); RefreshList(); } catch (Exception ex) { ViewHelper.ShowErrorMessage(@"Error deleteing this vendor information."); ErrorLogger.LogError(this, ex); } } }
public void SaveChanges() { if (!ValidateForm()) { return; } VendorDataBindingSource.EndEdit(); var vendor = (Vendor)VendorDataBindingSource.DataSource; try { if (_newMode) { _context = new WmsEntities(); _context.Vendors.AddObject(vendor); _context.SaveChanges(); this.Close(); } } catch (Exception e) { ViewHelper.ShowErrorMessage(@"Error saving vendor information."); ErrorLogger.LogError(this, e); } }
public void SaveChanges() { if (!ValidateForm()) { return; } lookupItemBindingSource.EndEdit(); var Item = (LookupItem)lookupItemBindingSource.DataSource; if (newMode) { var lr = (from l in _context.LookupItems select l).OrderByDescending(l => l.ItemId).FirstOrDefault(); Item.ItemId = lr.ItemId + 1; _context.LookupItems.AddObject(Item); } try { _context.SaveChanges(); this.Close(); _lookupView.RefreshList(); } catch (Exception e) { ViewHelper.ShowSaveError(); return; } }
private void deleteToolStripButton_Click(object sender, EventArgs e) { DialogResult result = ViewHelper.Conformation("Are you sure you want to delete this lookup information?"); if (result == DialogResult.Yes) { if (_newMode) { return; } ItemBindingSource.EndEdit(); try { _context.LookupItems.DeleteObject(lookupItem); _context.SaveChanges(); ShowItems(); } catch (Exception ex) { ViewHelper.ShowErrorMessage(@"Error deleting lookup item information."); ErrorLogger.LogError(this, ex); } } }
public void SaveChanges() { if (!ValidateForm()) { return; } RenewalBindingSource.EndEdit(); _contractRenewal = (ContractRenewal)RenewalBindingSource.DataSource; int month = 0; month = Convert.ToInt32(CmbDuration.SelectedValue) == 1 ? (_contractRenewal.Duration ?? 0) : (_contractRenewal.Duration * 12 ?? 0); _contractRenewal.Duration = month; _contractRenewal.Status = 1; var activeContract = GetActiveContract(_contract); activeContract.Status = 0; try { _context.ContractRenewals.AddObject(_contractRenewal); _context.SaveChanges(); this.Close(); _contractDetailView.ReloadRenewals(); } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current contract renewal.", ex); } }
public void SaveChanges() { if (!ValidateForm()) { return; } CustomerDataBindingSource.EndEdit(); _customer = (Customer)CustomerDataBindingSource.DataSource; AddDefaultContract(); try { _context.Customers.AddObject(_customer); _context.SaveChanges(); } catch (Exception e) { ViewHelper.ShowSaveError(); ErrorLogger.LogError(this, e); } if (_saveAndNew) { _customer = new Customer(); CustomerDataBindingSource.DataSource = _customer; LoadLookups(); } else { var cdv = new CustomerDetailView(); cdv.ShowObject(_customer); cdv.MdiParent = this.MainForm; cdv.Show(); this.Close(); } }
public void SaveChanges() { if (!ValidateForm()) { return; } ContractBindingSource.EndEdit(); try { _context.SaveChanges(); BtnSaveContract.Enabled = false; ReloadContract(_contract.ContractId); } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current contract.", ex); } }
private void DeleteSelectedEquipment() { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _equipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); RefreshEquipmentList(); }
public void SaveChanges() { var iv = _context.Invoices.FirstOrDefault(i => i.Id == _paymentRecord.InvoiceId); if (!ValidateForm()) { return; } var rt = (Convert.ToDouble(_invoiceListInfo.RecievedTotal) + Convert.ToDouble(_paymentRecord.AmountReceived)); if (rt > Convert.ToDouble(_invoiceListInfo.InvoiceTotal)) { ViewHelper.ShowErrorMessage("the amount of recieved total has exceeded the amount of invoice total?"); Close(); return; } PaymentbindingSource.EndEdit(); _paymentRecord = (PaymentRecord)PaymentbindingSource.DataSource; if (_newMode) { _context.PaymentRecords.AddObject(_paymentRecord); } if (rt == Convert.ToDouble(_invoiceListInfo.InvoiceTotal)) { iv.Status = (int)InvoiceStatuses.PaidInFull; } try { switch (_paymentRecord.PaymentMethod) { case 5: _paymentRecord.Reference = null; break; case 6: _paymentRecord.Reference = checkNoTextBox.Text; break; case 7: _paymentRecord.Reference = bankTransferTextBox.Text; break; case 8: _paymentRecord.Reference = othersTextBox.Text; break; } _context.SaveChanges(); Close(); } catch (Exception) { ViewHelper.ShowSaveError(); return; } }
private void btnDelete_Click(object sender, EventArgs e) { var result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this PM service ?"); if (result == DialogResult.Yes) { _context.PmServices.DeleteObject(_selectService); _context.SaveChanges(); RefreshList(); } }
public void DeleteObject() { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _equipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); Close(); if (ContractDetailView != null) { ContractDetailView.RefreshEquipmentList(); } }
private void BtnDelete_Click(object sender, EventArgs ev) { DialogResult result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this equipment."); if (result == DialogResult.Yes) { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _selectEquipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); RefreshList(); } }
public void SaveChanges() { if (!ValidateForm()) { return; } CustomerDataBindingSource.EndEdit(); try { if (newMode) { _context.Customers.AddObject(_customer); } _context.SaveChanges(); btnSave.Enabled = false; } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current customer.", ex); ErrorLogger.LogError(this, ex); } }
public void SaveChanges() { if (!ValidateForm()) { return; } ContractBindingSource.EndEdit(); RenewalBindingSource.EndEdit(); _contract = (Contract)ContractBindingSource.DataSource; var renewal = (ContractRenewal)RenewalBindingSource.DataSource; int month = 0; month = Convert.ToInt32(CmboDuration.SelectedValue) == 1 ? (renewal.Duration ?? 0) : (renewal.Duration * 12 ?? 0); renewal.Duration = month; renewal.Status = 1; _contract.Status = 1; try { InsertRenewal(renewal); _context.Contracts.AddObject(_contract); _context.SaveChanges(); if (CustomerView == null) { if (_saveAndNew) { ContractBindingSource.DataSource = new Contract(); RenewalBindingSource.DataSource = new ContractRenewal(); } else { this.Close(); var ct = new ContractDetailView(); var contractDetailView = new ContractDetailView(); contractDetailView.ShowObject(_contract); contractDetailView.MdiParent = this.MainParent; contractDetailView.Show(); } } else { this.Close(); CustomerView.ReloadContracts(); } } catch (Exception e) { ViewHelper.ShowSaveError(); ErrorLogger.LogError(this, e); } }
public void SaveChanges() { if (!ValidateForm()) { return; } vendorBindingSource.EndEdit(); try { //If we are in new mode then we need to add the new object to the context if (_newMode) { _context.Vendors.AddObject(_vendor); } //Save the changes to the database through the context _context.SaveChanges(); this.Close(); } catch (Exception e) { ViewHelper.ShowErrorMessage(@"Error saving vendor information."); ErrorLogger.LogError(this, e); } }
public void SaveChanges() { if (!ValidateForm()) { return; } InvoicebindingSource.EndEdit(); _invoice = (Invoice)InvoicebindingSource.DataSource; var rt = GetPaymentTotal(); var it = GetInvoiceTotal(); if (rt == it) { _invoice.Status = (int)InvoiceStatuses.PaidInFull; } else if (rt < it) { _invoice.Status = (int)InvoiceStatuses.OutStanding; } if (_newMode) { _context.Invoices.AddObject(_invoice); } try { _context.SaveChanges(); _newMode = false; } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current invoice.", ex); return; } }
private void DeleteContract() { try { _context = new WmsEntities(); var d = _context.Contracts.First(ct => ct.ContractId == this._contract.ContractId); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception) { throw; } }
public void DeleteObject() { try { _context = new WmsEntities(); var cont = _context.Contracts.First(ct => ct.ContractId == _contract.ContractId); _context.Contracts.DeleteObject(cont); _context.SaveChanges(); this.Close(); } catch (Exception e) { ViewHelper.ShowDeleteError(); } }
public void DeleteObject() { try { _context = new WmsEntities(); var d = _context.Invoices.First(ct => ct.Id == _invoice.Id); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception) { throw; } }
private void BtnDelete_Click(object sender, EventArgs e) { var result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this work order?"); if (result == DialogResult.Yes) { try { _context.WorkOrders.DeleteObject(_selectedWorkOrder); _context.SaveChanges(); RefreshList(); } catch (Exception) { ViewHelper.ShowDeleteError(); return; } } }
public void SaveChanges() { if (!ValidateForm()) { return; } lookupItemBindingSource.EndEdit(); try { if (newMode) { _context.LookupItems.AddObject(lookupItem); } _context.SaveChanges(); this.Close(); } catch (Exception e) { ViewHelper.ShowErrorMessage(@"Error saving Lookup Item information."); ErrorLogger.LogError(this, e); } }
public void SaveChanges() { if (!ValidateForm()) { return; } equipmentBindingSource.EndEdit(); try { var equipment = (Equipment)equipmentBindingSource.DataSource; _context.Equipments.AddObject(equipment); _context.SaveChanges(); _equipment = equipment; if (_saveAndNew) { equipmentBindingSource.DataSource = new Equipment(); LoadLookUp(); if (CustomerView != null) { CustomerView.ReloadEquipments(); } if (ContractView != null) { //ContractView.ReloadEquipments(); } } else { this.Close(); // Redirect to Equipment Detail. ShowEquipmentDetail(); } } catch (Exception) { ViewHelper.ShowErrorMessage(@"Error saving new equipment."); } }
public void SaveChanges() { if (!ValidateForm()) { return; } MaintaincePartBindingSource.EndEdit(); _maintenancePart = (MaintenancePart)MaintaincePartBindingSource.DataSource; if (_newMode) { _context.MaintenanceParts.AddObject(_maintenancePart); } try { _context.SaveChanges(); if (MaintenanceTask != null) { var maintenaceTaskViewp = this.MaintenaceTaskViewp; if (maintenaceTaskViewp != null) { // maintenaceTaskViewp.AddPart(_maintenancePart); //MaintenaceTaskViewp.PartAdded(true); } var workOrderViewp = this.WorkOrderViewp; if (workOrderViewp != null) { //workOrderViewp.ReloadParts(); } Close(); } } catch (Exception) { ViewHelper.ShowSaveError(); return; } }
public void SaveChanges() { attachmentBindingSource.EndEdit(); //_equipmentAttachment = (EquipmentAttachment) attachmentBindingSource.DataSource; if (_newMode) { _context.EquipmentAttachments.AddObject(_equipmentAttachment); } try { if (!ValidateForm()) { return; } _context.SaveChanges(); EquipmentDetail.ReloadAttachments(); Close(); } catch (Exception ex) { ViewHelper.ShowErrorMessage("Error occured while saving the current attachment.", ex); return; } }
public void SaveChanges() { if (!ValidateForm()) { return; } pmserviceBindingSource.EndEdit(); pmPartsBindingSource.EndEdit(); if (Convert.ToInt32(rgTrackingMode.EditValue) == 1) { if (!RGDateTracking.EditValue.Equals(DBNull.Value)) { if (Convert.ToInt32(RGDateTracking.EditValue) == 1) { //calculate the date _pmService.RecurringDate = CalculateDate(_pmService.RecurringDate, (int)LERecurringType.SelectedValue); _pmService.FixedDate = null; } else { _pmService.RecurringDate = null; } _pmService.RecurringHour = null; _pmService.FixedHour = null; } } //if it's houre tracked. else if (Convert.ToInt32(rgTrackingMode.EditValue) == 2) { if (!RGMileageTracking.EditValue.Equals(DBNull.Value)) { if (Convert.ToInt32(RGMileageTracking.EditValue) == 1) { _pmService.FixedHour = null; } else { _pmService.RecurringHour = null; } _pmService.RecurringDate = null; _pmService.FixedDate = null; } } if (_newMode) { _context.PmServices.AddObject(_pmService); } try { _context.SaveChanges(); btnSave.Enabled = false; ShowObject(_pmService); ListView.RefreshList(); } catch (Exception) { ViewHelper.ShowSaveError(); return; } }