Esempio n. 1
0
        public void invoiceDelete()
        {
            DataSet1 dataSetRead = BL.getInvoices();

            List <DataRow> rows_list = dataSetRead.invoice.Select("invoice_number = '000001'").OfType <DataRow>().ToList();

            // Сортируем строки по id в порядке возрастания
            rows_list.Sort((x, y) => ((int)x["id"]).CompareTo((int)y["id"]));
            // Количество записей до удаления
            int countRowBefore = rows_list.Count();

            Assert.That(countRowBefore, Is.EqualTo(1));

            //удаляем
            List <DataRow> list_1 = dataSetRead.invoice.Select("invoice_number = '000001'").OfType <DataRow>().ToList();

            foreach (DataRow rowForDel in list_1)
            {
                rowForDel.Delete();
            }
            BL.updateInvoices(dataSetRead);
            dataSetRead.AcceptChanges();

            // проверяем что теперь записей стало на одну больше
            DataSet1       dataSet_AfterDel      = BL.getInvoices();
            List <DataRow> rows_list_AfterInsert = dataSet_AfterDel.invoice.Select("invoice_number = '000001'").OfType <DataRow>().ToList();

            Assert.That(rows_list_AfterInsert.Count, Is.EqualTo(0));
        }
Esempio n. 2
0
        public void materialDelete()
        {
            DataSet1 dataSetRead = BL.getMaterials();

            List <DataRow> rows_list = dataSetRead.material.Select("name_material = 'Бревна буковые'").OfType <DataRow>().ToList();

            // Сортируем строки по id в порядке возрастания
            rows_list.Sort((x, y) => ((int)x["id"]).CompareTo((int)y["id"]));
            // Количество записей до удаления
            int countRowBefore = rows_list.Count();

            Assert.That(countRowBefore, Is.EqualTo(1));

            //удаляем
            List <DataRow> list_1 = dataSetRead.material.Select("name_material = 'Бревна буковые'").OfType <DataRow>().ToList();

            foreach (DataRow rowForDel in list_1)
            {
                //dataSetRead.material.Rows.Remove(rowForDel);
                rowForDel.Delete();
            }
            BL.updateMaterials(dataSetRead);
            dataSetRead.AcceptChanges();

            // проверяем что теперь записей стало на одну больше

            DataSet1 dataSet_AfterDel = BL.getMaterials();
            //BL.updateMaterials(dataSet_AfterInsert);
            List <DataRow> rows_list_AfterInsert = dataSet_AfterDel.material.Select("name_material = 'Бревна буковые'").OfType <DataRow>().ToList();

            Assert.That(rows_list_AfterInsert.Count, Is.EqualTo(0));
        }
        public void organizationDelete()
        {
            DataSet1 dataSetRead = BL.getOrganizations();

            List <DataRow> rows_list = dataSetRead.organization.Select("organization_name = 'ОАО \"КРАСНОЯРСКЛЕСОМАТЕРИАЛЫ\"'").OfType <DataRow>().ToList();

            // Сортируем строки по id в порядке возрастания
            rows_list.Sort((x, y) => ((int)x["id"]).CompareTo((int)y["id"]));
            // Количество записей до удаления
            int countRowBefore = rows_list.Count();

            Assert.That(countRowBefore, Is.EqualTo(1));

            //удаляем
            List <DataRow> list_1 = dataSetRead.organization.Select("organization_name = 'ОАО \"КРАСНОЯРСКЛЕСОМАТЕРИАЛЫ\"'").OfType <DataRow>().ToList();

            foreach (DataRow rowForDel in list_1)
            {
                rowForDel.Delete();
            }
            BL.updateOrganizations(dataSetRead);
            dataSetRead.AcceptChanges();

            // проверяем что теперь записей стало на одну больше

            DataSet1       dataSet_AfterDel      = BL.getOrganizations();
            List <DataRow> rows_list_AfterInsert = dataSet_AfterDel.organization.Select("organization_name = 'ОАО \"КРАСНОЯРСКЛЕСОМАТЕРИАЛЫ\"'").OfType <DataRow>().ToList();

            Assert.That(rows_list_AfterInsert.Count, Is.EqualTo(0));
        }
Esempio n. 4
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (edited.Value)
            {
                if (DialogResult.Yes == MessageBox.Show("Сохранить изменения в БД?", "Внимание", MessageBoxButtons.YesNo))
                {
                    try
                    {
                        int       kt   = 0;
                        int       kol  = dataSet1.postavki.Count;
                        DataRow[] rows = new DataRow[kol];
                        foreach (DataRow r in dataSet1.postavki)
                        {
                            if (r.RowState == DataRowState.Deleted)
                            {
                                rows[kt] = r;
                                kt++;
                            }
                        }
                        for (int k = 0; k <= kt; k++)
                        {
                            postavkiTableAdapter.Update(rows[k]);
                        }
                        postavshikiTableAdapter.Update(dataSet1.postavshiki);
                        produktTableAdapter.Update(dataSet1.produkt);

                        kol  = dataSet1.postavki.Count;
                        rows = new DataRow[kol];
                        kt   = 0;
                        foreach (DataRow r in dataSet1.postavki)
                        {
                            if (r.RowState == DataRowState.Modified || r.RowState == DataRowState.Added)
                            {
                                rows[kt] = r;
                                kt++;
                            }
                        }
                        for (int k = 0; k <= kt; k++)
                        {
                            postavkiTableAdapter.Update(rows[k]);
                        }
                        dataSet1.AcceptChanges();
                        edited.Value = false;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    dataSet1.RejectChanges();
                    edited.Value = false;
                }
                if (DialogResult.No == MessageBox.Show("Выйти?", "Выход", MessageBoxButtons.YesNo))
                {
                    e.Cancel = true;
                }
            }
        }
Esempio n. 5
0
        private void button_apply_Click(object sender, EventArgs e)
        {
            tryBox();

            if ((tryDate == true) && (tryNumb == true) && (tryPhoneNum == true) && (tryAdd == true))
            {
                if (testLeft == false)
                {
                    DialogResult vibor2 = MessageBox.Show("Вы действительно хотите добавить пользователя?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (vibor2 == DialogResult.Yes)
                    {
                        String   datTime;
                        DateTime inBox = new DateTime();
                        inBox.AddHours(0);
                        inBox.AddMinutes(0);
                        inBox.AddSeconds(0);
                        datTime = textBox_day.Text + "." + textBox_month.Text + "." + textBox_year.Text;
                        inBox   = DateTime.Parse(datTime);
                        MessageBox.Show("Пользователь добавлен!");
                        user.addNewClient(textBox_first_name.Text.ToString(), textBox_last_name.Text.ToString(),
                                          inBox, 100,
                                          (textBox_carNumber1.Text + textBox_carNumber2.Text + textBox_carNumber3.Text), text_telephone.Text.ToString(), false);
                        user.Update(dataNew);
                        dataNew.AcceptChanges();
                    }
                    if (vibor2 == DialogResult.No)
                    {
                    }
                }
                else
                {
                    String   datTime;
                    DateTime inBox = new DateTime();
                    inBox.AddHours(0);
                    inBox.AddMinutes(0);
                    inBox.AddSeconds(0);
                    datTime = textBox_day.Text + "." + textBox_month.Text + "." + textBox_year.Text;
                    inBox   = DateTime.Parse(datTime);
                    MessageBox.Show("Пользователь добавлен!");
                    user.addNewClient(textBox_first_name.Text.ToString(), textBox_last_name.Text.ToString(),
                                      inBox, 100,
                                      (textBox_carNumber1.Text + textBox_carNumber2.Text + textBox_carNumber3.Text), text_telephone.Text.ToString(), false);
                }
            }
            else
            if (tryDate == false)
            {
                MessageBox.Show("Неверный формат даты!");
            }
            testLeft = false;
            tryAdd   = true;
        }
Esempio n. 6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            tblUser.Fill(ds1.UserInfo);
            cardNumber = Session["cardNumber"].ToString();

            DataRow[] dr = ds1.UserInfo.Select("Card_Number = '" + cardNumber + "'");
            dr[0]["Email"]        = TextBox1.Text;
            dr[0]["Phone_Number"] = TextBox2.Text;
            dr[0]["Address"]      = TextBox3.Text;

            tblUser.Update(ds1.UserInfo);
            ds1.AcceptChanges();
            // tblUser.Transaction.Commit();
        }
Esempio n. 7
0
        //ОТЧЕТ
        private void btnReport_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                ds.AcceptChanges();

                licenseAdapter.FillByActiveAudit(ds.License, ActiveAudit.ID, ActiveAudit.ID_Company);

                elHouseAdapter.FillByActiveAudit(ds.ElHouse, ActiveAudit.ID, ActiveAudit.ID_Company);
                elHouseParamAdapter.Fill(ds.ElHouseParams);

                gfObjectsAdapter.FillByActiveAudit(ds.GilFondObject, ActiveAudit.ID, ActiveAudit.ID_Company);
                porchAdapter.Fill(ds.PorchGilFondОbjects);
                pomeschAdapter.Fill(ds.PomeschGilFondОbs);

                qrLSPlatDocsAdapter.Fill(ds.qrLicSchet_PlatDocs, ActiveAudit.ID, ActiveAudit.ID_Company); //query LS -> PlatDocs

                lichouseAdapter.FillByActiveAudit(ds.LicenseHouses, ActiveAudit.ID, ActiveAudit.ID_Company);
                DataSet1.LicenseHousesRow[] licHouseArr = ds.LicenseHouses.ToArray();                  //Дома по лицензии

                dogUprAdapter.FillByActiveAudit(ds.DogUpravl, ActiveAudit.ID, ActiveAudit.ID_Company); //договоры упр
                DataSet1.DogUpravlRow[] doguprArr = ds.DogUpravl.ToArray();                            //Дома по договорам

                companiesAdapter.Fill(ds.Companies);

                //Сравниваем дома в договорах управления и лицензиях - ОТЛОЖЕНО

                /*
                 * /// повтор вызов приводит к ошибке dogUprAdapter.FillByActiveAudit(ds.DogUpravl, ActiveAudit.ID, ActiveAudit.ID_Company); //договоры упр
                 * string[] dogupr_Arr = ds.DogUpravl.Select(d => d.Управляемые_объекты).ToArray();
                 * /// повтор вызов приводит к ошибке  lichouseAdapter.FillByActiveAudit(ds.LicenseHouses, ActiveAudit.ID, ActiveAudit.ID_Company);
                 * string[] licHouse_Arr = ds.LicenseHouses.Select(d => d.Адрес).ToArray();
                 */

                priborAdapter.FillByActiveAudit(ds.Pribor, ActiveAudit.ID, ActiveAudit.ID_Company);
                DataSet1.PriborRow[] priborArr = ds.Pribor.ToArray();

                /////////////////

                repGFObj.Clear();

                DataSet1.LicenseRow LicenseCompany = null;
                if (ds.License.Rows.Count > 0)
                {
                    LicenseCompany = (DataSet1.LicenseRow)ds.License.Rows[0];
                }
                //для случая с ТСЖ
                DataSet1.CompaniesRow ActiveCompany = ds.Companies.Where(c => c.ID == ActiveAudit.ID_Company).FirstOrDefault();

                foreach (DataSet1.GilFondObjectRow gfoRow in ds.GilFondObject.Rows)
                {
                    repGFObj.Add(new repGilFondObj
                    {
                        ID_GilFondObject = gfoRow.ID_GilFondObject,
                        ID_Audit         = ActiveAudit.ID,
                        ID_Company       = ActiveAudit.ID_Company,

                        CompanyName    = LicenseCompany != null ? LicenseCompany.Лицензиат : ActiveAudit.Company,
                        CompanyAddress = LicenseCompany != null ? LicenseCompany.Адрес : "???",
                        CompanyINN     = LicenseCompany != null ? LicenseCompany.ИНН : ActiveCompany.INN,
                        CompanyLicense = LicenseCompany != null ? LicenseCompany.Лицензия : "????",

                        Address       = gfoRow.Адрес,
                        quantGilPom   = gfoRow._Кол_во_помещений.Split('/')[0] == "-" ? 0 : Convert.ToInt32(gfoRow._Кол_во_помещений.Split('/')[0]),
                        quantNoGilPom = gfoRow._Кол_во_помещений.Split('/')[1] == "- " ? 0 : Convert.ToInt32(gfoRow._Кол_во_помещений.Split('/')[1])
                    });

                    DataSet1.PorchGilFondОbjectsRow[] arr = (DataSet1.PorchGilFondОbjectsRow[])gfoRow.GetChildRows("GilFondObjectPorchGilFondОbjects");
                    foreach (DataSet1.PorchGilFondОbjectsRow porch in arr)
                    {
                        DataSet1.PomeschGilFondОbsRow[] pomscharr = (DataSet1.PomeschGilFondОbsRow[])porch.GetChildRows("PorchGilFondОbjectsPomeschGilFondОbs");
                        // Console.WriteLine(pomscharr);
                    }
                }

                //Лицевые счета
                licSchetAdapter.FillByActiveAudit(ds.LicSchet, ActiveAudit.ID, ActiveAudit.ID_Company);
                DataSet1.LicSchetRow[] lsArr = ds.LicSchet.ToArray();
                int quantLS = lsArr.Count(); //общее кол-во ЛС
                                             //???? DateTime tls = Convert.ToDateTime(lsArr.Max(l => Convert.ToDateTime(l.Дата_события))); //Макс дата выгрузки ЛС

                //Перечень работ и услуг
                pereschRabUslAdapter.FillByActiveAudit(ds.PerechRabUslug, ActiveAudit.ID, ActiveAudit.ID_Company);
                DataSet1.PerechRabUslugRow[] perArr = ds.PerechRabUslug.ToArray();

                //Голосования
                votingAdapter.FillByActiveAudit(ds.Voting, ActiveAudit.ID, ActiveAudit.ID_Company);
                DataSet1.VotingRow[] votingArr = ds.Voting.ToArray();

                DataSet1.qrLicSchet_PlatDocsRow[] qrLSDocsArr = ds.qrLicSchet_PlatDocs.ToArray();

                foreach (repGilFondObj gfo in repGFObj)
                {
                    gfo.quantPribor = QuantPriborByHouse(priborArr, gfo.Address);

                    if (!ActiveAudit.Company.StartsWith("ТСЖ") && !ActiveAudit.Company.StartsWith("ЖСК") && !ActiveAudit.Company.StartsWith("ТСН"))
                    {
                        Tuple <string, string> dates = DatesByLicensyAndDogUpr(licHouseArr, doguprArr, gfo.Address);
                        gfo.BeginDateByLic    = dates.Item1;
                        gfo.BeginDateByDogUpr = dates.Item2;
                    }

                    if (ActiveAudit.Company.StartsWith("ТСЖ") || ActiveAudit.Company.StartsWith("ЖСК") || ActiveAudit.Company.StartsWith("ТСН"))
                    {
                        ustavHouseAdapter.FillByCurrentAudit(ds.UstavHouse, ActiveAudit.ID);
                        DataSet1.UstavHouseRow[] ustavHousesArr = ds.UstavHouse.ToArray();

                        DataSet1.UstavHouseRow uhrow = ustavHousesArr.Where(h => h.Адрес == gfo.Address).FirstOrDefault();

                        gfo.BeginDateByLic = "отсутствует";

                        if (uhrow != null)
                        {
                            gfo.BeginDateByDogUpr = uhrow.Период;
                        }
                        else
                        {
                            gfo.BeginDateByDogUpr = "-";
                        }
                    }

                    DataSet1.PerechRabUslugRow x = perArr.Where(p => p.Адрес == gfo.Address).FirstOrDefault();
                    if (x != null)
                    {
                        gfo.perechRabUsl = x.Перечень;
                    }
                    else
                    {
                        gfo.perechRabUsl = "отсутствует";
                    }

                    Tuple <int, DateTime?> ls = LS_Quant_Date(lsArr, gfo.Address); //Кол-во и дата ЛС по объекту
                    gfo.quantLS   = ls.Item1;
                    gfo.maxDateLS = ls.Item2;

                    Tuple <int, DateTime?> vot = Voting_Qiant_Date(votingArr, gfo.Address);
                    gfo.quantVoting   = vot.Item1;
                    gfo.maxDateVoting = vot.Item2;

                    //////// Платежные док-ты со статусами Размещен и Проект
                    gfo.quantPlatDocsRazm = qrLSDocsArr
                                            .Where(d => !d.IsСтатус_документаNull())
                                            .Where(d => d.Адрес.Contains(gfo.Address))
                                            .Where(s => s.Статус_документа == "Размещен")
                                            .Count();

                    gfo.quantPlatDocsNoRazm = qrLSDocsArr
                                              .Where(d => !d.IsСтатус_документаNull())
                                              .Where(d => d.Адрес.Contains(gfo.Address))
                                              .Where(s => s.Статус_документа == "Проект")
                                              .Count();
                }

                frmReport ft = new frmReport(repGFObj);
                ft.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 8
0
 public Pistes_Edition(DataSet1 ds)
 {
     InitializeComponent();
     copieDataSet = ds;
     copieDataSet.AcceptChanges();
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (action == ActionState.New)
            {
                try
                {
                    DataRow newRow = phoneNumbersDataSet.PhoneNumbers.NewRow();
                    newRow.BeginEdit();
                    newRow["Phonenum"]   = txtPhoneNumber.Text.Trim();
                    newRow["Subscriber"] = txtSubscriber.Text.Trim();
                    newRow.EndEdit();
                    phoneNumbersDataSet.PhoneNumbers.Rows.Add(newRow);
                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges();
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
            }
            else
            if (action == ActionState.Edit)
            {
                try
                {
                    DataRow editRow = phoneNumbersDataSet.PhoneNumbers.Rows[lstPhones.SelectedIndex];
                    editRow.BeginEdit();
                    editRow["Phonenum"]   = txtPhoneNumber.Text.Trim();
                    editRow["Subscriber"] = txtSubscriber.Text.Trim();
                    editRow.EndEdit();
                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges();
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnDelete.IsEnabled      = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
                txtPhoneNumber.SetBinding(TextBox.TextProperty, txtPhoneNumberBinding);
                txtSubscriber.SetBinding(TextBox.TextProperty, txtSubscriberBinding);
            }
            else
            if (action == ActionState.Delete)
            {
                try
                {
                    DataRow deleterow = phoneNumbersDataSet.PhoneNumbers.Rows[lstPhones.SelectedIndex];
                    deleterow.Delete();

                    tblPhoneNumbersAdapter.Update(phoneNumbersDataSet.PhoneNumbers);
                    phoneNumbersDataSet.AcceptChanges();
                }
                catch (DataException ex)
                {
                    phoneNumbersDataSet.RejectChanges(); MessageBox.Show(ex.Message);
                    MessageBox.Show(ex.Message);
                }
                btnNew.IsEnabled         = true;
                btnEdit.IsEnabled        = true;
                btnDelete.IsEnabled      = true;
                btnSave.IsEnabled        = false;
                btnCancel.IsEnabled      = false;
                lstPhones.IsEnabled      = true;
                btnPrevious.IsEnabled    = true;
                btnNext.IsEnabled        = true;
                txtPhoneNumber.IsEnabled = false;
                txtSubscriber.IsEnabled  = false;
                txtPhoneNumber.SetBinding(TextBox.TextProperty, txtPhoneNumberBinding);
                txtSubscriber.SetBinding(TextBox.TextProperty, txtSubscriberBinding);
            }
        }