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()); } }
public int getTitleIDByDiskID(int did) { eDisk d = new eDisk(); var item = db.tbl_Disks.Where(x => x.DiskID == did).FirstOrDefault(); return(d.TitleID); }
public void updateDisk(eDisk disk) { tbl_Disk temp = db.tbl_Disks.Where(x => x.DiskID == disk.DiskID).FirstOrDefault(); temp.TitleID = disk.TitleID; temp.DiskStatus = disk.DiskStatus; temp.DiskCode = disk.DiskCode; db.SubmitChanges(); }
public eDisk getOneDisk(int did) { eDisk d = new eDisk(); var item = db.tbl_Disks.Where(x => x.DiskID == did).FirstOrDefault(); d.DiskID = item.DiskID; d.TitleID = Convert.ToInt32(item.TitleID); d.DiskStatus = item.DiskStatus; d.DiskCode = item.DiskCode; return(d); }
public void insertDisk(eDisk disk) { tbl_Disk temp = new tbl_Disk(); temp.TitleID = disk.TitleID; temp.DiskStatus = disk.DiskStatus; temp.DiskCode = disk.DiskCode; db.tbl_Disks.InsertOnSubmit(temp); db.SubmitChanges(); }
private void btnAdd_Click(object sender, EventArgs e) { eDisk disk = new eDisk(); disk.TitleID = Convert.ToInt32(txtTitleID.Text); disk.DiskStatus = txtDiskStatus.Text; disk.DiskCode = txtDiskCode.Text; diskbll.insertDisk(disk); LoadDataGridView(); }
private void btnUpdate_Click(object sender, EventArgs e) { eDisk temp = new eDisk(); temp.DiskID = Convert.ToInt32(lblDiskID.Text); temp.TitleID = Convert.ToInt32(txtTitleID.Text); temp.DiskStatus = txtDiskStatus.Text; temp.DiskCode = txtDiskCode.Text; diskbll.updateDisk(temp); LoadDataGridView(); }
public List <eDisk> getAllDisl() { List <eDisk> ls = new List <eDisk>(); foreach (tbl_Disk item in db.tbl_Disks.ToList()) { eDisk disk = new eDisk(); disk.DiskID = item.DiskID; disk.TitleID = Convert.ToInt32(item.TitleID); disk.DiskStatus = item.DiskStatus; disk.DiskCode = item.DiskCode; ls.Add(disk); } return(ls); }
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); }
public List <eDisk> getDiskByTitleID(int titleid) { List <eDisk> ls = new List <eDisk>(); var lsdisk = db.tbl_Disks.Where(x => x.TitleID == titleid).ToList(); foreach (tbl_Disk item in lsdisk) { eDisk disk = new eDisk(); disk.DiskID = item.DiskID; disk.TitleID = Convert.ToInt32(item.TitleID); disk.DiskStatus = item.DiskStatus; disk.DiskCode = disk.DiskCode; ls.Add(disk); } return(ls); }
//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(); } }