private void txtSoTo_ValueChanged(object sender, EventArgs e) { try { int idSanPhamCha = (int)cbbLoaiSanPham.SelectedValue; String size = cbbSize.Text; String loaiBia = cbbLoaiBia.Text; String loaiGiay = cbbLoaiGiay.Text; DataTable dt = SanPhamDao.getChiTietSanPham(idSanPhamCha, size, loaiBia, loaiGiay); if (dt.Rows.Count == 1) { DataRow row = dt.Rows[0]; int numPageDefault = int.Parse(row["NUM_PAGE_DEFAULT"].ToString()); double donGiaDefault = double.Parse(row["DON_GIA"].ToString()); int soTo = (int)txtSoTo.Value; double costPageAdd = double.Parse(row["ADDITIONAL_PAGES_COST"].ToString()); double donGia = AppUtils.cashProduct(numPageDefault, donGiaDefault, soTo, costPageAdd); txtDonGia.Text = donGia.ToString(); txtThanhTien.Text = (donGia * (double)txtSoLuong.Value).ToString(); } } catch (Exception ex) { //MessageBox.Show(ex.Message, "ERROR"); } }
private void updateDataChanged() { try { if (this.initData == false) { return; } txtSoTo.Value = 10; txtDonGia.Text = ""; txtSoLuong.Value = txtSoLuong.Minimum; txtChietKhau.Value = txtChietKhau.Minimum; txtThanhTien.Text = ""; int idSanPhamCha = (int)cbbLoaiSanPham.SelectedValue; String size = cbbSize.Text; String loaiBia = cbbLoaiBia.Text; String loaiGiay = cbbLoaiGiay.Text; DataTable dt = SanPhamDao.getChiTietSanPham(idSanPhamCha, size, loaiBia, loaiGiay); if (dt.Rows.Count == 1) { DataRow row = dt.Rows[0]; int numPageDefault = int.Parse(row["NUM_PAGE_DEFAULT"].ToString()); double donGiaDefault = double.Parse(row["DON_GIA"].ToString()); int soTo = (int)txtSoTo.Value; double costPageAdd = double.Parse(row["ADDITIONAL_PAGES_COST"].ToString()); double donGia = AppUtils.cashProduct(numPageDefault, donGiaDefault, soTo, costPageAdd); txtDonGia.Text = donGia.ToString(); txtThanhTien.Text = (donGia * (double)txtSoLuong.Value).ToString("#,###"); } } catch (Exception) { } }