// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { User newObj = new User(username.Text, password.Password, ((User)oldObj).Person); //editing action if (parentWindow.EditDataEntity(oldObj, newObj, 7)) { this.Close(); } } }
// perform the password change private void Button_Click(object sender, RoutedEventArgs e) { if (IsValid()) { User newUser = new User(oldUser); newUser.Password = newPass.Password; // editing action if (parentWindow.EditDataEntity(oldUser, newUser, 7)) { parentWindow.user = newUser; this.Close(); } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { Customer newObj = new Customer(int.Parse(ID.Text), firstName.Text, lastName.Text); //adding action if (isAdd) { User newUser = new User(username.Text, password.Password, newObj); if (parentWindow.AddDataEntity(newObj, newUser, 2)) { this.Close(); if (isRegister) { MessageBox.Show("Registration to E-MART done successfully!\nPlease click OK to continue"); // if this is a self registration - then send the user to the main window as a customer parentWindow.user = newUser; parentWindow.rank = (int)Rank.Customer; // display the username and permission in the main Window at the upper left square parentWindow.title_name.Text = "Hey " + newUser.UserName + "!"; parentWindow.title_rank.Text = "Logged in as " + Rank.Customer; parentWindow.Permissions(); // activate permissions control parentWindow.Show(); login.Close(); } else { MessageBox.Show("Customer was added successfully!\nPlease click OK to continue"); } } } //editing action else { newObj.CreditCard = ((Customer)oldObj).CreditCard; newObj.TranHistory = ((Customer)oldObj).TranHistory; if (parentWindow.EditDataEntity(oldObj, newObj, 2)) { this.Close(); } } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { PType myPType; var selectedItem = productType.SelectedItem as ComboBoxItem; if (selectedItem.Name.Equals("Clothes")) { myPType = PType.Clothes; } else if (selectedItem.Name.Equals("Electronics")) { myPType = PType.Electronics; } else { myPType = PType.Food; } Product newObj = new Product(productName.Text, myPType, ((Department)depID.SelectedItem).DepartmentID, int.Parse(stockcount.Text), int.Parse(price.Text)); //adding action if (isAdd) { if (parentWindow.AddDataEntity(newObj, null, 5)) { this.Close(); } } //editing action else { newObj.TopSellerStatus = ((Product)oldObj).TopSellerStatus; if (parentWindow.EditDataEntity(oldObj, newObj, 5)) { this.Close(); } } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { Is_a_return tranType; if (purchaseType.IsChecked == true) { tranType = Is_a_return.Purchase; } else { tranType = Is_a_return.Return; } PaymentMethod myPayment; var selectedItem = payment.SelectedItem as ComboBoxItem; if (selectedItem.Name.Equals("Cash")) { myPayment = PaymentMethod.Cash; } else if (selectedItem.Name.Equals("Check")) { myPayment = PaymentMethod.Check; } else { myPayment = PaymentMethod.Visa; } Transaction newObj = new Transaction(((Transaction)oldObj).TransactionID, tranType, ((Transaction)oldObj).Receipt, myPayment); //editing action if (parentWindow.EditDataEntity(oldObj, newObj, 6)) { this.Close(); } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { Gender myGender; if (male.IsChecked == true) { myGender = Gender.Male; } else { myGender = Gender.Female; } ClubMember newObj = new ClubMember(int.Parse(ID.Text), firstName.Text, lastName.Text, dateOfBirth.SelectedDate.Value, myGender); //adding action if (isAdd) { User newUser = new User(username.Text, password.Password, newObj); if (parentWindow.AddDataEntity(newObj, newUser, 1)) { this.Close(); } } //editing action else { newObj.CreditCard = ((ClubMember)oldObj).CreditCard; newObj.TranHistory = ((ClubMember)oldObj).TranHistory; if (parentWindow.EditDataEntity(oldObj, newObj, 1)) { this.Close(); } } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { Department newObj = new Department(depName.Text); //adding action if (isAdd) { if (parentWindow.AddDataEntity(newObj, null, 3)) { this.Close(); } } //editing action else { if (parentWindow.EditDataEntity(oldObj, newObj, 3)) { this.Close(); } } } }
// Add or edit private void AddOrEdit(object sender, RoutedEventArgs e) { if (IsValid()) { Gender myGender; if (male.IsChecked == true) { myGender = Gender.Male; } else { myGender = Gender.Female; } Employee newObj = new Employee(firstName.Text, lastName.Text, int.Parse(ID.Text), myGender, ((Department)depID.SelectedItem).DepartmentID, int.Parse(salary.Text), int.Parse(supID.Text)); //adding action if (isAdd) { User newUser = new User(username.Text, password.Password, newObj); if (parentWindow.AddDataEntity(newObj, newUser, 4)) { this.Close(); } } //editing action else { ///newObj.Rank = ((Employee)oldObj).Rank; if (parentWindow.EditDataEntity(oldObj, newObj, 4)) { this.Close(); } } } }