Ejemplo n.º 1
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);
        }
Ejemplo n.º 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();
            }
        }