예제 #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (ValidateController.validateItem(labelIDCity.Text))
            {
                sqlConnection = new SqlConnection(con);
                commandString = $@"DELETE FROM [dbo].[City]
									WHERE IdCity = '{labelIDCity.Text}'"                                    ;
                try
                {
                    sqlConnection.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("Не удалось подключиться");
                }
                command = new SqlCommand(commandString, sqlConnection);
                command.ExecuteNonQuery();
                this.cityTableAdapter.Fill(this.phoneCallDataSet19.City);


                labelIDCity.Text = "";
                ValidateController.CleanerTextBox(textBoxCity);
                ValidateController.CleanerNumeric(numericDiscount, numericRateDay, numericRateNight);
            }
            else
            {
                MessageBox.Show("Выберите строку для удаления");
            }
        }
예제 #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (ValidateController.validateItem(idSubscriber.Text))
            {
                sqlConnection = new SqlConnection(con);
                commandString = $@"DELETE FROM [dbo].[Subscribers]
									WHERE IdSubscriber = '{idSubscriber.Text}'"                                    ;
                try
                {
                    sqlConnection.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("Не удалось подключиться");
                }
                command = new SqlCommand(commandString, sqlConnection);
                command.ExecuteNonQuery();
                this.subscribersTableAdapter2.Fill(this.phoneCallDataSet15.Subscribers);

                idSubscriber.Text = "";
                ValidateController.CleanerTextBox(textBoxAddress, textBoxInn, textBoxNumber);
                Cursor.Current = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Выберите строку для удаления");
            }
        }
예제 #3
0
        public bool validate(Label city, Label subscriber, Label minutes)
        {
            bool result = ValidateController.validateItem(IDCity.ToString(), city) &&
                          ValidateController.validateItem(IDSubscriber.ToString(), subscriber) &&
                          ValidateController.validateItem(CountMinutes.ToString(), minutes) &&
                          ValidateController.validateItem(PriceConverstation.ToString());

            return(result);
        }
예제 #4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            subscribeModel = new SubscribeModel(textBoxNumber.Text, textBoxInn.Text, textBoxAddress.Text);
            if (subscribeModel.validate(errorNumber, errorINN, errorAddress))
            {
                Cursor.Current = Cursors.WaitCursor;
                sqlConnection  = new SqlConnection(con);
                if (ValidateController.validateItem(idSubscriber.Text))
                {
                    commandString = $@"UPDATE [dbo].[Subscribers]
								   SET [NumberPhone] = '{subscribeModel.MobilePhone}'
									  ,[INN] = '{subscribeModel.INN}'
									  ,[Address] = '{subscribeModel.Address}'
								 WHERE IdSubscriber = '{idSubscriber.Text}'"                                ;
                }
                else
                {
                    commandString = $@"INSERT INTO [dbo].[Subscribers]
						   ([NumberPhone]
						   ,[INN]
						   ,[Address])
					 VALUES(
						    '{subscribeModel.MobilePhone}',
							'{subscribeModel.INN}',
							'{subscribeModel.Address}')"                            ;
                }

                try
                {
                    sqlConnection.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("Не удалось подключиться");
                }


                command = new SqlCommand(commandString, sqlConnection);
                command.ExecuteNonQuery();
                this.subscribersTableAdapter2.Fill(this.phoneCallDataSet15.Subscribers);

                idSubscriber.Text = "";
                ValidateController.CleanerTextBox(textBoxAddress, textBoxInn, textBoxNumber);
                Cursor.Current = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Заполните данные");
            }
        }
예제 #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            cityModel = new CityModel(textBoxCity.Text, numericRateDay.Value, numericRateNight.Value, numericDiscount.Value);
            if (cityModel.validate(errorCity, errorRDay, errorRNight))
            {
                Cursor.Current = Cursors.WaitCursor;
                sqlConnection  = new SqlConnection(con);

                if (ValidateController.validateItem(labelIDCity.Text))
                {
                    commandString = $@"UPDATE [dbo].[City]
								   SET [NameCity] = '{cityModel.CityName}'
									  ,[RateDay] = '{cityModel.RateDay}'
									  ,[RateNigth] = '{cityModel.RateNight}'
									  ,[Discount] = '{cityModel.Discount}'
								   WHERE IdCity = '{labelIDCity.Text}'"                                ;
                }
                else
                {
                    commandString = $@"INSERT INTO [dbo].[City]
							   ([NameCity]
							   ,[RateDay]
							   ,[RateNigth]
							   ,[Discount])
					 VALUES(
						    '{cityModel.CityName}',
							'{cityModel.RateDay.ToString()}',
							'{cityModel.RateNight}',
							'{cityModel.Discount}')"                            ;
                }

                try
                {
                    sqlConnection.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("Не удалось подключиться");
                }
                command = new SqlCommand(commandString, sqlConnection);
                command.ExecuteNonQuery();
                this.cityTableAdapter.Fill(this.phoneCallDataSet19.City);


                labelIDCity.Text = "";
                ValidateController.CleanerTextBox(textBoxCity);
                ValidateController.CleanerNumeric(numericDiscount, numericRateDay, numericRateNight);
            }
        }
예제 #6
0
 private double?CalculationPriceMinutes(string rDay, string rNight, decimal countMIn)
 {
     if (ValidateController.validateItem(rDay) && ValidateController.validateItem(rNight))
     {
         if (date.TimeOfDay.Hours > 12)
         {
             return(Convert.ToDouble(rDay) * Convert.ToDouble(countMIn));
         }
         else
         {
             return(Convert.ToDouble(rNight) * Convert.ToDouble(countMIn));
         }
     }
     return(null);
 }
예제 #7
0
        public bool validate(Label labelMob, Label labelInn, Label labelAddress)
        {
            bool result = ValidateController.validateItem(MobilePhone, labelMob) && ValidateController.validateItem(INN, labelInn) && ValidateController.validateItem(Address, labelAddress);

            return(result);
        }