예제 #1
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(mobileContact.ToString()) || val.isEmpty(homeContact.ToString()))
            {
                await this.ShowMessageAsync("Error", "Data Cannot be Empty", MessageDialogStyle.Affirmative);
            }
            else
            {
                int affectedLines = 0;
                supplier.Suppliername  = SupplierName.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.executeSupplierEntry(supplier);

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

                        SupplierName.Text  = "";
                        Address1.Text      = "";
                        Address2.Text      = "";
                        Address3.Text      = "";
                        MobileContact.Text = "";
                        HomeContact.Text   = "";
                        CompanyName.Text   = "";
                    }
                    else
                    {
                        await this.ShowMessageAsync("Error", "Sorry Can not add, Please Try again", MessageDialogStyle.Affirmative);
                    }
                }
                catch (SqlException sqlException)
                {
                    Console.WriteLine(sqlException);
                }
            }
        }