示例#1
0
        private void FillPictureBox(int resourrceID, PictureBox pic)
        {
            ResourceBL resourceBL = new ResourceBL();

            Resource resource = resourceBL.GetRessourceDetails(resourrceID);

            if (!string.IsNullOrEmpty(resource.ImagePath))
            {
                pic.ImageLocation = resource.ImagePath;
            }
        }
示例#2
0
        private void PopulateDgvRessource(int parameter)
        {
            ResourceBL ressourceBL = new ResourceBL();

            //ressourceBL.GetRessourceDetails(id: parameter);

            List <Resource> ressources = new List <Resource>()
            {
                ressourceBL.GetRessourceDetails(id: parameter)
            };

            dgvRessourceToBorrow.DataSource = ressources;
            dgvRessourceToBorrow.Columns["DateRemoved"].Visible = false;
            dgvRessourceToBorrow.Columns["Price"].Visible       = false;
            dgvRessourceToBorrow.Columns["ImagePath"].Visible   = false;
        }
示例#3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvRessourceToBorrow.DataSource != null)
                {
                    ResourceBL        ressourceBL = new ResourceBL();
                    LoanBL            loanBL      = new LoanBL();
                    StudentLoanInfoBL loanInfoBL  = new StudentLoanInfoBL();

                    int      ressourceID = Convert.ToInt32(txtRessourceID.Text);
                    Resource ressource   = ressourceBL.GetRessourceDetails(ressourceID);

                    Loan loan = PopulateLoanObject(ressource, txtStudentID.Text);

                    //loanBL._loans = (List<Loan>)dgvLoans.DataSource;

                    List <StudentLoanInfo> studentLoanInfos = (List <StudentLoanInfo>)dgvLoans.DataSource;

                    foreach (StudentLoanInfo stli in studentLoanInfos)
                    {
                        Loan studentLoan = loanBL.GetLoanByID(stli.LoanID);

                        loanBL._loans.Add(studentLoan);
                    }



                    if (loanBL.AddLoan(loan))
                    {
                        string msg = string.Empty;
                        if (ressourceBL.ModifyRessource(ressource, txtStudentID.Text))
                        {
                            msg = "\nRessource status set to \"On Loan\"";
                        }

                        PopulateDgvRessource(ressource.ID);
                        PopulateStudentLoans(txtStudentID.Text, loanInfoBL);

                        txtRessourceID.ResetText();
                        dgvRessourceToBorrow.DataSource = null;

                        MessageBox.Show("Resource succesfuly added to the student Loans." + msg);
                    }
                    else
                    {
                        string msg = string.Empty;

                        foreach (ValidationError error in loanBL.Errors)
                        {
                            msg += error.Description + "\n";
                        }



                        if (msg != string.Empty)
                        {
                            dgvRessourceToBorrow.DataSource = null;
                            txtRessourceID.ResetText();
                            txtRessourceID.Focus();

                            MessageBox.Show(msg);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().ToString(), ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }