//private void ForceValidation() //{ // this.NameTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); // this.PasswordBox.GetBindingExpression(TextBlock.TextProperty).UpdateSource(); //} private void LoginButton_Click(object sender, RoutedEventArgs e) { #region validation if ((String.IsNullOrEmpty(NameTextBox.Text)) || (String.IsNullOrEmpty(PasswordBox.Password))) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion using (var db = new AlphaElectricEntitiesDB()) { var obj = db.Logins.Where(m => m.Username == NameTextBox.Text).FirstOrDefault(); if (obj == null) { var sMessageDialog = new MessageDialog { Message = { Text = "Incorrect Username!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); Clear(); NameTextBox.Focus(); return; } else if (!Hashing.ValidatePassword(PasswordBox.Password, obj.Password)) { var sMessageDialog = new MessageDialog { Message = { Text = "Incorrect Password!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); Clear(); NameTextBox.Focus(); return; } this.Hide(); LoggedInUser.Instance.Info = db.Logins.Where(u => u.ID == obj.ID).FirstOrDefault(); MainwWindow x = new MainwWindow(); x.Show(); this.Close(); } }
void UpdateFields() { if (SelectProjectComboBox.SelectedValue != null) { var id = int.Parse(SelectProjectComboBox.SelectedValue.ToString()); var proj = new AlphaElectricEntitiesDB().Projects.Where(x => x.ID == id).FirstOrDefault(); if (proj != null) { NameTextBox.Text = proj.Name; this.DeliveryDateDatePicker.SelectedDate = proj.DeliveyDate; OrderStatusComboBox.SelectedValue = proj.CustomerOrder.OrderStatusID; } } }
void UpdateFields() { if (SelectCompanyComboBox.SelectedValue != null) { var db = new AlphaElectricEntitiesDB(); var id = int.Parse(SelectCompanyComboBox.SelectedValue.ToString()); var cust = db.Contacts.Where(x => x.ID == id).FirstOrDefault(); if (cust != null) { NameTextBox.Text = cust.CompanyName; EmailTextBox.Text = cust.Email; PhoneTextBox.Text = cust.Phone; AddressTextBox.Text = cust.Address; } } }
void UpdateFields() { if (SelectEmployeeComboBox.SelectedValue != null) { var db = new AlphaElectricEntitiesDB(); var id = int.Parse(SelectEmployeeComboBox.SelectedValue.ToString()); var emp = db.Employees.Where(x => x.ID == id).FirstOrDefault(); if (emp != null) { FirstNameTextBox.Text = emp.FirstName; LastNameTextBox.Text = emp.LastName; PhoneTextBox.Text = emp.Phone; PassportTextBox.Text = emp.Passport; JoinDateDatePicker.SelectedDate = emp.JoinDate; AddressTextBox.Text = emp.Address; DesignationComboBox.SelectedValue = emp.DesignationID; EmployeeStatusComboBox.SelectedValue = emp.EmployeeStatusID; } } }
public CustomerOrderDA() { db = new AlphaElectricEntitiesDB(); }
public LocationDA() { db = new AlphaElectricEntitiesDB(); }
public SizeTypeDA() { db = new AlphaElectricEntitiesDB(); }
public PurchaseOrderDA() { db = new AlphaElectricEntitiesDB(); }
public Product_CustomerOrderBTDA() { db = new AlphaElectricEntitiesDB(); }
public Panel_ProjectBTDA() { db = new AlphaElectricEntitiesDB(); }
public CertificationDA() { db = new AlphaElectricEntitiesDB(); }
public ContactDA() { db = new AlphaElectricEntitiesDB(); }
public PanelShellGradeProtectionDA() { db = new AlphaElectricEntitiesDB(); }
public InventoryDA() { db = new AlphaElectricEntitiesDB(); }
public OrderStatusDA() { db = new AlphaElectricEntitiesDB(); }
private void CreateButton_Click(object sender, RoutedEventArgs e) { #region validation ForceValidation(); if (Validation.GetHasError(PODateDatePicker)) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } if (SupplierComboBox.SelectedValue == null) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Select all fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } if (productItemsList.Count() == 0) { var sMessageDialog = new MessageDialog { Message = { Text = "There are no items in the purchase order,\nadd items!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion // Creating PO po.PODate = PODateDatePicker.SelectedDate.Value; po.ContactID = int.Parse(SupplierComboBox.SelectedValue.ToString()); PurchaseOrderFactory fac = new PurchaseOrderFactory(); fac.InsertPurchaseOrder(po); // Adding Products to PO using (var db = new AlphaElectricEntitiesDB()) { bool flag = false; // Multiple Products foreach (var item in productItemsList) { Product_PurchaseOrderBT po_prod = new Product_PurchaseOrderBT() { ProductID = item.ProductID, PurchaseOrderID = po.ID }; // LINQ query var query = from prod in db.Product_PurchaseOrderBT where prod.PurchaseOrderID == po.ID && prod.ProductID == po_prod.ProductID select prod; if (query.ToList().Count == 0) { po_prod.Quantity = item.Quantity; db.Product_PurchaseOrderBT.Add(po_prod); db.SaveChanges(); flag = true; } // Checks if existing ProductID and PurchaseOrderID exists // Used if item is added again else if (query.ToList().Count == 1) { foreach (var xx in query) { xx.Quantity += item.Quantity; } db.SaveChanges(); flag = true; } } productItemsList.Clear(); ClearItems(); Clear(); if (flag) { var sMessageDialog = new MessageDialog { Message = { Text = "Purchase Order added!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } } }
public MakeDA() { db = new AlphaElectricEntitiesDB(); }
public ProjectDA() { db = new AlphaElectricEntitiesDB(); }
public DesignationDA() { db = new AlphaElectricEntitiesDB(); }
public Product_PurchaseOrderBTDA() { db = new AlphaElectricEntitiesDB(); }
public EmployeeStatusDA() { db = new AlphaElectricEntitiesDB(); }
private void InsertButton_Click(object sender, RoutedEventArgs e) { #region validation ForceValidation(); if (Validation.GetHasError(NameTextBox) || Validation.GetHasError(DeliveryDateDatePicker) || Validation.GetHasError(OrderDateDatePicker)) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } if (CustomerComboBox.SelectedValue == null || AssignedEmployeeComboBox.SelectedValue == null || OrderStatusComboBox.SelectedValue == null) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Select all fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion // Adding a new Proj Project proj = new Project() { Name = NameTextBox.Text, DeliveyDate = DeliveryDateDatePicker.SelectedDate.Value }; // Adding a new Order CustomerOrder co = new CustomerOrder() { OrderDate = OrderDateDatePicker.SelectedDate.Value, DeliveryDate = proj.DeliveyDate, ContactID = int.Parse(CustomerComboBox.SelectedValue.ToString()), OrderStatusID = int.Parse(OrderStatusComboBox.SelectedValue.ToString()), EmployeeID = int.Parse(AssignedEmployeeComboBox.SelectedValue.ToString()) }; //CustomerOrderFactory fac = new CustomerOrderFactory(); //fac.InsertCustomerOrder(co); new CustomerOrderFactory().InsertCustomerOrder(co); //setting Proj CustID. proj.CustomerOrderID = co.ID; new ProjectFactory().InsertProject(proj); // Adding Panels to Project using (var db = new AlphaElectricEntitiesDB()) { // Multiple Panels foreach (var item in productItemsList) { Panel_ProjectBT proj_panel = new Panel_ProjectBT() { PanelID = item.ProductID, ProjectID = proj.ID }; // LINQ query var query = from row in db.Panel_ProjectBT where row.ProjectID == proj.ID && row.PanelID == proj_panel.PanelID select row; if (query.ToList().Count == 0) { proj_panel.Quantity = item.Quantity; db.Panel_ProjectBT.Add(proj_panel); db.SaveChanges(); //flag = true; } // Checks if existing PanelID and ProjectOrderID exists // Used if item is added again else if (query.ToList().Count == 1) { foreach (var xx in query) { xx.Quantity += item.Quantity; } db.SaveChanges(); //flag = true; } } productItemsList.Clear(); ClearItems(); Clear(); if (true) { var sMessageDialog = new MessageDialog { Message = { Text = "Project Inserted! " } }; DialogHost.Show(sMessageDialog, "RootDialog"); ClearButton_Click(null, null); return; } } }
private void CreateButton_Click(object sender, RoutedEventArgs e) { #region validation ForceValidation(); if (Validation.GetHasError(OrderDateDatePicker) || Validation.GetHasError(DeliveryDateDatePicker)) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } if (CustomerComboBox.SelectedValue == null || AssignedEmployeeComboBox.SelectedValue == null || OrderStatusComboBox.SelectedValue == null) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Select all fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } if (productItemsList.Count() == 0) { var sMessageDialog = new MessageDialog { Message = { Text = "There are no items in the customer order,\nadd items!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion bool flag = false; // Creating PO CustomerOrder co = new CustomerOrder() { OrderDate = OrderDateDatePicker.SelectedDate.Value, DeliveryDate = DeliveryDateDatePicker.SelectedDate.Value, ContactID = int.Parse(CustomerComboBox.SelectedValue.ToString()), OrderStatusID = int.Parse(OrderStatusComboBox.SelectedValue.ToString()), EmployeeID = int.Parse(AssignedEmployeeComboBox.SelectedValue.ToString()) }; //CustomerOrderFactory fac = new CustomerOrderFactory(); //fac.InsertCustomerOrder(co); new CustomerOrderFactory().InsertCustomerOrder(co); // Adding Products to PO using (var db = new AlphaElectricEntitiesDB()) { // Multiple Products foreach (var item in productItemsList) { Product_CustomerOrderBT co_prod = new Product_CustomerOrderBT() { ProductID = item.ProductID, CustomerOrderID = co.ID }; // LINQ query var query = from row in db.Product_CustomerOrderBT where row.CustomerOrderID == co.ID && row.ProductID == co_prod.ProductID select row; if (query.ToList().Count == 0) { co_prod.Quantity = item.Quantity; db.Product_CustomerOrderBT.Add(co_prod); db.SaveChanges(); flag = true; } // Checks if existing ProductID and PurchaseOrderID exists // Used if item is added again else if (query.ToList().Count == 1) { foreach (var xx in query) { xx.Quantity += item.Quantity; } db.SaveChanges(); flag = true; } } productItemsList.Clear(); ClearItems(); Clear(); if (flag) { var sMessageDialog = new MessageDialog { Message = { Text = "Customer Order added!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } } }