示例#1
0
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            val = new Validation();
            if (val.isEmpty(capacity.ToString()) || val.isEmpty(date.ToString()) || val.isEmpty(type) || val.isEmpty(vehicleNo) || val.isEmpty(salesCenter))
            {
                await this.ShowMessageAsync("Error", "Data Cannot be Empty", MessageDialogStyle.Affirmative);
            }
            else if (val.isNumeric(capacity.ToString()))
            {
                await this.ShowMessageAsync("Error", "Capacity shoul be numeric", MessageDialogStyle.Affirmative);
            }
            else
            {
                int affectedLines = 0;
                vehicle.VehicleNo   = VehicleNo.Text;
                vehicle.Type        = Type.Text;
                vehicle.Capacity    = Convert.ToInt32(Capacity.Text);
                vehicle.Date        = Convert.ToDateTime(RegisterDate.Text);
                vehicle.SalesCenter = SellingCenter.SelectedValue.ToString();
                try
                {
                    handleDatabase = new HandleDatabase();
                    affectedLines  = handleDatabase.executeVehicleDataEntry(vehicle);

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

                        clearFields();
                    }
                    else
                    {
                        await this.ShowMessageAsync("Error", "Sorry Can not Proceed, Please Try again", MessageDialogStyle.Affirmative);
                    }
                    clearFields();
                }
                catch (SqlException sqlException)
                {
                    Console.WriteLine(sqlException);
                }
                clearFields();
            }
        }