Example #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());
            }
        }
Example #2
0
        public void updateStatusDiskRental(eDiskRental e, int st)
        {
            var item = db.tbl_DiskRentals.Where(x => x.RentalID == e.RentalID && x.DiskID == e.DiskID).FirstOrDefault();

            item.RentalID   = e.RentalID;
            item.DiskID     = e.DiskID;
            item.Status     = st;
            item.ReturnDate = e.ReturnDate;

            db.SubmitChanges();
        }
Example #3
0
        public void insertDiskRental(eDiskRental e)
        {
            tbl_DiskRental temp = new tbl_DiskRental();

            temp.RentalID   = e.RentalID;
            temp.DiskID     = e.DiskID;
            temp.Status     = e.Status;
            temp.ReturnDate = e.ReturnDate;

            db.tbl_DiskRentals.InsertOnSubmit(temp);
            db.SubmitChanges();
        }
Example #4
0
        //0 chua tra, 1 tra roi
        public eDiskRental getDiskNoRentalByDiskID(int did)
        {
            eDiskRental e = new eDiskRental();
            var         d = db.tbl_DiskRentals.Where(x => x.DiskID == did && x.Status == 0).FirstOrDefault();

            e.RentalID   = d.RentalID;
            e.DiskID     = d.DiskID;
            e.Status     = Convert.ToInt32(d.Status);
            e.ReturnDate = Convert.ToDateTime(d.ReturnDate);

            return(e);
        }
Example #5
0
        public List <eDiskRental> getAllDiskRentalByRentalID(int rentalid)
        {
            List <eDiskRental> ls = new List <eDiskRental>();
            var lsdrental         = db.tbl_DiskRentals.Where(x => x.RentalID == rentalid).ToList();

            foreach (tbl_DiskRental item in lsdrental)
            {
                eDiskRental temp = new eDiskRental();
                temp.RentalID = item.RentalID;
                temp.DiskID   = item.DiskID;
                temp.Status   = Convert.ToInt32(item.Status);

                ls.Add(temp);
            }
            return(ls);
        }
Example #6
0
        private void btnreturn_Click(object sender, EventArgs e)
        {
            //rtbll = new ReturnDiskBLL();
            //eReturn ert = new eReturn();
            //ert.CustomerID = Convert.ToInt32(txtcustomerid.Text);
            //ert.DiskID = Convert.ToInt32(cmbDiskID.Text);
            //ert.ReturnDate = Convert.ToDateTime(dtreturn.Text);

            //int temp = rtbll.ReturnDisk(ert);
            //if (temp >= 0 )
            //    MessageBox.Show("Trễ", "Noti", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            //else
            //{
            //    MessageBox.Show("Trả đĩa thành công!", "Noti!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);


            //}


            //0 la chua tra, 1 la tra roi
            eDiskRental dr = new eDiskRental();

            //MessageBox.Show(cmbDiskID.Text);
            dr = drbll.getDiskNoRentalByDiskID(Convert.ToInt32(cmbDiskID.Text));
            //MessageBox.Show(dr.RentalID.ToString());
            drbll.updateStatusDiskRental(dr, 1);

            eRental er = new eRental();

            er = rbll.getOneRental(dr.RentalID);
            TimeSpan ts = new TimeSpan();

            ts = dr.ReturnDate - er.RentalDate;

            eDisk di = new eDisk();

            di = dbll.getOneDisk(dr.DiskID);

            eLateCharge lc = new eLateCharge();

            MessageBox.Show(er.CustomerID.ToString());
            MessageBox.Show(di.DiskID.ToString());
            lc = lcbll.getOneLateCharge(er.CustomerID, di.DiskID);
            MessageBox.Show(lc.LateChargeID.ToString());
            //lcbll.addLateCharge(lc);
        }
Example #7
0
        public List <eDiskRental> getDisRentalByStatus(int st)
        {
            List <eDiskRental> ls = new List <eDiskRental>();
            var list = db.tbl_DiskRentals.Where(x => x.Status == st).ToList();

            foreach (tbl_DiskRental item in list)
            {
                eDiskRental e = new eDiskRental();
                e.RentalID   = item.RentalID;
                e.DiskID     = item.DiskID;
                e.Status     = Convert.ToInt32(item.Status);
                e.ReturnDate = Convert.ToDateTime(item.ReturnDate);

                ls.Add(e);
            }
            return(ls);
        }
Example #8
0
        public List <eDiskRental> getAllDiskRental()
        {
            List <eDiskRental> ls = new List <eDiskRental>();

            foreach (tbl_DiskRental item in db.tbl_DiskRentals.ToList())
            {
                eDiskRental temp = new eDiskRental();
                temp.RentalID = item.RentalID;
                temp.DiskID   = item.DiskID;
                temp.Status   = Convert.ToInt32(item.Status);



                ls.Add(temp);
            }

            return(ls);
        }
Example #9
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();
            }
        }