コード例 #1
0
 private void FillListBox()
 {
     ContaContext contaContext = new ContaContext();
     UnitOfWork unitOfWork = new UnitOfWork(contaContext);
     var data = unitOfWork.TipLucrare.GetAll();
     foreach (var item in data)
     {
         ListViewItem lvItem = new ListViewItem(item.TipLucrareId.ToString());
         lvItem.SubItems.Add(item.CodLucrare.ToString());
         lvItem.SubItems.Add(item.Tip_Lucrare);
         listViewTipLucrare.Items.Add(lvItem);
     }
 }
コード例 #2
0
ファイル: ucContracte.cs プロジェクト: cosmintaran/CosminRepo
        private void gridViewContract_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow selectedRow = null;
            foreach (DataGridViewRow iterator in gridViewContract.SelectedRows)
            {
                selectedRow = iterator;
            }

            var selRow = selectedRow?.Cells["ContractId"].Value;
            if (selRow == null) return;

            ContaContext contaContext = new ContaContext();
            UnitOfWork unitOfWork = new UnitOfWork(contaContext);

            _contract = unitOfWork.Contracte.Get((int) selRow);
            unitOfWork.Dispose();
            contaContext.Dispose();

            if (_contract == null) return;
            // Completeaza formul cu datele din baza de date
            txtNrContr.Text = _contract.NrContract;
            txtSuma.Text = _contract.Suma.ToString(CultureInfo.InstalledUICulture);
            txtObiect.Text = _contract.ObiectulContractului;
            txtObs.Text = _contract.Observatii;
            dateTimePickerContr.Value = _contract.Data;

            //Set enable disabe or visibilty for controls
            bttNewContract.Enabled = false;
            bttDeleteContract.Enabled = false;
            grBoxContract.Enabled = true;
            bttEdit.Visible = true;
            bttCancel.Visible = true;
            bttSave.Visible = false;
            bttClear.Visible = false;
        }
コード例 #3
0
ファイル: ucContracte.cs プロジェクト: cosmintaran/CosminRepo
        private void FillGridView(FilterCriteria criteria, string key)
        {
            try
            {
                ContaContext conta = new ContaContext();
                UnitOfWork unityOfWork = new UnitOfWork(conta);

                BindingSource bindingSource;

                #region Switch
                switch (criteria)
                {
                    case FilterCriteria.An:

                        try
                        {
                            int year = int.Parse(key);
                            bindingSource = new BindingSource
                            {
                                DataSource = unityOfWork.Contracte.GetGridViewContractByYear(year)
                            };
                        }
                        catch (Exception)
                        {
                            return;
                        }
                        break;

                    case FilterCriteria.NrContract:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContractByNumber(key) };
                        break;

                    case FilterCriteria.Suma:
                        try
                        {
                            decimal value = decimal.Parse(key);
                            bindingSource = new BindingSource{ DataSource = unityOfWork.Contracte.GetContractByAmount(value) };
                        }
                        catch (Exception)
                        {
                            return;
                        }

                        break;

                    case FilterCriteria.NumeBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContractByBeneficiar(key) };
                        break;

                    default:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Contracte.GetContracts() };
                        break;
                }
                #endregion Switch

                // ReSharper disable once ConstantConditionalAccessQualifier
                if (bindingSource?.DataSource == null) return;
                gridViewContract.DataSource = bindingSource;
                if (gridViewContract.Columns["ContractId"] == null)
                {
                    gridViewContract.Rows.Clear();
                    gridViewContract.Refresh();
                    var dataGridViewColumn = gridViewContract.Columns["Current"];
                    if (dataGridViewColumn != null) dataGridViewColumn.Visible = false;
                }
                else
                {
                    var dataGridViewColumn = gridViewContract.Columns["ContractId"];
                    dataGridViewColumn.Visible = false;
                    gridViewContract.Columns[1].MinimumWidth = 100;
                    gridViewContract.Columns[2].MinimumWidth = 150;
                    gridViewContract.Columns[3].MinimumWidth = 300;
                    gridViewContract.Columns[4].MinimumWidth = 120;
                    gridViewContract.Columns[5].MinimumWidth = 500;
                    gridViewContract.Columns[6].MinimumWidth = 350;
                }
            }
            catch (InvalidOperationException ex) { MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
コード例 #4
0
ファイル: ucContracte.cs プロジェクト: cosmintaran/CosminRepo
 private void bttSave_Click(object sender, EventArgs e)
 {
     PrepareObject();
     ContaContext contaContext = new ContaContext();
     UnitOfWork unityOfWork = new UnitOfWork(contaContext);
     IList<Contract> checkIfIsExist = (IList<Contract>)unityOfWork.Contracte.GetContractByNumberAndYear(_contract.NrContract, DateTime.Today);
     if (checkIfIsExist == null || checkIfIsExist.Count > 0)
     {
         MessageBox.Show(@"Contractul cu numarul " + _contract.NrContract + @" exista deja.",
             @"Eroare la salvare", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtNrContr.Text = "";
         return;
     }
     if (_contract.BeneficiarId <= 0)
     {
         MessageBox.Show(@"Contractul nu poate fi salvat fara Beneficiar.\nVa rugam selectati unul sau creati unul nou ",
              @"Eroare la salvare", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     unityOfWork.Contracte.Add(_contract);
     unityOfWork.Complete();
     unityOfWork.Dispose();
     contaContext.Dispose();
     grBoxContract.Enabled = false;
     bttNewContract.Enabled = true;
     FillGridView(_filter, DateTime.Today.Year.ToString());
     OnUpdateLucrariCombo();
 }
コード例 #5
0
ファイル: ucContracte.cs プロジェクト: cosmintaran/CosminRepo
        private void bttEdit_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren(ValidationConstraints.Enabled)) return;

            PrepareObject();
            ContaContext contaContext = new ContaContext();
            UnitOfWork unitOfWork = new UnitOfWork(contaContext);
            unitOfWork.Contracte.UpdateEntry(_contract);
            unitOfWork.Complete();
            unitOfWork.Dispose();

            FillGridView(_filter, DateTime.Today.Year.ToString());

            ClearFormContract();

            bttClear.Visible = true;
            bttClear.Enabled = true;
            bttSave.Visible = true;
            bttSave.Enabled = true;
            bttEdit.Visible = false;
            bttCancel.Visible = false;
            bttNewContract.Enabled = true;
            bttDeleteContract.Enabled = false;
            grBoxContract.Enabled = false;
        }
コード例 #6
0
ファイル: ucContracte.cs プロジェクト: cosmintaran/CosminRepo
        private void bttDeleteContract_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow = null;
            foreach (DataGridViewRow iterator in gridViewContract.SelectedRows)
            {
                selectedRow = iterator;
            }

            var selRow = selectedRow?.Cells["ContractId"].Value;

            if (selRow == null) return;
            ContaContext contaContext = new ContaContext();
            UnitOfWork unityOfWork = new UnitOfWork(contaContext);

            Contract contract = unityOfWork.Contracte.Get((int) selRow);
            if (contract == null) return;
            var userConfirm =
                MessageBox.Show(
                    @"Confirmati stergerea din baza de date a contractului cu nr. " + contract.NrContract + @"/" +
                    contract.Data, @"Delete confirmation",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (userConfirm == DialogResult.Yes)
            {
                try
                {
                    unityOfWork.Contracte.Remove(contract);
                    unityOfWork.Complete();
                    unityOfWork.Dispose();
                    contaContext.Dispose();
                    bttDeleteContract.Enabled = false;
                    FillGridView(_filter, DateTime.Now.Year.ToString());
                    ClearFormContract();
                }
                catch (DbUpdateException)
                {
                    // ReSharper disable once LocalizableElement
                    MessageBox.Show("Contractul este folosit de o alta intrare din baza de date.\nStergere refuzata", @"Eroare stergere contract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch(Exception ex) { MessageBox.Show(ex.Message, @"Eroare stergere contract", MessageBoxButtons.OK, MessageBoxIcon.Error); }

            }
            else
            {
                bttDeleteContract.Enabled = false;
                unityOfWork.Dispose();
                contaContext.Dispose();
            }
        }
コード例 #7
0
 private void Save()
 {
     ContaContext contaContext = new ContaContext();
     UnitOfWork unitOfWork = new UnitOfWork(contaContext);
     unitOfWork.Beneficiari.Add(_beneficiar);
     unitOfWork.Complete();
     unitOfWork.Dispose();
 }
コード例 #8
0
 private void UpDate()
 {
     ContaContext contaContext = new ContaContext();
     UnitOfWork unitOfWork = new UnitOfWork(contaContext);
     unitOfWork.Beneficiari.UpdateEntry(_beneficiar);
     unitOfWork.Complete();
     unitOfWork.Dispose();
 }
コード例 #9
0
        private void FillComboBox()
        {
            ContaContext contaContext = new ContaContext();
            UnitOfWork unitOfWork = new UnitOfWork(contaContext);

            BindingSource bindTipAct = new BindingSource {DataSource = unitOfWork.TipActe.GetAll()};
            unitOfWork.Dispose();
            contaContext.Dispose();
            cbTipAct.DataSource = bindTipAct;
            cbTipAct.DisplayMember = "TipAct1";
            cbAtribFiscal.Items.Add("");
            cbAtribFiscal.Items.Add("RO");
        }
コード例 #10
0
 private void GetBeneficiariForDb()
 {
     ContaContext contaContext = new ContaContext();
     UnitOfWork unitOfWork = new UnitOfWork(contaContext);
     _mlBeneficiari =(List<Beneficiar>) unitOfWork.Beneficiari.GetAll();
     unitOfWork.Dispose();
     contaContext.Dispose();
     _names = new AutoCompleteStringCollection();
     foreach (var str in _mlBeneficiari)
         _names.Add(str.Nume);
 }
コード例 #11
0
ファイル: ucLucrari.cs プロジェクト: cosmintaran/CosminRepo
        private void bttDeleteLucrari_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow = null;
            foreach (DataGridViewRow iterator in LucrariView.SelectedRows)
            {
                selectedRow = iterator;
            }

            var dataGridViewCell = selectedRow?.Cells["LucrareId"].Value;
            if (dataGridViewCell == null) return;
            //var id = dataGridViewCell;
            ContaContext contaContext = new ContaContext();
            UnitOfWork unityOfWork = new UnitOfWork(contaContext);
            Lucrare lucrare = unityOfWork.Lucrari.Get((int)dataGridViewCell);
            var userConfirm = MessageBox.Show(@"Confirmati stergerea din baza de date a documentatiei cu nr. " + lucrare.NrProiect + @"/" +
                lucrare.AnProiect, @"Delete confirmation",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (userConfirm == DialogResult.Yes)
            {
                try
                {
                    unityOfWork.Lucrari.Remove(lucrare);
                    unityOfWork.Complete();
                    unityOfWork.Dispose();
                    contaContext.Dispose();
                    bttDeleteLucrari.Enabled = false;
                    FillGridView(_filter, DateTime.Now.Year.ToString());
                }
                catch (DbUpdateException)
                {
                    // ReSharper disable once LocalizableElement
                    MessageBox.Show("Documentatie este folosit de o alta intrare din baza de date.\nStergere refuzata", @"Eroare stergere contract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message, @"Eroare stergere contract", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            }
            else
            {
                bttDeleteLucrari.Enabled = false;
                unityOfWork.Dispose();
                contaContext.Dispose();
            }
        }
コード例 #12
0
ファイル: ucLucrari.cs プロジェクト: cosmintaran/CosminRepo
        private void LucrariView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row = null;
            foreach (DataGridViewRow iterator in LucrariView.SelectedRows)
            {
                row = iterator;
            }

            if (row == null) return;
            var conta = new ContaContext();
            var unitOfWork = new UnitOfWork(conta);

            // ReSharper disable once ConstantConditionalAccessQualifier
            var id = row?.Cells["LucrareId"].Value;
            if (id == null) return;
            _lucrare = unitOfWork.Lucrari.Get((int)id);

            if (_lucrare == null) return;

            int sStatusAccept = unitOfWork.AcceptateRespinse.Get(_lucrare.AcceptataRefuzataId).AcceptataRefuzataId;
            if (--sStatusAccept >= 0)
                cbAcceptResp.SelectedIndex = sStatusAccept;

            int sStatusRec = unitOfWork.ReceptionateRespinse.Get(_lucrare.ReceptionatRespinsId).ReceptionatRespinsId;
            if(--sStatusRec >= 0)
                cbReceptionatRespins.SelectedIndex = sStatusRec;

            if (_lucrare.ContractId != null)
                cbContract.SelectedText = unitOfWork.Contracte.Get((int)_lucrare.ContractId).NrContract;

            if (_lucrare.DataInregistrare != null)
                dateTimePickerInreg.Value = (DateTime)_lucrare.DataInregistrare;

            if (_lucrare.TermenSolutionare != null)
                dateTimePickerTermen.Value = (DateTime)_lucrare.TermenSolutionare;

            unitOfWork.Dispose();
            conta.Dispose();

            txtInreg.Text = _lucrare.Nr_OCPI;
            txtDoc.Text = _lucrare.NrProiect;
            txtAvizator.Text = _lucrare.AvizatorRegistrator;
            txtUAT.Text = _lucrare.UAT;
            txtObservatii.Text = _lucrare.Observatii;
            txtCad.Text = _lucrare.CadTop;

            //Set enable disabe or visibilty for controls
            bttNewLucrare.Enabled = false;
            bttDeleteLucrari.Enabled = false;
            grBoxLucrare.Enabled = true;
            bttEdit.Visible = true;
            bttCancel.Visible = true;
            bttSave.Visible = false;
            bttClearlucrare.Visible = false;
        }
コード例 #13
0
ファイル: ucLucrari.cs プロジェクト: cosmintaran/CosminRepo
        private void FillGridView(FilterCriteria criteria, string key)
        {
            try
            {
                ContaContext conta = new ContaContext();
                UnitOfWork unityOfWork = new UnitOfWork(conta);

                BindingSource bindingSource;

                #region Switch
                switch (criteria)
                {
                    case FilterCriteria.An:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByYear(key) };
                        break;
                    case FilterCriteria.CnpBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByBeneficiarName(key) };
                        break;
                    case FilterCriteria.NrContract:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrareByContract(key) };
                        break;
                    case FilterCriteria.NrDoc:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByNrDocumentatie(key) };
                        break;
                    case FilterCriteria.NumeBeneficiar:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByBeneficiarName(key) };
                        break;

                    case FilterCriteria.TipDoc:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByCodLucrare(key) };
                        break;
                    case FilterCriteria.Uat:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByUat(key) };
                        break;
                    case FilterCriteria.Receptionata:
                    case FilterCriteria.Respinsa:
                    case FilterCriteria.InLucru:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrariByStatusOcpi(key) };
                        break;

                    default:
                        bindingSource = new BindingSource { DataSource = unityOfWork.Lucrari.GetLucrari() };
                        break;
                }
                #endregion Switch

                // ReSharper disable once ConstantConditionalAccessQualifier
                if (bindingSource?.DataSource == null) return;
                LucrariView.DataSource = bindingSource;
                if (LucrariView.Columns["LucrareId"] == null)
                {
                    LucrariView.Rows.Clear();
                    LucrariView.Refresh();
                    var dataGridViewColumn = LucrariView.Columns["Current"];
                    if (dataGridViewColumn != null) dataGridViewColumn.Visible = false;
                }
                else
                {
                    var dataGridViewColumn = LucrariView.Columns["LucrareId"];
                    dataGridViewColumn.Visible = false;
                }
            }
            catch (InvalidOperationException ex) { MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
コード例 #14
0
ファイル: ucLucrari.cs プロジェクト: cosmintaran/CosminRepo
        private void FillCombobox()
        {
            try
            {
                var bindAcceptrefuz = new BindingSource();
                var bindRecResp = new BindingSource();
                //var bindContract = new BindingSource();

                var contaContext = new ContaContext();
                var unitOfWork = new UnitOfWork(contaContext);

                //Acceptata/Respinsa
                bindAcceptrefuz.DataSource = unitOfWork.AcceptateRespinse.GetAll();
                cbAcceptResp.DataSource = bindAcceptrefuz;
                cbAcceptResp.DisplayMember = "StatusAccept";

                //Receptionat/Respins
                bindRecResp.DataSource = unitOfWork.ReceptionateRespinse.GetAll();
                cbReceptionatRespins.DataSource = bindRecResp;
                cbReceptionatRespins.DisplayMember = "StatusRec";

                //Numar contract
               /* bindContract.DataSource = unitOfWork.Contracte.GetContractByYear(DateTime.Today.Year);
                bindContract.Add(new Contract { NrContract = "<new...>" });
                cbContract.DataSource = bindContract;
                cbContract.DisplayMember = "NrContract";*/
                var listOfContracts = unitOfWork.Contracte.GetContractByYear(DateTime.Today.Year);
                if(cbContract.Items.Count > 0)
                    cbContract.Items.Clear();
                cbContract.Items.Add(new Contract { NrContract = "<new...>" });
                foreach (var item in listOfContracts)
                {
                    cbContract.Items.Add(item);
                }

                cbContract.DisplayMember = "NrContract";
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, @"Error initializing fields", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
コード例 #15
0
ファイル: ucLucrari.cs プロジェクト: cosmintaran/CosminRepo
        private void bttSave_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren(ValidationConstraints.Enabled)) return;

            PrepareObject();
            var con = new ContaContext();
            var unitOfWork = new UnitOfWork(con);

            IList<Lucrare> checkIfIsExist = (IList<Lucrare>)unitOfWork.Lucrari.GetLucrariByNumberAndYear(_lucrare.NrProiect, DateTime.Today);
            if (checkIfIsExist == null || checkIfIsExist.Count > 0)
            {
                MessageBox.Show(@"Documentatia cu numarul " + _lucrare.NrProiect +@"/" +_lucrare.AnProiect+ @" exista deja.",
                    @"Eroare la salvare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDoc.Text = "";
                return;
            }

            unitOfWork.Lucrari.Add(_lucrare);
            unitOfWork.Complete();
            unitOfWork.Dispose();
            FillGridView(_filter, _filterKeyWordS);

            ClearFormLucrare();
            if (!bttNewLucrare.Enabled)
                bttNewLucrare.Enabled = true;
            // Disable grupbox Lucrari
            if (grBoxLucrare.Enabled)
                grBoxLucrare.Enabled = false;
        }