public frmBaoCaoBarcode(Barcode[] code, string hanhdong, Boolean xemIn) { //In mã vạch hàng hóa InitializeComponent(); Code = code; HanhDong = hanhdong; XemIn = xemIn; }
/// <summary> /// GetTheVip /// </summary> /// <param name="barCode"></param> /// <param name="thongTinCongTy"></param> /// <returns></returns> public MaVachThe[] GetTheVip(Barcode[] barCode, ThongTinCongTy thongTinCongTy) { List<MaVachThe> retVal; try { retVal = new List<MaVachThe>(); cl = new Server_Client.Client(); // gán TCPclient client = cl.Connect(Luu.IP, Luu.Ports); // khởi tạo biến truyền vào với hàm khởi tạo //Entities.TheVip kh = new Entities.TheVip("Select", txtmkh.Text); clientstrem = cl.SerializeObj(client, "LayTheVip", null); // đổ mảng đối tượng vào datagripview TheVip[] theVip = (TheVip[])cl.DeserializeHepper1(clientstrem, null); // foreach (Barcode code in barCode) { foreach (TheVip item in theVip) { if (!code.MaHangHoa.Trim().ToUpper().Equals(item.MaThe.Trim().ToUpper())) continue; MaVachThe maVachThe = new MaVachThe { TenCongTy = thongTinCongTy.TenCongTy + "\r\n" + thongTinCongTy.DiaChi, TenThe = "Thẻ Vip", MaKH = item.MaKhachHang, TenKH = code.TenHangHoa, NgayBatDau = new DateTime().ToShortDateString(), NgayKetThuc = new DateTime().ToShortDateString(), MaVach = code.MaVach, MaThe = item.MaThe, GiaTriThe = double.Parse(item.GiaTriThe) }; retVal.Add(maVachThe); break; } } } catch (Exception) { retVal = null; } return retVal.ToArray(); }
/// <summary> /// Lay hang hoa trong datagridview /// </summary> /// <param name="view"></param> /// <param name="thongTinCongTy"> </param> /// <returns></returns> private Barcode[] GetProduct(DataGridView view, ThongTinCongTy thongTinCongTy) { List<Barcode> hangHoaList = new List<Barcode>(); try { int count = 0; if (view != null) count = view.Rows.Count; for (int i = 0; i < count; i++) { if (view == null) continue; string maHangHoa = view["maHangHoa", i].Value.ToString(); string tenHangHoa = view["TenHangHoa", i].Value.ToString(); string dongiastr = view["GiaBanLe", i].Value.ToString(); double dongia = double.Parse(string.IsNullOrEmpty(dongiastr) ? "0" : dongiastr); int soLuong = 0; if (view["GhiChu", i].Value != null) soLuong = int.Parse(view["GhiChu", i].Value.ToString()); for (int j = 0; j < soLuong; j++) { Barcode item = new Barcode { TenSieuThi = thongTinCongTy.TenCongTy, TenHangHoa = rdoVisibleName.Checked ? tenHangHoa : string.Empty, MaHangHoa = maHangHoa, MaVach = ConvertToByte(CreateImg(maHangHoa)), DonGia = rdoVisibleName.Checked ? -1 : dongia }; hangHoaList.Add(item); } } } catch { return new List<Barcode>().ToArray(); } return hangHoaList.ToArray(); }
/// <summary> /// GetTheGT /// </summary> /// <param name="barCode"></param> /// <param name="congTy"></param> /// <returns></returns> public MaVachThe[] GetTheGt(Barcode[] barCode, ThongTinCongTy congTy) { List<MaVachThe> retVal = null; try { retVal = new List<MaVachThe>(); cl = new Server_Client.Client(); // gán TCPclient client = cl.Connect(Luu.IP, Luu.Ports); // khởi tạo biến truyền vào với hàm khởi tạo TheGiamGia pt = new TheGiamGia { HanhDong = "Select" }; clientstrem = cl.SerializeObj(client, "TheGiamGia", pt); TheGiamGia[] tggArr = new TheGiamGia[1]; // đổ mảng đối tượng vào datagripview tggArr = (TheGiamGia[])cl.DeserializeHepper1(clientstrem, tggArr); // foreach (Barcode code in barCode) { foreach (TheGiamGia item in tggArr) { if (code.MaHangHoa.Trim().ToUpper().Equals(item.MaTheGiamGia.Trim().ToUpper())) { MaVachThe mavach = new MaVachThe { TenCongTy = congTy.TenCongTy + "\r\n" + congTy.DiaChi, TenThe = "Thẻ Giá Trị", MaKH = item.MaKhachHang, TenKH = code.TenHangHoa, NgayBatDau = item.NgayBatDau.ToShortDateString(), NgayKetThuc = item.NgayKetThuc.ToShortDateString(), MaVach = code.MaVach, MaThe = item.MaTheGiamGia, GiaTriThe = double.Parse(item.GiaTriThe) }; retVal.Add(mavach); break; } } } } catch (Exception) { retVal = null; } return retVal.ToArray(); }