Exemple #1
0
 static void Main()
 {
     db = new OGMContext();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new LogInForm());
 }
        private void button_leaser_info_Click(object sender, EventArgs e)
        {
            // выбираем строку
            int PK_LeasingContract = -1;

            try
            {
                PK_LeasingContract = Convert.ToInt32(dataGridView_DataSearch.SelectedRows[0].Cells[0].Value);

                if (PK_LeasingContract == -1)
                {
                    throw new Exception();
                }

                RelationshipOrganizationLeasingContract r_leasingContract = null;
                using (OGMContext db = new OGMContext())
                {
                    r_leasingContract = db.relationships_organization_leasing_contract
                                        .Where(r => r.PK_Role == 2 && r.PK_Leasing_Contract == PK_LeasingContract)
                                        .FirstOrDefault();
                }

                if (r_leasingContract == null)
                {
                    throw new Exception();
                }

                new AddOrganizationForm(r_leasingContract.Organization, true).ShowDialog();
            }
            catch
            {
                MessageBox.Show("Не удалось открыть информацию о лизингодателе", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
        private void updateTable()
        {
            using (OGMContext db = new OGMContext())
            {
                var relationships = db.relationships_organization_leasing_contract
                                    .Select(r => new { r.PK_Leasing_Contract, r.Leasing_Contract.contract_number, r.Leasing_Contract.date, r.Leasing_Contract.date_end, r.PK_Role, r.Organization.name })
                                    .Where(r => r.PK_Role == 2);

                dataGridView_DataSearch.DataSource = relationships.ToList();
                SetTextLastColumn();
                dataGridView_DataSearch.ClearSelection();
            }
        }
Exemple #4
0
        private void button_show_act_contract_Click(object sender, EventArgs e)
        {
            try
            {
                int       PK_Equipment = Convert.ToInt32(this.dataGridView.SelectedRows[0].Cells[0].Value);
                Equipment equipment    = null;
                using (OGMContext db = new OGMContext()) { equipment = db.Equipments.Find(PK_Equipment); }

                if (equipment == null)
                {
                    throw new Exception();
                }


                if (this.button_show_act_contract.Text == "Перейти к акту")
                {
                    ActDebit actDebit = null;
                    using (OGMContext db = new OGMContext()) { actDebit = db.ActDebits.Find(equipment.PK_Debit); }

                    if (actDebit == null)
                    {
                        throw new Exception();
                    }

                    new DebitViewForm(actDebit).ShowDialog();
                }
                else if (this.button_show_act_contract.Text == "Перейти к договору")
                {
                    LeasingContract leasingContract = null;
                    using (OGMContext db = new OGMContext()) { leasingContract = db.LeasingContracts.Find(equipment.PK_Leasing); }

                    if (leasingContract == null)
                    {
                        throw new Exception();
                    }

                    new LeasingViewForm(leasingContract).ShowDialog();
                }
            }
            catch
            {
                MessageBox.Show("Не удалось перейти к документу", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void button_Search_Click(object sender, EventArgs e)
        {
            using (OGMContext db = new OGMContext()) {
                List <ActDebit> actDebits       = db.ActDebits.ToList();
                List <ActDebit> actDebitsResult = new List <ActDebit>();

                foreach (var item in actDebits)
                {
                    if (!item.act_number.ToLower().Contains(textBox_ActNumber.Text.ToLower()))
                    {
                        continue;
                    }

                    if (dateTimePicker_DateDebit_From.Checked)
                    {
                        if (item.date.Date < dateTimePicker_DateDebit_From.Value.Date)
                        {
                            continue;
                        }
                    }

                    if (dateTimePicker_DateDebit_To.Checked)
                    {
                        if (item.date.Date > dateTimePicker_DateDebit_To.Value.Date)
                        {
                            continue;
                        }
                    }

                    actDebitsResult.Add(item);
                }

                dataGridView_DataSearch.DataSource = actDebitsResult;
                dataGridView_DataSearch.ClearSelection();
                textBox_ActNumber.Focus();
            }
        }
Exemple #6
0
        private void GenerateTable()
        {
            // получаем из бд строки спецификации

            List <RowAttachmentSpecification> rows = new List <RowAttachmentSpecification>();

            using (OGMContext db = new OGMContext())
                rows = db.RowsAttachmentSpecification.Where(row => row.PK_Leasing_Contract == contract.PK_Leasing_Contract).ToList();

            if (rows.Count == 0)
            {
                return;
            }

            // заполняем таблицу
            foreach (RowAttachmentSpecification row in rows)
            {
                dataGridView_Data.Rows.Add(row.EquipmentGroup.name, row.cost, row.amount, "шт.", row.amount * row.cost);

                LeasingContractTotalCost += row.amount * row.cost;
            }

            dataGridView_Data.ClearSelection();
        }
 private void UpdateTable()
 {
     using (OGMContext db = new OGMContext())
         dataGridView_DataSearch.DataSource = db.ActDebits.ToList();
 }
Exemple #8
0
        private void LeasingViewForm_Load(object sender, EventArgs e)
        {
            // заполнение инфы о договоре
            if (contract == null)
            {
                return;
            }

            ///// то, что хранится непосредственно в таблице договора /////

            // номер и дата
            this.label_LeasingContractNumber.Text += " " + contract.contract_number;
            this.textBox_LeasingNum.Text           = contract.contract_number;
            this.textBox_Date.Text    = DateToString.Translate(this.contract.date, "г.");
            this.textBox_DateEnd.Text = DateToString.Translate(this.contract.date_end, "г.");

            // сроки
            this.numericUpDown_DaysForFirstPayment.Value = contract.days_for_first_payment;
            this.numericUpDown_DaysForReport.Value       = contract.days_for_report;
            this.numericUpDown_DaysForForceMajeure.Value = contract.days_for_force_majeure;

            // ответственность
            this.numericUpDown_Penalty.Value    = contract.penalty;
            this.numericUpDown_MaxPenalty.Value = contract.max_penalty;
            this.numericUpDown_PenaltyFee.Value = contract.penalty_fee;

            // об оборудовании
            this.numericUpDown_PeriodOfUse.Text = contract.period_of_use;
            this.textBox_DateDelivery.Text      = DateToString.Translate(this.contract.date_delivery, "г.");
            this.textBox_AddressDelivery.Text   = contract.address_delivery;

            //// организации подгружаем через поиск связей ////
            ///
            RelationshipOrganizationLeasingContract r_lessee = null;
            RelationshipOrganizationLeasingContract r_seller = null;
            RelationshipOrganizationLeasingContract r_leaser = null;

            using (OGMContext db = new OGMContext())
            {
                r_lessee = db.relationships_organization_leasing_contract.Where(r => r.PK_Leasing_Contract == contract.PK_Leasing_Contract && r.PK_Role == 1).FirstOrDefault();
                r_seller = db.relationships_organization_leasing_contract.Where(r => r.PK_Leasing_Contract == contract.PK_Leasing_Contract && r.PK_Role == 3).FirstOrDefault();
                r_leaser = db.relationships_organization_leasing_contract.Where(r => r.PK_Leasing_Contract == contract.PK_Leasing_Contract && r.PK_Role == 2).FirstOrDefault();
            }

            if (r_lessee != null)
            {
                this.lessee = r_lessee.Organization;
                this.textBox_Lessee.Text = lessee.name;
            }
            if (r_seller != null)
            {
                this.seller = r_seller.Organization;
                this.textBox_Seller.Text = seller.name;
            }
            if (r_leaser != null)
            {
                this.leaser = r_leaser.Organization;
                this.textBox_Leaser.Text = leaser.name;
            }

            GenerateTable();
        }