private void btnCapNhat_Click(object sender, EventArgs e) { try { InfoReportDetails ob = lst.Find(o => o.ID == ID); if (ob != null) { ob.MaSP = txtMaSP.Text; ob.TenHang = txtTenSanPham.Text; ob.MoTaHangHoa = txtMoTa.Text; // ob.ThanhTien = decimal.Parse(txtThanhTien.EditValue.ToString()); ob.ChietKhau = decimal.Parse(txtTienChietKhau.EditValue.ToString()); ob.DonGia = decimal.Parse(txtDonGia.EditValue.ToString()); ob.SoLuong = int.Parse(txtSoLuong.EditValue.ToString()); ob.Profit = decimal.Parse(txtProfit.EditValue.ToString()); ob.IsGroup = _IsGroup; ob.Status = 1; // ob.MoneyProfit = decimal.Parse(txtTienLoiNhuan.EditValue.ToString()); } if (lst.Exists(o => o.Status == 0)) { dgv_BaoGia.OptionsView.EnableAppearanceOddRow = false; } else { dgv_BaoGia.OptionsView.EnableAppearanceOddRow = true; } dgv_BaoGia.RefreshData(); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "btnCapNhat_Click", ex.ToString())); } }
private void btnAdd_Click(object sender, EventArgs e) { try { InfoReportDetails ob = new InfoReportDetails(); ob.MaSP = txtMaSP.Text; if (ob.MaSP == "") { XtraMessageBox.Show("Vui lòng chọn sản phẩm", "Thông Báo"); return; } if (lst == null) { lst = new List <InfoReportDetails>(); } ob.ID = (lst.Count + 1).ToString(); ID = (lst.Count + 1).ToString(); ob.TenHang = txtTenSanPham.Text; ob.DonGia = decimal.Parse(txtDonGia.EditValue.ToString()); ob.SoLuong = int.Parse(txtSoLuong.EditValue.ToString()); ob.IsGroup = _IsGroup; ob.ChietKhau = decimal.Parse(txtTienChietKhau.EditValue.ToString()); ob.Profit = decimal.Parse(txtProfit.EditValue.ToString()); ob.CostPrice = CostPrice; ob.Status = 1; ProfitValue = ob.Profit; ob.MoTaHangHoa = txtMoTa.Text; lst.Add(ob); if (lst.Exists(o => o.Status == 0)) { dgv_BaoGia.OptionsView.EnableAppearanceOddRow = false; } else { dgv_BaoGia.OptionsView.EnableAppearanceOddRow = true; } dgc_BaoGia.DataSource = lst; dgv_BaoGia.RefreshData(); dgv_BaoGia.BestFitColumns(true); ShowInfo_Commission(); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "btnAdd_Click", ex.ToString())); } }
private void dgv_BaoGia_RowClick(object sender, RowClickEventArgs e) { try { int focus = dgv_BaoGia.FocusedRowHandle; if (focus >= 0) { InfoReportDetails ob = (InfoReportDetails)dgv_BaoGia.GetFocusedRow(); if (ob != null) { // thiết lập lại profit: flag_edit = true; decimal PTChietKhau, tienChietKhauMax, tyle = 100; PTChietKhau = ob.DonGia == 0 ? 0 : (ob.ChietKhau * tyle) / ob.DonGia; ProfitValue = Math.Round(ob.Profit / HeSoBienDoi + PTChietKhau, 2); CostPrice = ob.CostPrice; tienChietKhauMax = (ProfitValue * ob.DonGia) / tyle; txtProfit.Properties.MinValue = 0; txtProfit.EditValue = ob.Profit; txtPTChietKhau.Properties.MaxValue = ProfitValue; ProfitValue_MAX = ProfitValue; txtPTChietKhau.Properties.MinValue = -100; txtTienChietKhau.Properties.MaxValue = tienChietKhauMax; txtTienChietKhau.Properties.MinValue = -ob.DonGia; txtDonGiaNew.Properties.MinValue = ob.DonGia - tienChietKhauMax; txtDonGiaNew.Properties.MaxValue = ob.DonGia * 2; txtPTChietKhau.EditValue = PTChietKhau; txtTienChietKhau.EditValue = ob.ChietKhau; txtDonGiaNew.EditValue = ob.DonGia - ob.ChietKhau; _IsGroup = ob.IsGroup; ID = ob.ID; txtMaSP.Text = ob.MaSP; txtTenSanPham.Text = ob.TenHang; txtMoTa.Text = ob.MoTaHangHoa; txtDonGia.EditValue = ob.DonGia; txtSoLuong.EditValue = ob.SoLuong; flag_edit = false; } } } catch (Exception ex) { ID = "0"; API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "dgv_BaoGia_RowClick", ex.ToString())); } }
private void xóaSảnPhẩmToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = XtraMessageBox.Show("Bạn Có muốn Xóa Những Sản Phẩm Này Không?", "Thông Báo", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } // Create an empty list. try { List <InfoReportDetails> lstdel = new List <InfoReportDetails>(); // Add the selected rows to the list. for (int i = 0; i < dgv_BaoGia.SelectedRowsCount; i++) { InfoReportDetails ob = (InfoReportDetails)dgv_BaoGia.GetRow(dgv_BaoGia.GetSelectedRows()[i]); lstdel.Add(ob); } if (dgv_BaoGia.SelectedRowsCount == 0) { XtraMessageBox.Show("Không có thông tin nào được chọn để xóa! Vui lòng chọn dữ liệu để thao tác", "Thông Tin"); return; } else { foreach (InfoReportDetails item in lstdel) { lst.Remove(item); } dgv_BaoGia.RefreshData(); } ShowInfo_Commission(); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "xóaSảnPhẩmToolStripMenuItem_Click", ex.ToString())); } }