Exemple #1
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            if (checkDataInput() == true)
            {
                eDiskRental dr = new eDiskRental();

                //MessageBox.Show(cmbDiskID.Text);
                dr = drbll.getDiskNoRentalByDiskID(Convert.ToInt32(cmbDiskID.Text));

                eRental r = new eRental();
                r = rbll.getOneRental(dr.RentalID);

                eCustomer c = new eCustomer();
                c = cbll.getOneCustomer(r.CustomerID);

                eDisk ed = new eDisk();
                ed = dbll.getOneDisk(dr.DiskID);

                eTitle et = new eTitle();
                et = tbll.getOneTitle(ed.TitleID);

                eLateCharge elc = new eLateCharge();
                elc = lcbll.getOneLateCharge(c.CustomerID, ed.DiskID);

                lblCustomerName.Text = c.CustomerName;
                lblCusTomerID.Text   = c.CustomerID.ToString();
                lblAddress.Text      = c.Address;
                lblPhoneNumber.Text  = c.PhoneNumber;
                lblRentalDate.Text   = r.RentalDate.ToString();
                lblTitleID.Text      = et.TitleName;
                lblLateCharge.Text   = elc.LateCharge.ToString();
                //MessageBox.Show(r.CustomerID.ToString());
            }
        }
Exemple #2
0
        //public bool checkInput()
        //{
        //    foreach(eDiskRental item in diskrentalbll.getAllDiskRentalByRentalID(Convert.ToInt32(rentalid)))
        //    {
        //        if (item.DiskID== Convert.ToInt32(cmbDiskID.Text))
        //        {
        //            MessageBox.Show("Dia nay da duoc thue, ban hay chon dia khac");
        //            cmbDiskID.Clear();
        //            cmbDiskID.Focus();
        //            return false;
        //        }
        //    }
        //    return true;
        //}

        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkDataInput() == true)
                {
                    eDiskRental d = new eDiskRental();
                    label1.Text  = rentalid.ToString();
                    d.RentalID   = Convert.ToInt32(label1.Text);
                    d.DiskID     = Convert.ToInt32(cmbDiskID.Text);
                    d.Status     = 0;
                    d.ReturnDate = Convert.ToDateTime(DateTime.Now.ToString());
                    diskrentalbll.insertDiskRental(d);
                    //diskrentalbll.ins(rental);

                    // MessageBox.Show(DateTime.Now.ToString());

                    LoadDataGridView1(dgvDiskRental, diskrentalbll.getAllDiskRentalByRentalID(Convert.ToInt32(label1.Text)));

                    //int tid = diskrentalbll.getTitleIDByDiskID(Convert.ToInt32(cmbDiskID.Text));
                    //decimal chargedisk = diskrentalbll.getRentalCharge(tid);
                    //decimal sumrental = Convert.ToDecimal(txtSumRentCharge.Text) + chargedisk;
                    //int tid = dbll.getTitleIDByDiskID(Convert.ToInt32(cmbDiskID.Text));

                    eDisk ed = new eDisk();
                    ed = dbll.getOneDisk(Convert.ToInt32(cmbDiskID.Text));

                    eTitle titletemp = tbll.getOneTitle(Convert.ToInt32(ed.TitleID));
                    //MessageBox.Show(titletemp.RentalCharge.ToString());
                    decimal chargedisk = tbll.getRentalCharge(Convert.ToInt32(titletemp.RentalCharge));
                    decimal sumrental  = Convert.ToDecimal(txtSumRentCharge.Text) + titletemp.RentalCharge;
                    txtSumRentCharge.Text = sumrental.ToString();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("ma dia nay khong ton tai tronghe thong, vui long chon lai");
                cmbDiskID.Text = "";
                cmbDiskID.Focus();
            }
        }