public static void UpdateShkaf(Shkaf newShkaf, int oldShkafID)
        {
            var query = from shkaf in DataBaseAccess.db.Shkafs
                        where shkaf.ShkafID == oldShkafID
                        select shkaf;

            try
            {
                foreach (Shkaf shkaf in query)
                {
                    //shkaf.ShkafID = newShkaf.ShkafID;
                    shkaf.Address          = newShkaf.Address;
                    shkaf.InstallDate      = newShkaf.InstallDate;
                    shkaf.PoverkaDate      = newShkaf.PoverkaDate;
                    shkaf.Installer        = newShkaf.Installer;
                    shkaf.CountersQuantity = newShkaf.CountersQuantity;
                    //shkaf.Is5YearPoverka = newShkaf.Is5YearPoverka;
                    //shkaf.IsUnauthorizedAccess = newShkaf.IsUnauthorizedAccess;
                    shkaf.Password1 = newShkaf.Password1;
                    shkaf.Password2 = newShkaf.Password2;
                    shkaf.Password3 = newShkaf.Password3;
                }
                db.SubmitChanges();
                MessageBox.Show("Корректировка модуля прошла успешно.", "Подтверждение!",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            catch (Exception e)
            {
                MessageBox.Show("Ошибка при корректировке модуля. Корректировка не сохранена.",
                                "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public static void NewShkaf(Shkaf newShkaf)
 {
     try
     {
         db.Shkafs.InsertOnSubmit(newShkaf);
         db.SubmitChanges();
         MessageBox.Show("Модуль создан.", "Подтверждение!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception e)
     {
         MessageBox.Show("Ошибка при создании модуля. Модуль не создан.",
                         "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
 public Counter(SqlInt32 counterID, Shkaf shkaf, SqlString counterOwner, SqlString telephoneOwner,
                SqlBoolean?isNonPaynted, SqlDateTime?installDate, SqlInt32?currentMonthDayEnergy,
                SqlInt32?currentMonthNightEnergy, SqlInt32?pastMonthDayEnergy, SqlInt32?pastMonthNightEnergy)
 {
     this.counterID               = counterID;
     this.shkaf                   = shkaf;
     this.counterOwner            = counterOwner;
     this.telephoneOwner          = telephoneOwner;
     this.isNonPaynted            = isNonPaynted;
     this.installDate             = installDate;
     this.currentMonthDayEnergy   = currentMonthDayEnergy;
     this.currentMonthNightEnergy = currentMonthNightEnergy;
     this.pastMonthDayEnergy      = pastMonthDayEnergy;
     this.pastMonthNightEnergy    = pastMonthNightEnergy;
 }
Example #4
0
        private void createNewShkafButton_Click(object sender, EventArgs e)
        {
            if (!IsValidForm())
            {
                MessageBox.Show("Создание нового модуля невозможно из-за неправильных входных значений",
                                "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult result = MessageBox.Show("Вы действительно хотите создать модуль?", "Указание",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            else
            {
                var query = (from shkaf in DataBaseAccess.db.Shkafs
                             where shkaf.ShkafID == int.Parse(shkafNumberTextBox.Text.Trim())
                             select shkaf).ToList();
                if (query.Count > 0)
                {
                    MessageBox.Show("модуль с номером " + shkafNumberTextBox.Text.Trim() +
                                    " уже существует.\n Задайте модулю другой номер", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                Shkaf newShkaf = new Shkaf
                {
                    ShkafID          = int.Parse(shkafNumberTextBox.Text.Trim()),
                    Address          = addressTextBox.Text.Trim(),
                    InstallDate      = installShkafDateTimePicker.Value,
                    PoverkaDate      = poverkaDateTimePicker.Value,
                    Installer        = installerTextBox.Text.Trim(),
                    CountersQuantity = int.Parse(countersUpDown.Value.ToString()),
                    //Is5YearPoverka = false,
                    //IsUnauthorizedAccess = false,
                    Password1 = password1TextBox.Text.Trim(),
                    Password2 = password2TextBox.Text.Trim(),
                    Password3 = password3TextBox.Text.Trim()
                };

                DataBaseAccess.NewShkaf(newShkaf);
                ClearForm();
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (!IsValidForm())
            {
                MessageBox.Show("Корректировка модуля невозможно из-за неправильных входных значений",
                                "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult result = MessageBox.Show("Вы действительно хотите изменить параметры модуля номер " +
                                                  (listBox1.SelectedItem as Shkaf).ShkafID.ToString() + "?", "Указание",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            else
            {
                Shkaf newShkaf = new Shkaf
                {
                    ShkafID          = int.Parse(shkafNumberTextBox.Text.Trim()),
                    Address          = addressTextBox.Text.Trim(),
                    InstallDate      = installDateTimePicker.Value,
                    PoverkaDate      = poverkaDateTimePicker.Value,
                    Installer        = installerTextBox.Text.Trim(),
                    CountersQuantity = (int)maxCountersUpDown.Value,
                    //Is5YearPoverka = (is5YearPoverkaComboBox.Text == "Да") ? true : false,
                    //IsUnauthorizedAccess = (unAuthorizedComboBox.Text == "Да") ? true : false,
                    Password1 = password1TextBox.Text.Trim(),
                    Password2 = password2TextBox.Text.Trim(),
                    Password3 = password3TextBox.Text.Trim()
                };

                DataBaseAccess.UpdateShkaf(newShkaf, ((Shkaf)listBox1.SelectedItem).ShkafID);

                //MessageBox.Show("Изменения шкафа номер: " + newShkaf.ShkafID.ToString() + " приняты!",
                //  "Подтверждение", MessageBoxButtons.OK, MessageBoxIcon.Information);

                listBox1.Items.Clear();
                foreach (Shkaf shkaf in DataBaseAccess.db.Shkafs)
                {
                    listBox1.Items.Add(shkaf);
                    listBox1.Sorted = true;
                }
            }
        }
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex != -1)
     {
         Shkaf shkaf = (Shkaf)listBox1.SelectedItem;
         shkafNumberTextBox.Text     = shkaf.ShkafID.ToString();
         installDateTimePicker.Value = (DateTime)shkaf.InstallDate;
         poverkaDateTimePicker.Value = (DateTime)shkaf.PoverkaDate;
         addressTextBox.Text         = shkaf.Address.ToString();
         installerTextBox.Text       = shkaf.Installer.ToString();
         countersUpDown.Value        = Convert.ToDecimal(shkaf.CountersQuantity);
         unAuthorizedComboBox.Text   = shkaf.IsUnauthorizedAccess ? "Да" : "Нет";
         is5YearPoverkaComboBox.Text = shkaf.Is5YearPoverka ? "Да" : "Нет";
         password1TextBox.Text       = shkaf.Password1.ToString();
         password2TextBox.Text       = shkaf.Password2.ToString();
         password3TextBox.Text       = shkaf.Password3.ToString();
     }
 }
Example #7
0
 private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (checkedListBox1.SelectedIndex != -1)
     {
         Shkaf shkaf = (Shkaf)checkedListBox1.SelectedItem;
         shkafNumberTextBox.Text    = shkaf.ShkafID.ToString();
         installDateTextBox.Text    = DateTime.Parse(shkaf.InstallDate.ToString()).ToShortDateString();
         poverkaDateTextBox.Text    = DateTime.Parse(shkaf.PoverkaDate.ToString()).ToShortDateString();
         password1TextBox.Text      = shkaf.Password1.ToString();
         password2TextBox.Text      = shkaf.Password2.ToString();
         password3TextBox.Text      = shkaf.Password3.ToString();
         installerTextBox.Text      = shkaf.Installer.ToString();
         addressTextBox.Text        = shkaf.Address.ToString();
         countersTextBox.Text       = shkaf.CountersQuantity.ToString();
         unAuthorizedTextBox.Text   = shkaf.IsUnauthorizedAccess ? "Да" : "Нет";
         is5YearPoverkaTextBox.Text = shkaf.Is5YearPoverka ? "Да" : "Нет";
     }
 }
 public CounterInformationReportForm(IEnumerable <CounterInformationR> a, bool isChecked,
                                     string beginDate, string endDate, Shkaf shkaf, Counter counter, decimal sumTarif)
 {
     InitializeComponent();
     isOpened = true;
     counterInformationReport1.SetDataSource(a);
     ((TextObject)counterInformationReport1.Section2.ReportObjects["shkafNumberText"]).Text   = shkaf.ShkafID.ToString();
     ((TextObject)counterInformationReport1.Section2.ReportObjects["shkafAddressText"]).Text  = shkaf.Address;
     ((TextObject)counterInformationReport1.Section2.ReportObjects["counterNumberText"]).Text = counter.CounterID.ToString();
     ((TextObject)counterInformationReport1.Section2.ReportObjects["poverkaDateText"]).Text   = counter.InstallDate.ToShortDateString();
     ((TextObject)counterInformationReport1.Section2.ReportObjects["ownerNameText"]).Text     = counter.CounterOwner;
     ((TextObject)counterInformationReport1.Section2.ReportObjects["telephoneText"]).Text     = counter.TelephoneOwner;
     ((TextObject)counterInformationReport1.Section4.ReportObjects["sumText"]).Text           = sumTarif.ToString();
     if (isChecked)
     {
         ((TextObject)counterInformationReport1.Section2.ReportObjects["beginDateLabel"]).Text = "Начальное время: " + beginDate;
         ((TextObject)counterInformationReport1.Section2.ReportObjects["endDateLabel"]).Text   = "Конечное время: " + endDate;
     }
     crystalReportViewer1.ReportSource = counterInformationReport1;
 }
        public static void DeleteShkaf(Shkaf delShkaf)
        {
            try
            {
                var query = from shkaf in db.Shkafs
                            where shkaf.ShkafID == delShkaf.ShkafID
                            select shkaf;

                foreach (Shkaf shkaf in query)
                {
                    db.Shkafs.DeleteOnSubmit(shkaf);
                }

                db.SubmitChanges();
            }

            catch (Exception e)
            {
                MessageBox.Show("Ошибка при удалении модуля " + delShkaf.ShkafID + ".", "Ошибка!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #10
0
 partial void DeleteShkaf(Shkaf instance);
Example #11
0
 partial void UpdateShkaf(Shkaf instance);
Example #12
0
 partial void InsertShkaf(Shkaf instance);