示例#1
0
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            val = new Validation();
            if (val.isEmpty(location) || val.isEmpty(addressLine1) || val.isEmpty(addressLine2) || val.isEmpty(mobileNumber.ToString()) || val.isEmpty(fixedNumber.ToString()))
            {
                await this.ShowMessageAsync("Error", "Data Cannot be Empty", MessageDialogStyle.Affirmative);
            }
            else if (val.isNumeric(mobileNumber.ToString()) || val.isNumeric(fixedNumber.ToString()))
            {
                await this.ShowMessageAsync("Error", "Contact Numbers Should be Numeric", MessageDialogStyle.Affirmative);
            }
            else
            {
                int affectedLines = 0;
                salesCenter.Location    = Location.Text;
                salesCenter.FixedNumber = Convert.ToInt32(FixedLine.Text);
                salesCenter.Mobile      = Convert.ToInt32(Mobile.Text);
                salesCenter.Address     = Address1.Text + ' ' + Address2.Text + ' ' + Address3.Text;
                try
                {
                    handleDatabase = new HandleDatabase();
                    affectedLines  = handleDatabase.executeSalesCenetrEntry(salesCenter);

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

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