private void bteSanPham_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) { return; } var frmLookUp = new frmLookUp_SanPham(true, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUp.ShowDialog() != DialogResult.OK) { return; } foreach (var dmSanPhamInfo in frmLookUp.SelectedItems) { liSanPham.Add(new ItemInMaVachInfor { IdSanPham = dmSanPhamInfo.IdSanPham, MaSanPham = dmSanPhamInfo.MaSanPham, TenSanPham = dmSanPhamInfo.TenSanPham, LoaiSanPham = dmSanPhamInfo.TenLoaiSP, SoLuong = 1, Nganh = dmSanPhamInfo.Nganh, TrungMaVach = dmSanPhamInfo.TrungMaVach }); } gSanPham.RefreshDataSource(); this.groupBox4.Text = "Danh sách sản phẩm (" + liSanPham.Count + " sản phẩm)"; }
public void TestLookUpSanPham_1() { frmLookUp_SanPham frm = new frmLookUp_SanPham(); frm.ShowDialog(); MessageBox.Show(frm.SelectedItem.Nganh); }
private void bteSanPham_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { var frmLookUp = new frmLookUp_SanPham(true, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUp.ShowDialog() != DialogResult.OK) { return; } foreach (var dmSanPhamInfo in frmLookUp.SelectedItems) { liSanPham.Add(new ItemInMaVachInfor { IdSanPham = dmSanPhamInfo.IdSanPham, MaSanPham = dmSanPhamInfo.MaSanPham, TenSanPham = dmSanPhamInfo.TenSanPham, LoaiSanPham = dmSanPhamInfo.TenLoaiSP, SoLuong = 1, Nganh = dmSanPhamInfo.Nganh, TrungMaVach = dmSanPhamInfo.TrungMaVach }); } gSanPham.RefreshDataSource(); this.groupBox4.Text = "Danh sách sản phẩm (" + liSanPham.Count + " sản phẩm)"; }
public void TestLookUpSanPham() { frmLookUp_SanPham frm = new frmLookUp_SanPham(true, "%%"); frm.ShowDialog(); Assert.AreEqual(1, frm.SelectedItems.Count); }
public void ChonSP() { frmLookUp_SanPham frm = new frmLookUp_SanPham(); if (frm.ShowDialog() == DialogResult.OK) { View.IdSanPham = frm.SelectedItem.IdSanPham; } }
private void bteSanpham_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { frmLookUp_SanPham frmLookUp = new frmLookUp_SanPham(String.Format("%{0}%", bteSanpham.Text)); if (frmLookUp.ShowDialog() == DialogResult.OK) { bteSanpham.Tag = frmLookUp.SelectedItem; } }
private void btnThemSP_Click(object sender, EventArgs e) { frmLookUp_SanPham frm = new frmLookUp_SanPham(((DMKhoInfo)bteKhoDi.Tag).IdKho, 0, true, true); if (frm.ShowDialog() == DialogResult.OK)//nếu kết quả trả về là form LookUp { PickUpSanPhamInfo(frm.SelectedItem); } }
private void btnThemSP_Click(object sender, EventArgs e) { frmLookUp_SanPham frm = new frmLookUp_SanPham(); if (frm.ShowDialog() == DialogResult.OK)//nếu kết quả trả về là form LookUp { PickUpSanPhamInfo(frm.SelectedItem); } }
private void bteSanPham_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham(); if (frmLookUpSanPham.ShowDialog() == DialogResult.OK) { bteSanPham.Text = frmLookUpSanPham.SelectedItem.MaSanPham; idSanPham = frmLookUpSanPham.SelectedItem.IdSanPham; } }
private void bteSanpham_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { frmLookUp_SanPham frmLookUp = new frmLookUp_SanPham(String.Format("%{0}%", bteSanpham.Text)); if (frmLookUp.ShowDialog() == DialogResult.OK) { bteSanpham.Tag = frmLookUp.SelectedItem; } } }
public void SaoChep() { try { frmLookUp_SanPham frm = new frmLookUp_SanPham("%%"); if (frm.ShowDialog() == DialogResult.OK) { DMSanPhamInfo dmSanPhamInfo = frm.SelectedItem; if (DmCauHinhSanPhamDAO.Instance.DaCoCauHinh(View.IdSanPham)) { if ( MessageBox.Show("Sản phẩm này đã có cấu hình bạn có muốn ghi đè không ?", "Xác Nhận ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } else if ( MessageBox.Show("Bạn chắc chắn sẽ sao chép cấu hình cho sản phẩm ?", dmSanPhamInfo.MaSanPham, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } try { ConnectionUtil.Instance.BeginTransaction(); DmCauHinhSanPhamDAO.Instance.Delete(dmSanPhamInfo.IdSanPham); List <DMCauHinhSanPhamInfo> list = new List <DMCauHinhSanPhamInfo>(); for (int i = 0; i < list.Count; i++) { DMCauHinhSanPhamInfo info = list[i]; DmCauHinhSanPhamDAO.Instance.Update(info.IdSanPham, info.TenCauHinh, info.GiaTri, info.SoTT); ConnectionUtil.Instance.CommitTransaction(); } } catch (Exception) { { ConnectionUtil.Instance.RollbackTransaction(); throw; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnThemSP_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(bteTrungTam.Text) || string.IsNullOrEmpty(bteKho.Text)) { clsUtils.MsgCanhBao("Bạn chưa chọn trung tâm/kho!"); return; } frmLookUp_SanPham frm = new frmLookUp_SanPham(((DMKhoInfo)bteKho.Tag).IdKho, 0, true, true); if (frm.ShowDialog() == DialogResult.OK)//nếu kết quả trả về là form LookUp { PickUpSanPhamInfo(frm.SelectedItem); } }
private void bteSanPham_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { frmLookUp_SanPham frmLookUp = new frmLookUp_SanPham(true, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUp.ShowDialog() == DialogResult.OK) { bteSanPham.EditValue = String.Empty; bteSanPham.Tag = frmLookUp.SelectedItems; foreach (DMSanPhamInfo selectedItem in frmLookUp.SelectedItems) { bteSanPham.EditValue += selectedItem.MaSanPham + ","; } } }
private void bteSanPham_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { frmLookUp_SanPham frmLookUp = new frmLookUp_SanPham(true, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUp.ShowDialog() == DialogResult.OK) { bteSanPham.Tag = frmLookUp.SelectedItems; foreach (DMSanPhamInfo selectedItem in frmLookUp.SelectedItems) { bteSanPham.EditValue += selectedItem.MaSanPham + ","; } } } }
private void bteSanPham_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham(true, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUpSanPham.ShowDialog() == DialogResult.OK) { int maxDisplay = 3; bteSanPham.Text = ","; if (frmLookUpSanPham.SelectedItems.Count < maxDisplay) { foreach (DMSanPhamInfo dmSanPhamInfo in frmLookUpSanPham.SelectedItems) { bteSanPham.Text += dmSanPhamInfo.MaSanPham + ","; } } else { foreach (DMSanPhamInfo dmSanPhamInfo in frmLookUpSanPham.SelectedItems) { if (maxDisplay < 0) { break; } bteSanPham.Text += dmSanPhamInfo.MaSanPham + ","; maxDisplay -= 1; } bteSanPham.Text += "..."; } bteSanPham.Tag = frmLookUpSanPham.SelectedItems; } }
//protected void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo) //{ // likhong[dgvSanPhamKhong.Rows.IndexOf(dgvSanPhamKhong.CurrentRow)].MaSanPham = sanPhamInfo.MaSanPham; // likhong[dgvSanPhamKhong.Rows.IndexOf(dgvSanPhamKhong.CurrentRow)].TenSanPham = sanPhamInfo.TenSanPham; // likhong[dgvSanPhamKhong.Rows.IndexOf(dgvSanPhamKhong.CurrentRow)].TrungMaVach = sanPhamInfo.TrungMaVach; // likhong[dgvSanPhamKhong.Rows.IndexOf(dgvSanPhamKhong.CurrentRow)].IdSanPham = sanPhamInfo.IdSanPham; // if (dgvSanPhamKhong.DataSource == null) // dgvSanPhamKhong.DataSource = new BindingList<KiemKeChiTietKhongMaVachInfor>(likhong); // else // { // ((BindingList<KiemKeChiTietKhongMaVachInfor>)dgvSanPhamKhong.DataSource).ResetBindings(); // } //} // private bool isKeyPressed; //void Control_KeyPress(object sender, KeyPressEventArgs e) //{ // isKeyPressed = true; //} //void Control_TextChanged(object sender, EventArgs e) //{ // try // { // if (ColumnMaSanPham == null) return; // if (!isKeyPressed || dgvSanPhamKhong.CurrentCell.ColumnIndex != dgvSanPhamKhong.Columns.IndexOf(ColumnMaSanPham) || // ((TextBox)sender).Text == String.Empty || ((TextBox)sender).Text == (string)dgvSanPhamKhong.CurrentCell.Value) return; // frmLookUp_SanPham frm = new frmLookUp_SanPham(String.Format("%{0}%", ((TextBox)sender).Text)); // if (frm.ShowDialog() == DialogResult.OK) // { // isKeyPressed = false; // PickUpSanPhamInfo(frm.SelectedItem); // } // } // catch (Exception ex) // { // EventLogProvider.Instance.WriteLog(ex.ToString(), "frmLookUp_SanPham"); // } //} //private void dgvSanPhamKhong_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) //{ // if (ColumnMaSanPham == null) return; // if (dgvSanPhamKhong.CurrentCell != null && dgvSanPhamKhong.CurrentCell.ColumnIndex == dgvSanPhamKhong.Columns.IndexOf(ColumnMaSanPham)) // { // e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress); // e.Control.TextChanged += new EventHandler(Control_TextChanged); // } //} //protected DataGridViewTextBoxColumn ColumnMaSanPham //{ // get // { // return clMaSanPhamKhong; // } //} private void Them() { if (trangThai == 1) { throw new ManagedException("Phiếu này đã được xác nhận!"); } if (txtMaVach.Text == "") { throw new ManagedException("Mã vạch không được để trống !"); } if (bteDotKiemKe.Tag == null) { throw new ManagedException("Bạn chưa chọn đợt kiểm kê!"); } txtMaVach.Text = txtMaVach.Text.Trim(); List <DMSanPhamInfoEx> listsp = KiemKeDataProvider.Instance. GetLookUpSanPhamTrungMV(txtMaVach.Text, MaTrungTam, MaKho, MaNganh, ((DotKiemKeInfor)bteDotKiemKe.Tag).IdDotKiemKe); List <ChungTu_ChiTietHangHoaKiemKeInfor> frm = KiemKeDataProvider.Instance.GetIdSanPhamByMaVach(txtMaVach.Text, MaTrungTam, MaKho, MaNganh, ((DotKiemKeInfor)bteDotKiemKe.Tag).IdDotKiemKe); if (frm != null && frm.Count != 0) { for (int i = 0; i < frm.Count; i++) { HangHoa.IdChiTietHangHoa = frm[i].IdChiTietHangHoa; HangHoa.IdSanPham = frm[i].IdSanPham; HangHoa.MaSanPham = frm[i].MaSanPham; HangHoa.TenSanPham = frm[i].TenSanPham; HangHoa.SoLuongSS = frm[i].SoLuong; HangHoa.GhiChu = frm[i].GhiChu; HangHoa.TrungMaVach = frm[i].TrungMaVach; HangHoa.IdKho = frm[i].IdKho; HangHoa.MaKho = frm[i].MaKho; //HangHoa.DonViTinh = frm[0].TenDonViTinh;} } } if (frm != null && frm.Count == 0 || !chkAutoRegSub.Checked || //&& HangHoa.TrungMaVach == 1 || KiemKeDataProvider.Instance.CheckMaVach(MaKho, HangHoa.IdSanPham, txtMaVach.Text.Trim(), MaNganh, MaTrungTam, ((DotKiemKeInfor)bteDotKiemKe.Tag).IdDotKiemKe) == false) { if (MessageBox.Show( !chkAutoRegSub.Checked && HangHoa.TrungMaVach == 1 ? "Bạn có chắc chắn là serial thừa không?" : "Mã vạch hiện không tìm thấy.\nBạn có muốn thêm mã vạch này không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { KiemKeChiTietKhongMaVachInfor matchInfo = new KiemKeChiTietKhongMaVachInfor(); DMTrungTamInfor trungTamInfor = DMTrungTamDataProvider.GetTrungTamByMa(((DotKiemKeInfor)bteDotKiemKe.Tag).TrungTam); frmLookUp_Kho frmLookUpKho = new frmLookUp_Kho(false, String.Format("%{0}%", ((DotKiemKeInfor)bteDotKiemKe.Tag).TrungTam), trungTamInfor.IdTrungTam, -1); if (frmLookUpKho.ShowDialog() == DialogResult.OK) { matchInfo.IdKho = frmLookUpKho.SelectedItem.IdKho; matchInfo.MaKho = frmLookUpKho.SelectedItem.MaKho; } else { return; } frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham("%%"); if (frmLookUpSanPham.ShowDialog() == DialogResult.OK) { matchInfo.IdSanPham = frmLookUpSanPham.SelectedItem.IdSanPham; matchInfo.MaSanPham = frmLookUpSanPham.SelectedItem.MaSanPham; matchInfo.TenSanPham = frmLookUpSanPham.SelectedItem.TenSanPham; } else { return; } foreach (KiemKeChiTietKhongMaVachInfor pt in liKhong) { if (pt.MaVach.ToLower() == txtMaVach.Text.Trim().ToLower() && pt.IdKho == matchInfo.IdKho && pt.IdSanPham == matchInfo.IdSanPham) { pt.SoLuong = pt.SoLuong + 1; ((BindingList <KiemKeChiTietKhongMaVachInfor>)grvDanhSachKhong.DataSource).ResetBindings(); txtMaVach.Clear(); grvDanhSachKhong.TopRowIndex = liKhong.IndexOf(pt); grvDanhSachKhong.ClearSelection(); grvDanhSachKhong.FocusedRowHandle = liKhong.IndexOf(pt); return; } } liKhong.Add(new KiemKeChiTietKhongMaVachInfor() { MaVach = txtMaVach.Text.Trim(), SoLuong = 1, IdSanPham = matchInfo.IdSanPham, MaSanPham = matchInfo.MaSanPham, TenSanPham = matchInfo.TenSanPham, IdKho = matchInfo.IdKho, MaKho = matchInfo.MaKho }); ((BindingList <KiemKeChiTietKhongMaVachInfor>)grvDanhSachKhong.DataSource).ResetBindings(); txtMaVach.Clear(); grvDanhSachKhong.TopRowIndex = liKhong.Count - 1; grvDanhSachKhong.ClearSelection(); grvDanhSachKhong.FocusedRowHandle = liKhong.Count - 1; } txtMaVach.Clear(); } else { if (listsp.Count < 2) { foreach (KiemKeChiTietHangHoaInfor pt in liCo) { if (pt.MaVach.ToLower() == txtMaVach.Text.Trim().ToLower() && pt.TrungMaVach == 1 && pt.MaKho == HangHoa.MaKho && pt.MaSanPham == HangHoa.MaSanPham) { pt.SoLuong = pt.SoLuong + 1; pt.SoLuongSs = pt.SoLuongSs; ((BindingList <KiemKeChiTietHangHoaInfor>)grvDanhSachCo.DataSource).ResetBindings(); txtTenSanPham.Text = HangHoa.TenSanPham; txtMaVach.Clear(); grvDanhSachCo.TopRowIndex = liCo.IndexOf(pt); grvDanhSachCo.ClearSelection(); grvDanhSachCo.FocusedRowHandle = liCo.IndexOf(pt); return; } if (pt.MaVach.ToLower() == txtMaVach.Text.Trim().ToLower() && pt.TrungMaVach == 0) { throw new ManagedException("Mã vạch không được trùng nhau!"); } } liCo.Add(new KiemKeChiTietHangHoaInfor { MaVach = txtMaVach.Text.Trim(), SoLuong = 1, TenDonViTinh = HangHoa.DonViTinh, IdSanPham = HangHoa.IdSanPham, IdChiTietHangHoa = HangHoa.IdChiTietHangHoa, TenSanPham = HangHoa.TenSanPham, MaSanPham = HangHoa.MaSanPham, SoLuongSs = HangHoa.SoLuongSS, GhiChu = HangHoa.GhiChu, TrungMaVach = HangHoa.TrungMaVach, IdKho = HangHoa.IdKho, MaKho = HangHoa.MaKho }); ((BindingList <KiemKeChiTietHangHoaInfor>)grvDanhSachCo.DataSource).ResetBindings(); txtTenSanPham.Text = HangHoa.TenSanPham; txtMaVach.Clear(); grvDanhSachCo.TopRowIndex = liCo.Count - 1; grvDanhSachCo.ClearSelection(); grvDanhSachCo.FocusedRowHandle = liCo.Count - 1; } else { frmLookup_SanPhamTrungMaVach frmsp = new frmLookup_SanPhamTrungMaVach(txtMaVach.Text, MaKho, MaTrungTam, MaNganh, ((DotKiemKeInfor)bteDotKiemKe.Tag).IdDotKiemKe); if (frmsp.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int idsanpham = frmsp.item.IdSanPham; ChungTu_ChiTietHangHoaKiemKeInfor obj = KiemKeDataProvider.Instance. GetSanPhamById_MaVach(idsanpham, txtMaVach.Text, MaTrungTam, frmsp.item.MaKho, MaNganh, ((DotKiemKeInfor)bteDotKiemKe.Tag).IdDotKiemKe); foreach (KiemKeChiTietHangHoaInfor pt in liCo) { if (pt.MaVach.ToLower() == txtMaVach.Text.Trim().ToLower() && pt.TrungMaVach == 1 && pt.MaKho == obj.MaKho && pt.MaSanPham == obj.MaSanPham) { pt.SoLuong = pt.SoLuong + 1; pt.SoLuongSs = pt.SoLuongSs; ((BindingList <KiemKeChiTietHangHoaInfor>)grvDanhSachCo.DataSource).ResetBindings(); txtTenSanPham.Text = HangHoa.TenSanPham; txtMaVach.Clear(); grvDanhSachCo.TopRowIndex = liCo.IndexOf(pt); grvDanhSachCo.ClearSelection(); grvDanhSachCo.FocusedRowHandle = liCo.IndexOf(pt); return; } if (pt.MaVach.ToLower() == txtMaVach.Text.Trim().ToLower() && pt.TrungMaVach == 0 && pt.MaKho == obj.MaKho && pt.MaSanPham == obj.MaSanPham) { throw new ManagedException("Mã vạch không được trùng nhau!"); } } liCo.Add(new KiemKeChiTietHangHoaInfor { MaVach = txtMaVach.Text.Trim(), SoLuong = 1, TenDonViTinh = obj.TenDonViTinh, IdSanPham = obj.IdSanPham, IdChiTietHangHoa = obj.IdChiTietHangHoa, TenSanPham = obj.TenSanPham, MaSanPham = obj.MaSanPham, //SoLuongSs = obj.SoLuongSS, GhiChu = obj.GhiChu, TrungMaVach = obj.TrungMaVach, IdKho = obj.IdKho, MaKho = obj.MaKho }); ((BindingList <KiemKeChiTietHangHoaInfor>)grvDanhSachCo.DataSource).ResetBindings(); txtTenSanPham.Text = obj.TenSanPham; txtMaVach.Clear(); grvDanhSachCo.TopRowIndex = liCo.Count - 1; grvDanhSachCo.ClearSelection(); grvDanhSachCo.FocusedRowHandle = liCo.Count - 1; } } } }
void Control_TextChanged(object sender, EventArgs e) { try { frmLookUp_SanPham frm; if (ColumnMaSanPham == null) { return; } if (!isKeyPressed || dgvChiTiet.CurrentCell.ColumnIndex != dgvChiTiet.Columns.IndexOf(ColumnMaSanPham) || ((TextBox)sender).Text == String.Empty || ((TextBox)sender).Text == (string)dgvChiTiet.CurrentCell.Value) { return; } if (this.Business == null) { this.Business = GetBussiness(); } if (Business.BusinessType == BusinessType.VIRTUAL_OUT || Business.BusinessType == BusinessType.REAL_OUT) { frm = new frmLookUp_SanPham(GetIdKho(), 0, true, Business.BusinessType == BusinessType.VIRTUAL_OUT, String.Format("%{0}%", ((TextBox)sender).Text)); } else { frm = new frmLookUp_SanPham(String.Format("%{0}%", ((TextBox)sender).Text)); } dgvChiTiet.CurrentCell.Value = null; if (frm.ShowDialog() == DialogResult.OK) { isKeyPressed = false; PickUpSanPhamInfo(frm.SelectedItem); } else { ((TextBox)sender).Text = String.Empty; } } catch (ManagedException ex) { #if DEBUG MessageBox.Show(ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #else MessageBox.Show(ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #endif } catch (Exception ex) { #if DEBUG MessageBox.Show(ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #else MessageBox.Show(ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error); #endif EventLogProvider.Instance.WriteLog(ex.ToString() + "\nUser: "******"\nKho: " + Declare.IdKho, this.Name); } }