Esempio n. 1
0
        protected void AddGsmButton_Click(object sender, EventArgs e)
        {
            string typeOfGsm = GsmtypeOfGSMTextBox.Text;
            string tTkofType = GsmtTKOfTypeTextBox.Text;

            if (CheckValues(typeOfGsm, tTkofType))
            {
                Gsm gsm = new Gsm
                {
                    TypeOfGsm = typeOfGsm,
                    TTkofType = tTkofType
                };

                _context.Gsm.Add(gsm);
                _context.SaveChanges();

                GsmtypeOfGSMTextBox.Text = string.Empty;
                GsmtTKOfTypeTextBox.Text = string.Empty;

                AddStatusLabel.Text = "Gsm was successfully added.";

                GsmGridView.PageIndex = GsmGridView.PageCount;
                GetGsm();
            }
        }
Esempio n. 2
0
        protected void AddContainersButton_Click(object sender, EventArgs e)
        {
            int    number       = int.Parse(ContainersNumberTextBox.Text);
            double tankCapacity = double.Parse(ContainersTankCapacityTextBox.Text);

            if (CheckValues(number, tankCapacity))
            {
                Container container = new Container
                {
                    Number       = number,
                    TankCapacity = tankCapacity
                };

                _context.Containers.Add(container);
                _context.SaveChanges();

                ContainersNumberTextBox.Text       = string.Empty;
                ContainersTankCapacityTextBox.Text = string.Empty;

                AddStatusLabel.Text = "Containers was successfully added.";

                ContainersGridView.PageIndex = ContainersGridView.PageCount;
                GetContainers();
            }
        }
Esempio n. 3
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            int      numberOfCapacity = int.Parse(IncomeAndExpensesOfGsmsNumberOfCapacityTextBox.Text);
            DateTime dateAndTimeOfTheOperationIncomeOrExpense = IncomeAndExpensesOfGsmsDateAndTimeOfTheOperationIncomeOrExpenseTextBox.SelectedDate;
            int      incomeOrExpensePerliter    = int.Parse(IncomeAndExpensesOfGsmsIncomeOrExpensePerliterTextBox.Text);
            int      containerId                = int.Parse(IncomeAndExpensesOfGsmsDropDownList1.SelectedValue);
            string   responsibleForTheOperation = IncomeAndExpensesOfGsmsResponsibleForTheOperationTextBox.Text;

            if (CheckValues(numberOfCapacity, incomeOrExpensePerliter, dateAndTimeOfTheOperationIncomeOrExpense, responsibleForTheOperation))
            {
                IncomeAndExpensesOfGsm income = new IncomeAndExpensesOfGsm
                {
                    NumberOfCapacity        = numberOfCapacity,
                    IncomeOrExpensePerliter = incomeOrExpensePerliter,
                    ContainerId             = containerId,
                    DateAndTimeOfTheOperationIncomeOrExpense = dateAndTimeOfTheOperationIncomeOrExpense,
                    ResponsibleForTheOperation = responsibleForTheOperation
                };

                _context.IncomeAndExpensesOfGsms.Add(income);
                _context.SaveChanges();

                AddStatusLabel.Text = "IncomeAndExpensesOfGsm was successfully added.";

                IncomeAndExpensesOfGsmsGridView.PageIndex = IncomeAndExpensesOfGsmsGridView.PageCount;
                GetIncomeAndExpensesOfGsms();
            }
        }
Esempio n. 4
0
        public static void Initialize(Petrol_StationContext petrol_Station)
        {
            petrol_Station.Database.EnsureCreated();

            int rowCount;

            int rowIndex;

            int minStringLength;

            int maxStringLength;

            if (!petrol_Station.Gsm.Any())

            {
                string typeOfGSM;

                string tTKOfType;

                rowCount = 500;

                rowIndex = 0;

                while (rowIndex < rowCount)

                {
                    minStringLength = 8;

                    maxStringLength = 16;

                    typeOfGSM = GetString(minStringLength, maxStringLength);

                    maxStringLength = 32;

                    tTKOfType = GetString(minStringLength, maxStringLength);

                    petrol_Station.Gsm.Add(new Gsm {
                        TTkofType = tTKOfType, TypeOfGsm = typeOfGSM
                    });

                    rowIndex++;
                }

                petrol_Station.SaveChanges();
            }

            if (!petrol_Station.Staff.Any())

            {
                string fullName;

                int staffAge;

                string staffFunction;

                DateTime workingHoursForAWeek;

                rowCount = 20000;

                rowIndex = 0;

                while (rowIndex < rowCount)

                {
                    minStringLength = 8;

                    maxStringLength = 32;

                    fullName = GetString(minStringLength, maxStringLength);

                    staffAge = random.Next(1, 11);

                    staffFunction = GetString(minStringLength, maxStringLength);

                    workingHoursForAWeek = GetDateTime();

                    petrol_Station.Staff.Add(new Staff

                    {
                        FullName = fullName,

                        StaffAge = staffAge,

                        StaffFunction = staffFunction,

                        WorkingHoursForAweek = workingHoursForAWeek,
                    });

                    rowIndex++;
                }
            }

            if (!petrol_Station.IncomeAndExpensesOfGsm.Any())

            {
                minStringLength = 8;

                maxStringLength = 32;

                int numberOfCapacity;

                int incomeOrExpensePerliter;

                DateTime dateAndTimeOfTheOperationIncomeOrExpense;

                string responsibleForTheOperation;

                rowCount = 20000;

                rowIndex = 0;

                while (rowIndex < rowCount)

                {
                    numberOfCapacity = random.Next(1, 8);

                    incomeOrExpensePerliter = random.Next(1, 13);

                    dateAndTimeOfTheOperationIncomeOrExpense = GetDateTime();

                    responsibleForTheOperation = GetString(minStringLength, maxStringLength);

                    petrol_Station.IncomeAndExpensesOfGsm.Add(new IncomeAndExpensesOfGsm

                    {
                        NumberOfCapacity = numberOfCapacity,

                        IncomeOrExpensePerliter = incomeOrExpensePerliter,

                        DateAndTimeOfTheOperationIncomeOrExpense = dateAndTimeOfTheOperationIncomeOrExpense,

                        ResponsibleForTheOperation = responsibleForTheOperation
                    });

                    rowIndex++;
                }

                petrol_Station.SaveChanges();
            }
        }