public SachKMView GetSachKMView(DataRow i) { SachKMView sachKMView = new SachKMView(); sachKMView.MaSach = Convert.ToInt32(i["MaSach"]); sachKMView.TenSach = i["TenSach"].ToString(); sachKMView.GiaBia = Convert.ToInt32(i["GiaBia"]); sachKMView.MucGiamGia = Convert.ToDouble(i["MucGiamGia"]); sachKMView.GiaSauKM = sachKMView.GiaBia * (1 - sachKMView.MucGiamGia / 100); return(sachKMView); }
//Lấy ra sách có id trùng (cả có trong danh sách khuyến mãi lẫn chưa) public SachKMView GetSachKMViewByID_All_BLL(int id) { SachKMView sachKMView = new SachKMView(); foreach (SachKMView i in DAL_SachKhuyenMai.Instance.getListSachKMView_All_DAL()) { if (i.MaSach == id) { sachKMView = i; } } return(sachKMView); }
private void btnEdit_Click(object sender, EventArgs e) { if (dataGridView2.SelectedRows.Count > 0) { int id = Convert.ToInt32(dataGridView2.SelectedRows[0].Cells["MaSach"].Value); SachKMView sachKMView = BLL_SachKhuyenMai.Instance.GetSachKMViewByID_BLL(id); txtIDBook.Text = sachKMView.MaSach.ToString(); txtIDBook.Enabled = false; txtBookTitle.Text = sachKMView.TenSach.ToString(); txtPrice.Text = string.Format("{0:#,##0.00}", sachKMView.GiaBia); txtPriceAfter.Text = sachKMView.GiaSauKM.ToString(); txtDiscount.Text = sachKMView.MucGiamGia.ToString(); } }
private void txtIDBook_TextChanged(object sender, EventArgs e) { try { if (txtIDBook.Text != "") { SachKMView sachKMView = BLL_SachKhuyenMai.Instance.GetSachKMViewByID_All_BLL(Convert.ToInt32(txtIDBook.Text)); // SachKMView sachKMView = BLL_SachKhuyenMai.Instance.GetSachKMViewByID_BLL(Convert.ToInt32(txtIDBook.Text)); txtBookTitle.Text = sachKMView.TenSach; txtPrice.Text = string.Format("{0:#,##0.00}", sachKMView.GiaBia); } else { ResetGUI(); } } catch (Exception) { } }