public InvoiceForm(TenderYear year) { invoiceRecord = new Invoice(); InitializeFormControls(year); LoadContractsRecords(); }
private void InitializeFormControls(TenderYear year) { InitializeComponent(); button1.Visible = UserSession.IsAuthorized; using (TenderContext tc = new TenderContext()) { contractorCBList.DataSource = tc.Contractors.OrderBy(p => p.ShortName).ToList(); contractorCBList.DisplayMember = "ShortName"; contractorCBList.ValueMember = "Id"; } isPossibleToChangeContractMainData = true; locker = new object(); label8.Text = string.Empty; contractUsedSumLabel.Text = contractRemainLabel.Text = string.Empty; filesTable.AutoGenerateColumns = contractChangesTable.AutoGenerateColumns = contractInvoicesTable.AutoGenerateColumns = false; deletingFiles = new List <UploadedFile>(); relatedFiles = new BindingList <UploadedFile>(); filesTable.DataSource = relatedFiles; DataGridViewHelper.ConfigureFileTable(filesTable, relatedFiles, deletingFiles, linkLabel1, linkLabel2, linkLabel3); dateOfSigning.Value = dateOfStart.Value = dateOfEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddYears(Convert.ToInt32(year.Year) - DateTime.Now.Year); dateOfSigning.MinDate = dateOfStart.MinDate = dateOfEnd.MinDate = new DateTime(Convert.ToInt32(year.Year), 1, 1, 0, 0, 0); dateOfSigning.MaxDate = dateOfStart.MaxDate = dateOfEnd.MaxDate = new DateTime(Convert.ToInt32(year.Year), 12, 31, 0, 0, 0); dateOfEnd.Value = new DateTime(Convert.ToInt32(year.Year), 12, 31, 0, 0, 0); hiddenPagesList = new List <TabPage>(); contractChangesTable.RowsAdded += (sender, e) => DataGridViewHelper.CalculateNewRowNumber(contractChangesTable, 0, e.RowIndex, e.RowCount); contractInvoicesTable.RowsAdded += (sender, e) => DataGridViewHelper.CalculateNewRowNumber(contractInvoicesTable, 0, e.RowIndex, e.RowCount); }
public EstimateYearSpendingReport(Estimate est, bool isNewSystem = true) { this.est = est; this.year = est.Year; this.isNewSystem = isNewSystem; LoadMoneySourcesList(); }
public PlannedSpendingForm(TenderYear year) { spendingRecord = new PlannedSpending(); InitializeFormControls(year); LoadKekvsList(); }
public YearPlanReport(TenderYear year, Estimate est, bool isNewSystem, KekvCode kekv) { this.year = year; this.estFilter = est; this.isNewSystem = isNewSystem; this.kekvFilter = kekv; }
public EstimateForm(TenderYear year) { InitializeFormControls(); currentEstimate = new Estimate(); currentEstimate.Year = year; currentEstimate.TenderYearId = year.Id; }
public ContractsSpendingReport(TenderYear year, Estimate est, bool isNewSystem, KekvCode kekv, Contractor contractor) { this.estFilter = est; this.year = year; this.isNewSystem = isNewSystem; this.kekvFilter = kekv; this.contractorFilter = contractor; LoadMoneySourceList(); }
public ContractForm(TenderYear year) { currentContract = new Contract(); InitializeFormControls(year); while (tabControl1.TabCount > 2) { hiddenPagesList.Add(tabControl1.TabPages[2]); tabControl1.TabPages.RemoveAt(2); } }
private void InitializeFormControls(TenderYear year) { InitializeComponent(); button1.Visible = UserSession.IsAuthorized; label6.Text = estimateNameLabel.Text = string.Empty; this.year = year; controlValueWasChangedByUser = false; locker = new object(); contractsRemains = new List <decimal>(); moneysOnSources = new List <decimal>(); relatedFiles = new BindingList <UploadedFile>(); deletingFiles = new BindingList <UploadedFile>(); DataGridViewHelper.ConfigureFileTable(filesTable, relatedFiles, deletingFiles, linkLabel1, linkLabel2, linkLabel3); filesTable.DataSource = relatedFiles; numberTextBox.Text = invoiceRecord.Number; descriptionTextBox.Text = invoiceRecord.Description; invoiceFullSum.Value = invoiceRecord.Sum; IsCreditCheckBox.Checked = invoiceRecord.IsCredit; switch (invoiceRecord.Status) { case PaymentStatus.New: newStatusRButton.Checked = true; break; case PaymentStatus.OnPayment: onPayStatusRButton.Checked = true; break; case PaymentStatus.Payed: paidStatusRButton.Checked = true; break; } if (invoiceRecord.Id == 0) { invoiceDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddYears(Convert.ToInt32(year.Year) - DateTime.Now.Year); } else { invoiceDate.Value = invoiceRecord.Date; } invoiceDate.MaxDate = new DateTime(Convert.ToInt32(year.Year), 12, 31, 0, 0, 0); invoiceDate.MinDate = new DateTime(Convert.ToInt32(year.Year), 1, 1, 0, 0, 0); using (TenderContext tc = new TenderContext()) { sourcesList = tc.MoneySources.OrderBy(p => p.ViewPriority).ToList(); contractorsCBList.DataSource = tc.Contracts.ToList() .Where(p => (p.RecordInPlan.Estimate.TenderYearId == year.Id) && (p.Status == ContractStatus.Active)) .Select(p => p.Contractor).Distinct().OrderBy(p => p.ShortName) .ToList(); contractorsCBList.ValueMember = "Id"; contractorsCBList.DisplayMember = "ShortName"; contractsCBList.ValueMember = "Id"; contractsCBList.DisplayMember = "FullName"; } for (int i = 0; i <= sourcesList.Count; i++) { DataGridViewRow newRow = new DataGridViewRow(); newRow.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; newRow.DefaultCellStyle.WrapMode = DataGridViewTriState.True; if (i < sourcesList.Count) { newRow.HeaderCell.Value = sourcesList[i].Name.ToString(); } else { newRow.HeaderCell.Value = "ВСЬОГО"; newRow.DefaultCellStyle.Font = FormStyles.MoneyTotalsFont; newRow.ReadOnly = true; } balanceChangesTable.Rows.Add(newRow); } for (int i = 0; i < balanceChangesTable.ColumnCount; i++) { balanceChangesTable.Columns[i].ValueType = typeof(decimal); balanceChangesTable.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } controlValueWasChangedByUser = false; for (int i = 0; i < (balanceChangesTable.RowCount - 1); i++) { balanceChangesTable.Rows[i].Cells[0].Value = 0; balanceChangesTable.Rows[i].Cells[1].Value = 0; moneysOnSources.Add(0); } controlValueWasChangedByUser = true; }
public PlannedSpendingForm(TenderYear year, PlannedSpending spending) { spendingRecord = spending; InitializeFormControls(year); if (!UserSession.IsAuthorized) { this.Text = "Перегляд даних витрати"; } else { this.Text = "Редагування даних витрати"; } using (TenderContext tc = new TenderContext()) { tc.PlannedSpending.Attach(spendingRecord); controlValueWasChangedByUser = false; estimateCBList.DataSource = new List <Estimate> { spendingRecord.Estimate }; mainKekvCBList.DataSource = new List <KekvCode> { spendingRecord.PrimaryKekv }; altKekvCBList.DataSource = new List <KekvCode> { spendingRecord.SecondaryKekv }; estimateCBList.Enabled = mainKekvCBList.Enabled = altKekvCBList.Enabled = false; controlValueWasChangedByUser = true; foreach (var file in spendingRecord.RelatedFiles) { relatedFiles.Add(file); } var lst = tc.BalanceChanges .Where(p => (p.EstimateId == spendingRecord.EstimateId) && (p.PrimaryKekvId == spendingRecord.PrimaryKekvId) && ((p.PrimaryKekvSum > 0) || (p.PlannedSpendingId != null))) .Select(p => p.PrimaryKekvSum) .ToList(); decimal notPlannedMoneyOnKekv = tc.BalanceChanges .Where(p => (p.EstimateId == spendingRecord.EstimateId) && (p.PrimaryKekvId == spendingRecord.PrimaryKekvId) && ((p.PrimaryKekvSum > 0) || (p.PlannedSpendingId != null))) .Select(p => p.PrimaryKekvSum) .ToList() .DefaultIfEmpty(0) .Sum(); decimal plannedMoneyOnKekv = tc.TenderPlanRecords.ToList() .Where(p => (p.EstimateId == spendingRecord.EstimateId) && (p.PrimaryKekvId == spendingRecord.PrimaryKekvId)) .Select(p => p.UsedByRecordSum) .ToList() .DefaultIfEmpty(0) .Sum(); decimal moneyRemainAtMainKekv = notPlannedMoneyOnKekv - plannedMoneyOnKekv; label6.Text = string.Format("Доступно: {0:N2} грн.", moneyRemainAtMainKekv); if (moneyRemainAtMainKekv > 0) { spendingFullSum.Maximum = spendingRecord.Sum + moneyRemainAtMainKekv; } else { spendingFullSum.Maximum = spendingRecord.Sum; } LoadMoneysTable(); // Заполняем затраты счёта по источникам финансирования if (spendingRecord.Changes.Count > 0) { for (int i = 0; i < sourcesList.Count; i++) { foreach (var rec in spendingRecord.Changes) { if (rec.MoneySourceId == sourcesList[i].Id) { controlValueWasChangedByUser = false; balanceChangesTable.Rows[i].Cells[0].Value = -rec.PrimaryKekvSum; controlValueWasChangedByUser = true; } } } } } }
private void InitializeFormControls(TenderYear year) { InitializeComponent(); button1.Visible = UserSession.IsAuthorized; label6.Text = string.Empty; this.year = year; controlValueWasChangedByUser = false; locker = new object(); kekvRemains = new List <decimal>(); moneysOnSources = new List <decimal>(); relatedFiles = new BindingList <UploadedFile>(); deletingFiles = new BindingList <UploadedFile>(); DataGridViewHelper.ConfigureFileTable(filesTable, relatedFiles, deletingFiles, linkLabel1, linkLabel2, linkLabel3); filesTable.DataSource = relatedFiles; spendingDescription.Text = spendingRecord.Description; spendingFullSum.Value = spendingRecord.Sum; if (spendingRecord.Id == 0) { dateTimePicker1.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddYears(Convert.ToInt32(year.Year) - DateTime.Now.Year); } else { dateTimePicker1.Value = spendingRecord.CreationDate; } dateTimePicker1.MinDate = new DateTime(Convert.ToInt32(year.Year), 1, 1, 0, 0, 0); dateTimePicker1.MaxDate = new DateTime(Convert.ToInt32(year.Year), 12, 31, 0, 0, 0); switch (spendingRecord.Status) { case PaymentStatus.New: newStatusRButton.Checked = true; break; case PaymentStatus.OnPayment: onPayStatusRButton.Checked = true; break; case PaymentStatus.Payed: paidStatusRButton.Checked = true; break; } using (TenderContext tc = new TenderContext()) { sourcesList = tc.MoneySources.OrderBy(p => p.ViewPriority).ToList(); estimateCBList.DataSource = tc.Estimates .Where(t => (t.TenderYearId == year.Id) && (t.Changes.Sum(p => p.PrimaryKekvSum) > 0)) .OrderBy(t => t.Id) .ToList(); Estimate selectedEstimate = estimateCBList.SelectedItem as Estimate; altKekvCBList.DataSource = tc.KekvCodes.OrderBy(p => p.Code).ToList(); } for (int i = 0; i <= sourcesList.Count; i++) { DataGridViewRow newRow = new DataGridViewRow(); newRow.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; newRow.DefaultCellStyle.WrapMode = DataGridViewTriState.True; if (i < sourcesList.Count) { newRow.HeaderCell.Value = sourcesList[i].Name.ToString(); } else { newRow.HeaderCell.Value = "ВСЬОГО"; newRow.DefaultCellStyle.Font = FormStyles.MoneyTotalsFont; newRow.ReadOnly = true; } balanceChangesTable.Rows.Add(newRow); } for (int i = 0; i < balanceChangesTable.ColumnCount; i++) { balanceChangesTable.Columns[i].ValueType = typeof(decimal); balanceChangesTable.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 0; i < (balanceChangesTable.RowCount - 1); i++) { balanceChangesTable.Rows[i].Cells[0].Value = 0; balanceChangesTable.Rows[i].Cells[1].Value = 0; moneysOnSources.Add(0); } controlValueWasChangedByUser = true; }
private void ChooseYear() { selectedYear = listBox1.SelectedItem as TenderYear; this.Close(); }
public CurrentMoneyRemainsAndNewInvoicesReport(TenderYear year) { this.year = year; LoadMoneySourcesList(); }
public InvoiceForm(TenderYear year, Invoice inv) { invoiceRecord = inv; InitializeFormControls(year); if (!UserSession.IsAuthorized) { this.Text = "Перегляд даних рахунку"; } else { this.Text = "Редагування даних рахунку"; } using (TenderContext tc = new TenderContext()) { tc.Invoices.Attach(invoiceRecord); controlValueWasChangedByUser = false; contractsCBList.DataSource = new List <Contract> { invoiceRecord.Contract }; contractorsCBList.DataSource = new List <Contractor> { invoiceRecord.Contract.Contractor }; contractsCBList.Enabled = contractorsCBList.Enabled = false; controlValueWasChangedByUser = true; foreach (var file in invoiceRecord.RelatedFiles) { relatedFiles.Add(file); } decimal moneyRemainAtContract = invoiceRecord.Contract.MoneyRemain; label6.Text = string.Format("Доступно: {0:N2} грн.", moneyRemainAtContract); if (moneyRemainAtContract > 0) { invoiceFullSum.Maximum = invoiceRecord.Sum + moneyRemainAtContract; } else { invoiceFullSum.Maximum = invoiceRecord.Sum; } estimateNameLabel.Text = invoiceRecord.Contract.RecordInPlan.Estimate.Name; LoadMoneyRemains(); // Заполняем затраты счёта по источникам финансирования if (invoiceRecord.Changes.Count > 0) { for (int i = 0; i < sourcesList.Count; i++) { foreach (var rec in invoiceRecord.Changes) { if (rec.MoneySourceId == sourcesList[i].Id) { controlValueWasChangedByUser = false; balanceChangesTable.Rows[i].Cells[0].Value = -rec.PrimaryKekvSum; controlValueWasChangedByUser = true; } } } } } }
public ContractForm(TenderYear year, Contract contractToEdit) { if (!UserSession.IsAuthorized) { this.Text = "Перегляд даних договору"; } else { this.Text = "Редагування даних договору"; } using (TenderContext tc = new TenderContext()) { tc.Contracts.Attach(contractToEdit); currentContract = contractToEdit; InitializeFormControls(year); number.Text = currentContract.Number; fullSum.Value = currentContract.Sum; description.Text = currentContract.Description; dateOfSigning.Value = currentContract.SignDate; dateOfStart.Value = currentContract.BeginDate; dateOfEnd.Value = currentContract.EndDate; tenderPlanRecordPicker1.SelectedRecord = currentContract.RecordInPlan; SetContractMaximumFromTPrecord(currentContract.RecordInPlan); dateOfSigning.MinDate = dateOfStart.MinDate = dateOfEnd.MinDate = new DateTime(Convert.ToInt32(year.Year), 1, 1, 0, 0, 0); dateOfSigning.MaxDate = dateOfStart.MaxDate = dateOfEnd.MaxDate = new DateTime(Convert.ToInt32(year.Year), 12, 31, 0, 0, 0); contractorCBList.SelectedItem = currentContract.Contractor; relatedFiles.Clear(); foreach (var item in currentContract.RelatedFiles) { relatedFiles.Add(item); } contractInvoicesTable.DataSource = new BindingList <Invoice>(currentContract .Invoices.OrderByDescending(t => t.Date).ToList()); contractChangesTable.DataSource = new BindingList <ContractChange>(currentContract .ContractChanges.OrderByDescending(t => t.DateOfChange).ToList()); // Убираем возможность менять смету, кекв и код по дк если есть проплаты по Договору isPossibleToChangeContractMainData = (currentContract.UsedMoney == 0); contractorCBList.Enabled = tenderPlanRecordPicker1.Enabled = isPossibleToChangeContractMainData; fullSum.Minimum = currentContract.UsedMoney; if (currentContract.Invoices.Count > 0) { contractUsedSumLabel.Text = string.Format("Проплачено на загальну суму: {0:N2} грн.", currentContract.UsedMoney); fullSum.Minimum = currentContract.UsedMoney; contractRemainLabel.Text = string.Format("Залишок по договору: {0:N2} грн.", currentContract.MoneyRemain); } else { contractUsedSumLabel.Text = contractRemainLabel.Text = string.Empty; } } for (int i = 0; i < hiddenPagesList.Count; i++) { tabControl1.TabPages.Add(hiddenPagesList[i]); } }
// Создание нового кода в плане public AddEditTPRecordForm(TenderYear year) { this.year = year; InitializeControls(); }
// Открытие кода плана для редактирование public AddEditTPRecordForm(TenderPlanRecord tenderPlanRecord) { if (!UserSession.IsAuthorized) { this.Text = "Перегляд запису у річному плані"; } else { this.Text = "Редагування запису у річному плані"; } using (TenderContext tc = new TenderContext()) { tc.TenderPlanRecords.Attach(tenderPlanRecord); planRecord = tenderPlanRecord; this.year = tenderPlanRecord.Estimate.Year; InitializeControls(); relatedFiles.Clear(); foreach (var item in planRecord.RelatedFiles) { relatedFiles.Add(item); } // Деньги занятые договорами decimal kekvMoneyOnContracts = planRecord.RegisteredContracts.Sum(p => p.Sum); if (kekvMoneyOnContracts > 0) { label6.Visible = true; label6.Text = string.Format("З них зайнято договорами: {0:N2} грн.", kekvMoneyOnContracts); if (!planRecord.BasedOnNeed) { // Отображаем только те КЕКВ на которых средств достаточно для регистрации данной записи primaryKekvList = primaryKekvList.Where(p => (p.Sum >= kekvMoneyOnContracts) || (p.Kekv.Id == planRecord.PrimaryKekvId)).ToList(); controlWasChangedByUser = false; mainKekv.DataSource = primaryKekvList; controlWasChangedByUser = true; } } procedureTypeCBList.SelectedValue = (int)planRecord.ProcedureType; protocolDate.Value = planRecord.ProtocolDate; protocolNum.Text = planRecord.ProtocolNum; tenderBeginDate.Value = planRecord.TenderBeginDate; isCodeRepeatCheckBox.Checked = codeRepeatReasonTextBox.Enabled = (planRecord.CodeRepeatReason != null); codeRepeatReasonTextBox.Text = planRecord.CodeRepeatReason; isProcedureComplete.Checked = planRecord.IsTenderComplete; estimatesCBList.SelectedValue = planRecord.Estimate.Id; mainKekv.SelectedValue = planRecord.PrimaryKekv.Id; altKekv.SelectedValue = planRecord.SecondaryKekv.Id; dkCodesCBList.SelectedValue = planRecord.Dk.Id; conctretePlanItemName.Text = planRecord.ConcreteName; dkCodeSum.Value = planRecord.PlannedSum; basedOnNeed.Checked = planRecord.BasedOnNeed; // Устанавливаем допустимые границы измененния средств на коде dkCodeSum.Minimum = kekvMoneyOnContracts; // Существуют ли проплаты по данной записи в годовом плане bool tenderRecordHasPayments = planRecord.RegisteredContracts.Any(p => p.Invoices.Any(k => k.Status != PaymentStatus.New)); // Смету и КЕКВ нельзя изменить, если существуют проплаты по данной записи estimatesCBList.Enabled = mainKekv.Enabled = altKekv.Enabled = !tenderRecordHasPayments; } }
public EstimateYearSpendingReport(TenderYear year, bool isNewSystem = true) { this.year = year; this.isNewSystem = isNewSystem; LoadMoneySourcesList(); }