예제 #1
0
 private void GetEmployeeDetails()
 {
     try
     {
         using (var db = new OrexEntities())
         {
             var employee = db.Employees.Where(m => m.EmployeeID == empid).FirstOrDefault();
             tbCity.Text      = employee.City;
             tbCountry.Text   = employee.Country;
             tbEmail.Text     = employee.Email;
             tbFirstName.Text = employee.FirstName;
             tbJobTitle.Text  = employee.JobTitle;
             tbLastName.Text  = employee.LastName;
             tbNotes.Text     = employee.Notes;
             tbPCode.Text     = employee.PostalCode;
             tbPhone1.Text    = employee.Phone1;
             tbPhone2.Text    = employee.Phone2;
             tbPhone3.Text    = employee.Phone3;
             tbPhone4.Text    = employee.Phone4;
             tbProvince.Text  = employee.Province;
             tbStreet.Text    = employee.Street;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        private void GetEmployees()
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    lEmployee = new List <OrexClass.EmployeeList>();
                    var employees = db.Employees.ToList();

                    foreach (var x in employees)
                    {
                        OrexClass.EmployeeList employee = new OrexClass.EmployeeList();
                        employee.ContactNo    = x.Phone1 + x.Phone2 + x.Phone3 + x.Phone4;
                        employee.EmployeeName = (x.LastName + ", " + x.FirstName).ToUpper();
                        employee.Email        = x.Email;
                        lEmployee.Add(employee);
                    }

                    datagridview.ItemsSource = lEmployee.OrderBy(m => m.EmployeeName).ToList();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #3
0
        private void GetWarehouses()
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    var warehouses = db.Warehouses.ToList();

                    lWarehouse = new List <OrexClass.WarehouseList>();

                    foreach (var x in warehouses)
                    {
                        Model.OrexClass.WarehouseList warehouse = new Model.OrexClass.WarehouseList();
                        warehouse.WarehouseID   = x.WarehouseID;
                        warehouse.WarehouseCode = x.WarehouseCode.ToUpper();
                        warehouse.ContactNo     = x.Phone1 + x.Phone2 + x.Phone3 + x.Phone4;
                        warehouse.ContactPerson = x.LastName.ToUpper() + ", " + x.FirstName.ToUpper();
                        warehouse.Email         = x.Email;
                        lWarehouse.Add(warehouse);
                    }

                    datagridview.ItemsSource = lWarehouse.OrderBy(m => m.ContactPerson).ToList();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #4
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    if (mode == 1)
                    {
                        Warehouse warehouse = new Warehouse();

                        warehouse.City          = tbCity.Text;
                        warehouse.Country       = tbCountry.Text;
                        warehouse.Email         = tbEmail.Text;
                        warehouse.FirstName     = tbFirstName.Text;
                        warehouse.JobTitle      = tbJobTitle.Text;
                        warehouse.LastName      = tbLastName.Text;
                        warehouse.Notes         = tbNotes.Text;
                        warehouse.Phone1        = tbPhone1.Text;
                        warehouse.Phone2        = tbPhone2.Text;
                        warehouse.Phone3        = tbPhone3.Text;
                        warehouse.Phone4        = tbPhone4.Text;
                        warehouse.PostalCode    = tbPCode.Text;
                        warehouse.Province      = tbProvince.Text;
                        warehouse.Street        = tbStreet.Text;
                        warehouse.WarehouseCode = tbCode.Text;

                        db.Warehouses.Add(warehouse);
                        db.SaveChanges();
                        MessageBox.Show("Add Success", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (mode == 2)
                    {
                        var warehouse = db.Warehouses.Where(m => m.WarehouseID == warehouseid).FirstOrDefault();

                        warehouse.City          = tbCity.Text;
                        warehouse.Country       = tbCountry.Text;
                        warehouse.Email         = tbEmail.Text;
                        warehouse.FirstName     = tbFirstName.Text;
                        warehouse.JobTitle      = tbJobTitle.Text;
                        warehouse.LastName      = tbLastName.Text;
                        warehouse.Notes         = tbNotes.Text;
                        warehouse.Phone1        = tbPhone1.Text;
                        warehouse.Phone2        = tbPhone2.Text;
                        warehouse.Phone3        = tbPhone3.Text;
                        warehouse.Phone4        = tbPhone4.Text;
                        warehouse.PostalCode    = tbPCode.Text;
                        warehouse.Province      = tbProvince.Text;
                        warehouse.Street        = tbStreet.Text;
                        warehouse.WarehouseCode = tbCode.Text;

                        db.SaveChanges();
                        MessageBox.Show("Update Success", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #5
0
        private void GetContactDetails()
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    var contact = db.Contacts.Where(m => m.ContactID == contactid).FirstOrDefault();
                    tbCity.Text                 = contact.City;
                    tbCompany.Text              = contact.Company;
                    tbCountry.Text              = contact.Country;
                    tbCredit.Text               = contact.CreditLimit.ToString();
                    tbEmail.Text                = contact.Email;
                    tbFirstName.Text            = contact.FirstName;
                    tbJobTitle.Text             = contact.JobTitle;
                    tbLastName.Text             = contact.LastName;
                    tbNotes.Text                = contact.Notes;
                    tbPCode.Text                = contact.PostalCode;
                    tbPhone1.Text               = contact.Phone1;
                    tbPhone2.Text               = contact.Phone2;
                    tbPhone3.Text               = contact.Phone3;
                    tbPhone4.Text               = contact.Phone4;
                    tbProvince.Text             = contact.Province;
                    tbStreet.Text               = contact.Street;
                    tbTerms.Text                = contact.PaymentTermDays.ToString();
                    tbTIN.Text                  = contact.TIN;
                    tbWebPage.Text              = contact.WebPage;
                    cbSalesPerson.SelectedValue = contact.SalesPerson;

                    if (contact.Category == 1)
                    {
                        rbCustomer.IsChecked = true;
                    }
                    else if (contact.Category == 2)
                    {
                        rbSupplier.IsChecked = true;
                    }
                    else if (contact.Category == 3)
                    {
                        rbMisc.IsChecked = true;
                    }

                    if (contact.SalesInvoice == true)
                    {
                        chckboxSalesInvoice.IsChecked = true;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #6
0
        private void GetContacts()
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    var contacts = db.Contacts.ToList();

                    lContact = new List <OrexClass.ContactList>();

                    foreach (var x in contacts)
                    {
                        Model.OrexClass.ContactList contact = new Model.OrexClass.ContactList();
                        contact.ContactID     = x.ContactID;
                        contact.Company       = x.Company;
                        contact.ContactNo     = x.Phone1 + x.Phone2 + x.Phone3 + x.Phone4;
                        contact.ContactPerson = x.LastName.ToUpper() + ", " + x.FirstName.ToUpper();
                        contact.Email         = x.Email;

                        if (x.Category == 1)
                        {
                            contact.Category = "Customer";
                        }
                        else if (x.Category == 2)
                        {
                            contact.Category = "Supplier";
                        }
                        else if (x.Category == 3)
                        {
                            contact.Category = "Misc";
                        }

                        lContact.Add(contact);
                    }

                    datagridview.ItemsSource = lContact.OrderBy(m => m.ContactPerson).ToList();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #7
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new OrexEntities())
                {
                    if (mode == 1)
                    {
                        Contact contact = new Contact();
                        if (rbCustomer.IsChecked == true)
                        {
                            contact.Category = 1;
                        }
                        else if (rbSupplier.IsChecked == true)
                        {
                            contact.Category = 2;
                        }
                        else if (rbMisc.IsChecked == true)
                        {
                            contact.Category = 3;
                        }

                        if (chckboxSalesInvoice.IsChecked == true)
                        {
                            contact.SalesInvoice = true;
                        }
                        else
                        {
                            contact.SalesInvoice = false;
                        }

                        contact.City            = tbCity.Text;
                        contact.Company         = tbCompany.Text;
                        contact.Country         = tbCountry.Text;
                        contact.CreditLimit     = Convert.ToInt32(tbCredit.Text);
                        contact.Email           = tbEmail.Text;
                        contact.FirstName       = tbFirstName.Text;
                        contact.JobTitle        = tbJobTitle.Text;
                        contact.LastName        = tbLastName.Text;
                        contact.Notes           = tbNotes.Text;
                        contact.PaymentTermDays = Convert.ToInt32(tbTerms.Text);
                        contact.Phone1          = tbPhone1.Text;
                        contact.Phone2          = tbPhone2.Text;
                        contact.Phone3          = tbPhone3.Text;
                        contact.Phone4          = tbPhone4.Text;
                        contact.PostalCode      = tbPCode.Text;
                        contact.Province        = tbProvince.Text;
                        contact.SalesPerson     = Convert.ToInt32(cbSalesPerson.SelectedValue);
                        contact.Street          = tbStreet.Text;
                        contact.TIN             = tbTIN.Text;
                        contact.WebPage         = tbWebPage.Text;
                        contact.Street          = tbStreet.Text;

                        db.Contacts.Add(contact);
                        db.SaveChanges();
                        MessageBox.Show("Add Success", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }

                    else if (mode == 2)
                    {
                        var contact = db.Contacts.Where(m => m.ContactID == contactid).FirstOrDefault();
                        if (rbCustomer.IsChecked == true)
                        {
                            contact.Category = 1;
                        }
                        else if (rbSupplier.IsChecked == true)
                        {
                            contact.Category = 2;
                        }
                        else if (rbMisc.IsChecked == true)
                        {
                            contact.Category = 3;
                        }

                        if (chckboxSalesInvoice.IsChecked == true)
                        {
                            contact.SalesInvoice = true;
                        }
                        else
                        {
                            contact.SalesInvoice = false;
                        }

                        contact.City            = tbCity.Text;
                        contact.Company         = tbCompany.Text;
                        contact.Country         = tbCountry.Text;
                        contact.CreditLimit     = Convert.ToInt32(tbCredit.Text);
                        contact.Email           = tbEmail.Text;
                        contact.FirstName       = tbFirstName.Text;
                        contact.JobTitle        = tbJobTitle.Text;
                        contact.LastName        = tbLastName.Text;
                        contact.Notes           = tbNotes.Text;
                        contact.PaymentTermDays = Convert.ToInt32(tbTerms.Text);
                        contact.Phone1          = tbPhone1.Text;
                        contact.Phone2          = tbPhone2.Text;
                        contact.Phone3          = tbPhone3.Text;
                        contact.Phone4          = tbPhone4.Text;
                        contact.PostalCode      = tbPCode.Text;
                        contact.Province        = tbProvince.Text;
                        contact.SalesPerson     = Convert.ToInt32(cbSalesPerson.SelectedValue);
                        contact.Street          = tbStreet.Text;
                        contact.TIN             = tbTIN.Text;
                        contact.WebPage         = tbWebPage.Text;

                        db.SaveChanges();
                        MessageBox.Show("Update Success", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }