private void btnAddInvLineItemSave_Click(object sender, EventArgs e) { InvoiceLineItem newItem = new InvoiceLineItem(); newItem.ServiceID = Convert.ToInt32(serviceIDComboBox.Text); newItem.EmployeeID = Convert.ToInt32(employeeIDComboBox.Text); newItem.ServiceNumOfHours = Convert.ToInt32(serviceNumOfHoursNumericUpDown.Value); newItem.InvoiceID = Convert.ToInt32(invoiceIDTextBox1.Text); invoicesDb.InvoiceLineItems.Add(newItem); invoicesDb.SaveChanges(); EnableAddInvLineItems(); //Reload database to show new info invoicesDb = new LawnServiceEntities(); invoicesDb.Customers.Load(); invoicesDb.Employees.Load(); invoicesDb.Invoices.Load(); invoicesDb.InvoiceLineItems.Load(); invoicesDb.Services.Load(); this.invoiceBindingSource.DataSource = invoicesDb.Invoices.Local.ToBindingList(); this.customerBindingSource.DataSource = invoicesDb.Customers.Local.ToList(); this.employeeBindingSource.DataSource = invoicesDb.Employees.Local.ToList(); this.serviceBindingSource.DataSource = invoicesDb.Services.Local.ToList(); PopulateCustomInvoiceDataGridViewColumns(); FilterInvoiceLineItemDataGridView(); }
public InvoiceListForm() { InitializeComponent(); invoicesDb = new LawnServiceEntities(); invoicesDb.Customers.Load(); invoicesDb.Employees.Load(); invoicesDb.Invoices.Load(); invoicesDb.InvoiceLineItems.Load(); this.invoiceBindingSource.DataSource = invoicesDb.Invoices.Local.ToBindingList(); this.customerBindingSource.DataSource = invoicesDb.Customers.Local.ToList(); this.employeeBindingSource.DataSource = invoicesDb.Employees.Local.ToList(); //add items to service id combobox var serviceIds = (from service in invoicesDb.Services select service.ServiceID); //Generate list from service ids to make it into string List <string> serviceIdList = new List <string>(); foreach (int id in serviceIds) { serviceIdList.Add(id.ToString()); } serviceIDComboBox.Items.AddRange(serviceIdList.ToArray()); }
private void btnInvLineItemSave_Click(object sender, EventArgs e) { int currentInvLineItemDetailId = currentSelectedInvLineItemDetailId; var editedInvLineItem = (from invLineItem in invoicesDb.InvoiceLineItems where invLineItem.InvLineItemDetailID == currentInvLineItemDetailId select invLineItem).Single(); editedInvLineItem.ServiceID = Convert.ToInt32(invoiceLineItemDataGridView.CurrentRow.Cells[2].Value); editedInvLineItem.InvoiceID = currentSelectedInvoiceId; editedInvLineItem.EmployeeID = Convert.ToInt32(employeeIDComboBox.Text); invoicesDb.SaveChanges(); DisableEditInvLineItems(); //Reload database to show new info invoicesDb = new LawnServiceEntities(); invoicesDb.Customers.Load(); invoicesDb.Employees.Load(); invoicesDb.Invoices.Load(); invoicesDb.InvoiceLineItems.Load(); invoicesDb.Services.Load(); this.invoiceBindingSource.DataSource = invoicesDb.Invoices.Local.ToBindingList(); this.customerBindingSource.DataSource = invoicesDb.Customers.Local.ToList(); this.employeeBindingSource.DataSource = invoicesDb.Employees.Local.ToList(); this.serviceBindingSource.DataSource = invoicesDb.Services.Local.ToList(); PopulateCustomInvoiceDataGridViewColumns(); FilterInvoiceLineItemDataGridView(); }
public ServicesListForm() { InitializeComponent(); ServiceDb = new LawnServiceEntities(); ServiceDb.Services.Load(); this.serviceBindingSource.DataSource = ServiceDb.Services.Local.ToBindingList(); btnServicesFormSaveChanges.Visible = false; //Populate list for service name combobox search item var names = (from service in ServiceDb.Services select service.ServiceName).Distinct(); searchByServiceNameCbo.Items.AddRange(names.ToArray()); //Populate list for service cost combobox search item var costs = (from service in ServiceDb.Services select service.ServiceCostPerHour).Distinct(); //Generate list from costs var and make it into a string to be used for the combobox List <string> serviceCosts = new List <string>(); foreach (Decimal cost in costs) { serviceCosts.Add(cost.ToString("N")); } filterByCostCbo.Items.AddRange(serviceCosts.ToArray()); }
public AddServiceForm() { InitializeComponent(); addServiceDb = new LawnServiceEntities(); service = new Service(); EnableSaveBtn(); }
public CustomersListForm() { InitializeComponent(); //Initialize LawnServiceEntities and load. Must utilize "this" (this form) and specify what the customerBindingSource DataSource is //Follow that by putting it to local and use ToBindingList() to make it so that any changes made are reflected in database //Combobox for states utilizes the list to show them CustDb = new LawnServiceEntities(); CustDb.Customers.Load(); CustDb.States.Load(); this.customerBindingSource.DataSource = CustDb.Customers.Local.ToBindingList(); this.stateBindingSource.DataSource = CustDb.States.Local.ToList(); btnCustomerFormSaveChanges.Visible = false; //Populate last names for combobox to search by last name var lastNames = (from customer in CustDb.Customers select customer.CustomerLName).Distinct(); searchByLastNameCbo.Items.AddRange(lastNames.ToArray()); //Populate states for toolbar combobox to filter by state var states = (from state in CustDb.States select state.StateCode); filterByStateCbo.Items.AddRange(states.ToArray()); }
public AddInvoiceForm() { InitializeComponent(); addInvDb = new LawnServiceEntities(); addInvDb.Customers.Load(); this.customerBindingSource.DataSource = addInvDb.Customers.Local.ToList(); invoice = new Invoice(); }
public AddCustomerForm() { InitializeComponent(); Db = new LawnServiceEntities(); Db.States.Load(); this.stateBindingSource.DataSource = Db.States.Local.ToList(); customer = new Customer(); EnableSaveBtn(); }
public AddEmployeeForm() { InitializeComponent(); AddEmpDb = new LawnServiceEntities(); AddEmpDb.States.Load(); this.stateBindingSource.DataSource = AddEmpDb.States.Local.ToList(); employee = new Employee(); EnableSaveBtn(); }
public AddVendorForm() { InitializeComponent(); AddVendorDb = new LawnServiceEntities(); AddVendorDb.States.Load(); this.stateBindingSource.DataSource = AddVendorDb.States.Local.ToList(); vendor = new Vendor(); EnableSaveBtn(); }
public VendorsListForm() { InitializeComponent(); VendorDb = new LawnServiceEntities(); VendorDb.Vendors.Load(); VendorDb.States.Load(); this.vendorBindingSource.DataSource = VendorDb.Vendors.Local.ToBindingList(); this.stateBindingSource.DataSource = VendorDb.States.Local.ToList(); btnVendorFormSaveChanges.Visible = false; //Populate names for combobox to search by vendor name var names = (from vendor in VendorDb.Vendors select vendor.VendorName).Distinct(); searchByNameCbo.Items.AddRange(names.ToArray()); //Populate states for toolbar combobox to filter by state var states = (from state in VendorDb.States select state.StateCode); filterByStateCbo.Items.AddRange(states.ToArray()); }
public EmployeesListForm() { InitializeComponent(); //Initialize Database on form EmpDb = new LawnServiceEntities(); EmpDb.Employees.Load(); EmpDb.States.Load(); this.employeeBindingSource.DataSource = EmpDb.Employees.Local.ToBindingList(); this.stateBindingSource.DataSource = EmpDb.States.Local.ToList(); btnEmployeeFormSaveChanges.Visible = false; //Populate last names for combobox var lastNames = (from employee in EmpDb.Employees select employee.EmployeeLName).Distinct(); searchByLastNameCbo.Items.AddRange(lastNames.ToArray()); //Populate states for toolbar combobox var states = (from state in EmpDb.States select state.StateCode); filterByStateCbo.Items.AddRange(states.ToArray()); }