Example #1
0
        private void back_Click(object sender, RoutedEventArgs e)
        {
            ViewSuppliers viewSuppliers = new ViewSuppliers();

            viewSuppliers.Show();
            this.Close();
        }
Example #2
0
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            val = new Validation();
            if (val.isEmpty(supplierName) || val.isEmpty(companyName) || val.isEmpty(addressLine1) || val.isEmpty(addressLine2) ||
                val.isEmpty(mobile.ToString()) || val.isEmpty(homeContact.ToString()))
            {
                await this.ShowMessageAsync("Error", "Data Cannot be Empty", MessageDialogStyle.Affirmative);
            }
            else
            {
                int affectedLines = 0;
                supplier = new SupplierData();

                supplier.Suppliername  = SupplierName.Text;
                supplier.CompanyName   = CompanyName.Text;
                supplier.Address       = Address1.Text + ' ' + Address2.Text + ' ' + Address3.Text;
                supplier.MobileContact = Convert.ToInt32(MobileContact.Text);
                supplier.HomeContact   = Convert.ToInt32(HomeContact.Text);
                supplier.CompanyName   = CompanyName.Text;

                try
                {
                    handleDatabase = new HandleDatabase();
                    affectedLines  = handleDatabase.executeSupplierUpdate(supplier, supplierID);

                    if (affectedLines > 0)
                    {
                        await this.ShowMessageAsync("Successfull", "Supplier details have been Successfully Updates", MessageDialogStyle.Affirmative);

                        ViewSuppliers view = new ViewSuppliers();
                        view.Show();
                        this.Close();
                    }
                    else
                    {
                        await this.ShowMessageAsync("Error", "Sorry Can not Update, Please Try again", MessageDialogStyle.Affirmative);
                    }
                }
                catch (SqlException sqlException)
                {
                    Console.WriteLine(sqlException);
                }
            }
        }