/// <summary> /// kiem tra trang loai don dat hang theo ma don hang /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.TruyenGiaTri KiemTraDonDatHang(Entities.TruyenGiaTri giatri) { Entities.TruyenGiaTri ve = null; try { SqlDataReader read = null; Sql = new Constants.Sql(); string sql = "exec sp_KiemTraDonDatHang @HanhDong,@MaDonDatHang"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("HanhDong", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; cmd.Parameters.Add("MaDonDatHang", SqlDbType.VarChar, 20).Value = giatri.Giatrithuhai; read = cmd.ExecuteReader(); while (read.Read()) { ve = new Entities.TruyenGiaTri(); ve.Giatritruyen = read[0].ToString(); ve.Giatrithuhai = read[1].ToString(); } read.Close(); } catch (Exception ex) { string s = ex.Message.ToString(); ve = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(ve); }
/// <summary> /// lay bang cong ty /// </summary> /// <param name="ct"></param> /// <returns></returns> public Entities.ThongTinCongTy sp_ThongTinCongTy(Entities.TruyenGiaTri ct) { Entities.ThongTinCongTy banghi = new Entities.ThongTinCongTy(); try { string sql = "exec sp_ThongTinCongTy @MaCongTy"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaCongTy", SqlDbType.VarChar, 20).Value = ct.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); ArrayList arr = new ArrayList(); while (dr.Read()) { banghi.MaCongTy = dr[0].ToString(); banghi.TenCongTy = dr[1].ToString(); banghi.DiaChi = dr[2].ToString(); banghi.SoDienThoai = dr[3].ToString(); banghi.Email = dr[4].ToString(); banghi.Website = dr[5].ToString(); banghi.Fax = dr[6].ToString(); } } catch (Exception ex) { string s = ex.Message.ToString(); banghi = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(banghi); }
/// <summary> /// lay ban ghi cuoi cung /// </summary> public Entities.KiemKeKho sp_LayBang_TheoTenBang(Entities.TruyenGiaTri chuyen) { Entities.KiemKeKho giatri = new Entities.KiemKeKho(); try { string sql = "exec sp_LayBang_TheoTenBang @table,@values"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("table", SqlDbType.NVarChar, 100).Value = chuyen.Giatritruyen; cmd.Parameters.Add("values", SqlDbType.NVarChar, 50).Value = chuyen.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { giatri.PhieuKiemKeKhoID = int.Parse(dr[0].ToString()); giatri.MaKiemKe = dr[1].ToString(); giatri.NgayKiemKe = DateTime.Parse(dr[2].ToString()); giatri.MaKho = dr[3].ToString(); giatri.GhiChu = dr[4].ToString(); giatri.Deleted = Boolean.Parse(dr[5].ToString()); } } catch (Exception ex) { string s = ex.Message.ToString(); giatri = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(giatri); }
/// <summary> /// /// </summary> /// <param name="giatri"></param> /// <returns></returns> public int CapNhatDuNoNhaCungCap(Entities.TruyenGiaTri giatri) { int tra = 0; try { Sql = new Constants.Sql(); string sql = "exec sp_CapNhatDuNoNhaCungCap @MaNhaCungCap,@DuNo"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhaCungCap", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; cmd.Parameters.Add("DuNo", SqlDbType.Float).Value = giatri.Giatrithuhai; tra = cmd.ExecuteNonQuery(); } catch (Exception ex) { string s = ex.Message.ToString(); tra = 0; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(tra); }
/// <summary> /// /// </summary> /// <param name="kiemtra"></param> /// <returns></returns> public Entities.HienThiBaoCao[] KiemTraNhomHangHoa(Entities.HienThiBaoCao[] kiemtra) { Entities.HienThiBaoCao[] tra = null; try { ArrayList arr = new ArrayList(); for (int i = 0; i < kiemtra.Length; i++) { Entities.TruyenGiaTri giatri = new TruyenGiaTri("", kiemtra[i].Ma); Entities.ThongTinHangHoa[] data = Select(giatri); if (data.Length > 0) { arr.Add(kiemtra[i]); } else { continue; } } int n = arr.Count; if (n == 0) { tra = null; } tra = new Entities.HienThiBaoCao[n]; for (int i = 0; i < n; i++) { tra[i] = (Entities.HienThiBaoCao)arr[i]; } } catch (Exception ex) { string s = ex.Message; tra = null; } return tra; }
/// <summary> /// lay bang cong ty /// </summary> /// <param name="ct"></param> /// <returns></returns> public Entities.ThongTinCongTy sp_ThongTinCongTy(TruyenGiaTri ct) { Entities.ThongTinCongTy banghi = new Entities.ThongTinCongTy(); try { string sql = "exec sp_ThongTinCongTy @MaCongTy"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaCongTy", SqlDbType.VarChar, 20).Value = ct.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); ArrayList arr = new ArrayList(); while (dr.Read()) { banghi.MaCongTy = dr[0].ToString(); banghi.TenCongTy = dr[1].ToString(); banghi.DiaChi = dr[2].ToString(); banghi.SoDienThoai = dr[3].ToString(); banghi.Email = dr[4].ToString(); banghi.Website = dr[5].ToString(); banghi.Fax = dr[6].ToString(); } } catch (Exception ex) { string s = ex.Message.ToString(); banghi = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return banghi; }
/// <summary> /// /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.BaoCaoKhachHangTraLaiTheoKy[] Select(Entities.TruyenGiaTri giatri) { Entities.BaoCaoKhachHangTraLaiTheoKy[] arrC = null; try { string sql = "exec sp_BaoCaoKhachHangTraLaiTheoKy @TuNgay,@DenNgay"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("TuNgay", SqlDbType.VarChar, 10).Value = giatri.Giatritruyen; cmd.Parameters.Add("DenNgay", SqlDbType.VarChar, 10).Value = giatri.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.BaoCaoKhachHangTraLaiTheoKy tao = new Entities.BaoCaoKhachHangTraLaiTheoKy(); tao.MaKhachHangTraLai = dr[0].ToString(); tao.NgayNhap = DateTime.Parse(dr[1].ToString()); tao.MaKhachHang = dr[2].ToString(); tao.MaHoaDonMuaHang = dr[3].ToString(); tao.MaKho = dr[4].ToString(); tao.MaHangHoa = dr[5].ToString(); tao.TenHangHoa = dr[6].ToString(); tao.GiaBanBuon = dr[7].ToString(); tao.GiaBanLe = dr[8].ToString(); tao.SoLuong = dr[9].ToString(); tao.PhanTramChietKhau = dr[10].ToString(); tao.TienBoiThuong = dr[11].ToString(); tao.ThueGTGT = dr[12].ToString(); tao.ThanhToanNgay = dr[13].ToString(); tao.Thue = dr[14].ToString(); arr.Add(tao); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.BaoCaoKhachHangTraLaiTheoKy[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BaoCaoKhachHangTraLaiTheoKy)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinDatHang[] sp_KiemKeHangHoa(Entities.TruyenGiaTri giatri) { Entities.ThongTinDatHang[] list = null; try { dh = new Constants.ThongTinDatHang(); Sql = new Constants.Sql(); string sql = "exec sp_KiemKeHangHoa @MaKho"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { dondathang = new Entities.ThongTinDatHang(); dondathang.HanhDong = string.Empty; dondathang.MaHangHoa = dr["MaHangHoa"].ToString(); dondathang.TenHangHoa = dr["TenHangHoa"].ToString(); dondathang.GiaNhap = dr["GiaNhap"].ToString(); dondathang.Tonkho = dr["SoLuong"].ToString(); dondathang.Giabanbuon = dr["GiaBanBuon"].ToString(); dondathang.Giabanle = dr["GiaBanLe"].ToString(); dondathang.Giatrigiatang = dr["GiaTriThue"].ToString(); arr.Add(dondathang); } int n = arr.Count; if (n == 0) { list = null; } list = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(list); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinDatHang[] sp_LayBang_HangHoa(Entities.TruyenGiaTri giatri) { Entities.ThongTinDatHang[] arrC = null; try { dh = new Constants.ThongTinDatHang(); Sql = new Constants.Sql(); string sql = Sql.sp_LayBang_HangHoa; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar, 50).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { dondathang = new Entities.ThongTinDatHang(); dondathang.MaHangHoa = dr[0].ToString(); dondathang.TenHangHoa = dr[1].ToString(); dondathang.GiaNhap = dr[2].ToString(); dondathang.Tonkho = dr[3].ToString(); dondathang.Giabanbuon = dr[4].ToString(); dondathang.Giabanle = dr[5].ToString(); dondathang.Giatrigiatang = dr[6].ToString(); arr.Add(dondathang); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// xuat hang theo tung nhom hang hungvv /// </summary> /// <param name="nhom"></param> /// <returns></returns> public Entities.ChiTietKhoHangTheoMa[] sp_ChiTietKhoHangTheoMa(Entities.TruyenGiaTri nhom) { Entities.ChiTietKhoHangTheoMa[] arrC = null; try { string sql = "exec sp_XemKhoHang @MaKho"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKho", SqlDbType.NVarChar, 20).Value = nhom.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { kh = new Entities.ChiTietKhoHangTheoMa(); kh.Makho = dr[0].ToString(); kh.Tenkho = dr[1].ToString(); kh.Tenhang = dr[2].ToString(); kh.Gianhap = dr[3].ToString(); kh.Soluong = int.Parse(dr[4].ToString()); kh.Ngaynhap = DateTime.Parse(dr[5].ToString()); kh.Ngayhethan = DateTime.Parse(dr[6].ToString()); kh.TongTien = new Common.Utilities().FormatMoney(Double.Parse(dr[7].ToString())); kh.MaHangHoa = dr[8].ToString(); arr.Add(kh); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.ChiTietKhoHangTheoMa[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ChiTietKhoHangTheoMa)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// vuong hung =================lay bang kiem ke thao ma kiem ke================ /// </summary> /// <returns></returns> public Entities.ThongTinKiemKeKho[] sp_LayKiemKeKhoTheoMa(Entities.TruyenGiaTri giatri) { Entities.ThongTinKiemKeKho[] arrC = null; try { string sql = "exec sp_LayTheoMaKiemKeKho @MaPhieuKiemKe"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaPhieuKiemKe", SqlDbType.NVarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ThongTinKiemKeKho chitietkiemkekho = new Entities.ThongTinKiemKeKho(); chitietkiemkekho.Mahang = dr[0].ToString(); chitietkiemkekho.Tenhang = dr[1].ToString(); chitietkiemkekho.Tonsosach = dr[2].ToString(); chitietkiemkekho.Tonthucte = dr[3].ToString().ToString(); chitietkiemkekho.Chenhlech = dr[4].ToString().ToString(); chitietkiemkekho.Lydo = dr[5].ToString(); chitietkiemkekho.Giavon = dr[6].ToString(); chitietkiemkekho.Giachechlech = dr[7].ToString(); arr.Add(chitietkiemkekho); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.ThongTinKiemKeKho[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinKiemKeKho)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// lay ban ghi cuoi cung /// </summary> public Entities.HoaDonNhap LayHoaDonNhap(Entities.TruyenGiaTri truyen) { Entities.HoaDonNhap giatri = null; try { string sql = "exec sp_LayBang_TheoTenBang @table,@values"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("table", SqlDbType.NVarChar, 100).Value = truyen.Giatritruyen; cmd.Parameters.Add("values", SqlDbType.NVarChar, 50).Value = truyen.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { giatri = new Entities.HoaDonNhap(); giatri.Hanhdong = ""; giatri.HoaDonNhapID = int.Parse(dr[0].ToString()); giatri.MaHoaDonNhap = dr[1].ToString(); giatri.NgayNhap = Convert.ToDateTime(dr[2].ToString()); giatri.MaNhaCungCap = dr[3].ToString(); giatri.NoHienThoi = dr[4].ToString(); giatri.NguoiGiaoHang = dr[5].ToString(); giatri.HinhThucThanhToan = dr[6].ToString(); giatri.MaKho = dr[7].ToString(); giatri.HanThanhToan = Convert.ToDateTime(dr[8].ToString()); giatri.MaDonDatHang = dr[9].ToString(); giatri.MaTienTe = dr[10].ToString(); giatri.ChietKhau = dr[11].ToString(); giatri.ThanhToanNgay = dr[12].ToString(); giatri.ThueGTGT = dr[13].ToString(); giatri.TongTien = dr[14].ToString(); giatri.GhiChu = dr[15].ToString(); giatri.Deleted = Convert.ToBoolean(dr[16].ToString()); cla.ThanhToanSauKhiLapPhieu = dr[17].ToString(); } } catch (Exception ex) { string s = ex.Message.ToString(); return(null); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(giatri); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.HienThi_ChiTiet_DonDatHang[] sp_LayBang_ThongTinDonDatHang(Entities.TruyenGiaTri giatri) { Entities.HienThi_ChiTiet_DonDatHang[] arrC = null; try { arrC = this.SelectChiTietDonHang(giatri.Giatritruyen); //dh = new Constants.HienThi_ChiTiet_DonDatHang(); //Sql = new Constants.Sql(); //string sql = Sql.sp_LayBang_ThongTinDonDatHang; //conn = new Connection(); //cn = conn.openConnection(); //cmd = new SqlCommand(sql, cn); //cmd.Parameters.Add(dh.MaDonDatHang, SqlDbType.NVarChar, 20).Value = giatri.Giatritruyen; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //arr = new ArrayList(); //while (dr.Read()) //{ // hienthi = new Entities.HienThi_ChiTiet_DonDatHang(); // hienthi.MaHangHoa = dr[0].ToString(); // hienthi.TenHangHoa = dr[1].ToString(); // hienthi.SoLuongDat = int.Parse(0+dr[2].ToString()); // hienthi.GiaGoc = Double.Parse(0+dr[3].ToString()).ToString(); // hienthi.Giabanbuon = Double.Parse(0 + dr[4].ToString()).ToString(); // hienthi.Giabanle = Double.Parse(0+dr[5].ToString()).ToString(); // hienthi.PhanTramChietKhau = Double.Parse(0 + dr[6].ToString()).ToString(); // hienthi.Thuegiatrigiatang = Double.Parse(0 + dr[7].ToString()).ToString(); // arr.Add(hienthi); //} //int n = arr.Count; //if (n == 0) { arrC= null; } //arrC = new Entities.HienThi_ChiTiet_DonDatHang[n]; //for (int i = 0; i < n; i++) //{ // arrC[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; //} } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } //finally //{ // cmd.Connection.Dispose(); // cn.Close(); // conn.closeConnection(); //} return(arrC); }
public Entities.ThongTinDatHang[] ChiTietKhachHangTraLaiTheoDonBanHang(Entities.TruyenGiaTri gitri) { Entities.ThongTinDatHang[] list = null; try { string sql = "exec sp_ChiTietKhachHangTraLaiTheoDonBanHang @MaHDBanHang,@LoaiHoaDon"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHDBanHang", SqlDbType.NVarChar, 20).Value = gitri.Giatritruyen; cmd.Parameters.Add("LoaiHoaDon", SqlDbType.VarChar, 20).Value = gitri.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ThongTinDatHang lay = new Entities.ThongTinDatHang(); lay.HanhDong = dr[0].ToString(); lay.MaHangHoa = dr[1].ToString(); lay.TenHangHoa = dr[2].ToString(); lay.GiaNhap = dr[3].ToString(); lay.Tonkho = dr[4].ToString(); lay.Giatrigiatang = dr[5].ToString(); arr.Add(lay); } int n = arr.Count; if (n == 0) { list = null; } list = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(list); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.HienThi_KhachHangTraLai[] sp_HoaDonBanHangTheoKhachHang(Entities.TruyenGiaTri lay) { Entities.HienThi_KhachHangTraLai[] arrC = null; try { string sql = "exec sp_KhachHangTraLaiHang @MaKhachHang ,@MaHDBanHang,@LoaiHoaDon"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKhachHang", SqlDbType.NVarChar, 20).Value = "" + lay.Giatritruyen; cmd.Parameters.Add("MaHDBanHang", SqlDbType.VarChar, 20).Value = "" + lay.Giatriba; cmd.Parameters.Add("LoaiHoaDon", SqlDbType.VarChar, 20).Value = "" + lay.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.HienThi_KhachHangTraLai bang = new Entities.HienThi_KhachHangTraLai(); bang.Mahoadonbanhang = dr[0].ToString(); bang.Ngayban = DateTime.Parse(dr[1].ToString()); bang.Tongtien = dr[2].ToString(); bang.Nohienthoi = dr[3].ToString(); bang.MaKho = dr[4].ToString(); arr.Add(bang); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.HienThi_KhachHangTraLai[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.HienThi_KhachHangTraLai)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinNhaCungCap[] sp_LayBang_NhaCungCap(Entities.TruyenGiaTri giatri) { Entities.ThongTinNhaCungCap[] arrC = null; try { dh = new Constants.ThongTinNhaCungCap(); Sql = new Constants.Sql(); string sql = Sql.sp_LayBang_NhaCungCap; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhaCungCap", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { cungcap = new Entities.ThongTinNhaCungCap(); cungcap.Manhacungcap = dr[0].ToString(); cungcap.Tennhacungcap = dr[1].ToString(); cungcap.Diachi = dr[2].ToString(); cungcap.Nohienthoi = dr[3].ToString(); arr.Add(cungcap); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.ThongTinNhaCungCap[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinNhaCungCap)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinKhachHang[] sp_LayBang_KhachHang(Entities.TruyenGiaTri giatri) { Entities.ThongTinKhachHang[] arrC = null; try { dh = new Constants.ThongTinKhachHang(); Sql = new Constants.Sql(); string sql = Sql.sp_LayBang_ThongTinKhachHang; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKH", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ThongTinKhachHang khachhang = new Entities.ThongTinKhachHang(); khachhang.Makhachhang = dr[dh.MaKH].ToString(); khachhang.Tenkhachhang = dr[dh.Ten].ToString(); khachhang.Diachi = dr[dh.DiaChi].ToString(); khachhang.Duno = dr["DuNo"].ToString(); arr.Add(khachhang); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.ThongTinKhachHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinKhachHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// lay hang hoa theo ma nhom hang /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.ThongTinHangHoa[] Select(Entities.TruyenGiaTri giatri) { Entities.ThongTinHangHoa[] arrC = null; try { string sql = "exec sp_TimHangHoaTheoMaNhomHang @MaNhomHangHoa"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhomHangHoa", SqlDbType.NVarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ThongTinHangHoa tao = new Entities.ThongTinHangHoa(); tao.MaNhomHangHoa = dr[0].ToString(); tao.MaHangHoa = dr[1].ToString(); tao.TenHangHoa = dr[2].ToString(); tao.GiaNhap = dr[3].ToString(); tao.GiaBanBuon = dr[4].ToString(); tao.GiaBanLe = dr[5].ToString(); arr.Add(tao); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.ThongTinHangHoa[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinHangHoa)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.BaoCaoSoDuKho[] Select(Entities.TruyenGiaTri giatri) { Entities.BaoCaoSoDuKho[] arrC = null; try { string sql = "exec sp_LaySoDuKho @TuNgay,@DenNgay"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("TuNgay", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; cmd.Parameters.Add("DenNgay", SqlDbType.VarChar, 20).Value = giatri.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.BaoCaoSoDuKho tao = new Entities.BaoCaoSoDuKho(); tao.MaSoDuKho = dr[0].ToString(); tao.MaHangHoa = dr[1].ToString(); tao.SoDuDauKy = int.Parse(dr[2].ToString()); tao.SoDuCuoiKy = int.Parse(dr[3].ToString()); tao.NgayKetChuyen = DateTime.Parse(dr[4].ToString()); arr.Add(tao); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.BaoCaoSoDuKho[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BaoCaoSoDuKho)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.KiemTraChung[] LaySoLuongDaTraLaiTheoHoaDonNhap(Entities.TruyenGiaTri giatri) { Entities.KiemTraChung[] tra = null; try { SqlDataReader read = null; string sql = "exec sp_LaySoLuongDaTraLaiTheoHoaDonNhap @MaHoaDonNhap"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHoaDonNhap", SqlDbType.NVarChar, 20).Value = giatri.Giatritruyen; read = cmd.ExecuteReader(); ArrayList arr = new ArrayList(); while (read.Read()) { Entities.KiemTraChung banghi = new Entities.KiemTraChung(); banghi.Giatri = read[0].ToString(); banghi.Giatri2 = read[1].ToString(); arr.Add(banghi); } read.Close(); int n = arr.Count; if (n == 0) { tra = null; } tra = new Entities.KiemTraChung[n]; for (int i = 0; i < n; i++) { tra[i] = (Entities.KiemTraChung)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); tra = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(tra); }
/// <summary> /// lay ban ghi cuoi cung /// </summary> public Entities.DonDatHang sp_LayBang_TheoTenBang(Entities.TruyenGiaTri truyen) { Entities.DonDatHang giatri = new Entities.DonDatHang(); try { string sql = "exec sp_LayBang_TheoTenBang @table,@values"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("table", SqlDbType.NVarChar, 100).Value = truyen.Giatritruyen; cmd.Parameters.Add("values", SqlDbType.NVarChar, 50).Value = truyen.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { giatri.DonDatHangID = int.Parse(dr[0].ToString()); giatri.MaDonDatHang = dr[1].ToString(); giatri.LoaiDonDatHang = Boolean.Parse(dr[2].ToString()); giatri.NgayDonHang = DateTime.Parse(dr[3].ToString()); giatri.MaNhaCungCap = dr[4].ToString(); giatri.NoHienThoi = dr[5].ToString(); giatri.TrangThaiDonDatHang = dr[6].ToString(); giatri.NgayNhapDuKien = DateTime.Parse(dr[7].ToString()); giatri.HinhThucThanhToan = dr[8].ToString(); giatri.MaKho = dr[9].ToString(); giatri.MaNhanVien = dr[10].ToString(); giatri.MaTienTe = dr[11].ToString(); giatri.ThueGTGT = dr[12].ToString(); giatri.Phivanchuyen = dr[13].ToString(); giatri.PhiKhac = dr[14].ToString(); giatri.GhiChu = dr[15].ToString(); giatri.Deleted = Boolean.Parse(dr[16].ToString()); giatri.Makhachhang = dr[17].ToString(); } } catch (Exception ex) { string s = ex.Message.ToString(); giatri = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(giatri); }
/// <summary> /// xuat hang theo tung nhom hang hungvv /// </summary> /// <param name="nhom"></param> /// <returns></returns> public Entities.BaoCaoXuatHangTheoNhomHang[] sp_BaoCao_XuatTheoNhomHang(Entities.TruyenGiaTri nhom) { Entities.BaoCaoXuatHangTheoNhomHang[] arrC = null; try { string sql = "exec sp_BaoCao_XuatTheoNhomHang @MaNhomHang,@NgayBan"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhomHang", SqlDbType.VarChar, 20).Value = nhom.Giatritruyen; cmd.Parameters.Add("NgayBan", SqlDbType.DateTime).Value = nhom.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { xuatkho = new Entities.BaoCaoXuatHangTheoNhomHang(); xuatkho.MaKho = dr[0].ToString(); xuatkho.MaKho = dr[1].ToString(); xuatkho.MaKho = dr[2].ToString(); xuatkho.MaKho = dr[3].ToString(); xuatkho.MaKho = dr[4].ToString(); arr.Add(xuatkho); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.BaoCaoXuatHangTheoNhomHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BaoCaoXuatHangTheoNhomHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// /// </summary> /// <param name="gitri"></param> /// <returns></returns> public Entities.ThongTinKhachHang[] BindingKhachHangTralaiHang(Entities.TruyenGiaTri gitri) { Entities.ThongTinKhachHang[] list = null; try { string sql = "exec sp_BindingKhachHangTralaiHang @LoaiHoaDon"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("LoaiHoaDon", SqlDbType.VarChar, 20).Value = gitri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.ThongTinKhachHang khachhang = new Entities.ThongTinKhachHang(); khachhang.Makhachhang = dr[0].ToString(); khachhang.Tenkhachhang = dr[1].ToString(); khachhang.Diachi = dr[2].ToString(); khachhang.Duno = dr[3].ToString(); arr.Add(khachhang); } int n = arr.Count; if (n == 0) { list = null; } list = new Entities.ThongTinKhachHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.ThongTinKhachHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(list); }
/// <summary> /// lay ban ghi kiem tra khi update /// </summary> /// <param name="truyen"></param> /// <returns></returns> public Entities.TraLaiNCC CheckTraLaiNhaCungCap(Entities.TruyenGiaTri truyen) { Entities.TraLaiNCC giatri = new Entities.TraLaiNCC(); try { string sql = "exec sp_LayBang_TheoTenBang @table,@values"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("table", SqlDbType.NVarChar, 100).Value = truyen.Giatritruyen; cmd.Parameters.Add("values", SqlDbType.NVarChar, 50).Value = truyen.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { giatri.TraLaiNCCID = Convert.ToInt32(dr[0].ToString()); giatri.MaHDTraLaiNCC = dr[1].ToString(); giatri.Ngaytra = Convert.ToDateTime(dr[2].ToString()); giatri.MaNCC = dr[3].ToString(); giatri.NoHienThoi = dr[4].ToString(); giatri.NguoiNhanHang = dr[5].ToString(); giatri.HinhThucThanhToan = dr[6].ToString(); giatri.MaHoaDonNhap = dr[7].ToString(); giatri.MaKho = dr[8].ToString(); giatri.MaTienTe = dr[9].ToString(); giatri.TienBoiThuong = dr[10].ToString(); giatri.ThanhToanNgay = dr[11].ToString(); giatri.ThueGTGT = dr[12].ToString(); giatri.GhiChu = dr[13].ToString(); giatri.Deleted = Convert.ToBoolean(dr[14].ToString()); } } catch (Exception ex) { string s = ex.Message.ToString(); giatri = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(giatri); }
/// <summary> /// lay so lupong mua theo hoa don ban hang /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.SoLuongTraLai[] sp_LaySoLuongDaMuaTheoHoaDonBanHang(Entities.TruyenGiaTri giatri) { Entities.SoLuongTraLai[] arrC = null; try { string sql = "exec sp_LaySoLuongDaMuaTheoHoaDonBanHang @MaHDBanHang"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHDBanHang", SqlDbType.NVarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.SoLuongTraLai tao = new Entities.SoLuongTraLai(); tao.MaHangHoa = dr[0].ToString(); tao.SoLuong = int.Parse(dr[1].ToString()); arr.Add(tao); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.SoLuongTraLai[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.SoLuongTraLai)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
/// <summary> /// cai dat kho /// </summary> /// <returns></returns> public TruyenGiaTri CaiDatKho(string hanhdong, string ma, string ten) { Common.Constants.Sql get = new Common.Constants.Sql(); Entities.TruyenGiaTri giatri = new Entities.TruyenGiaTri(); string Links = Application.StartupPath.ToString() + get.tenfile; try { XmlDocument doc = new XmlDocument(); if (CheckFile(Links) == true) { if (hanhdong == "View") { doc.Load(Links); XmlElement root = doc.DocumentElement; giatri.Giatritruyen = GiaiMa(get.setup, root.ChildNodes[0].InnerText); giatri.Giatrithuhai = GiaiMa(get.setup, root.ChildNodes[1].InnerText); } if (hanhdong == "XuLy") { XmlTextWriter txtwrite = new XmlTextWriter(Links, null); txtwrite.WriteStartDocument(); txtwrite.WriteStartElement(constants.Connect); txtwrite.WriteElementString("MaKho", MaHoa(get.setup, ma)); txtwrite.WriteElementString("TenKho", MaHoa(get.setup, ten)); txtwrite.WriteEndElement(); txtwrite.WriteEndDocument(); txtwrite.Close(); giatri.Hanhdong = "Đã lưu lại"; } } else { if (hanhdong == "XuLy") { XmlTextWriter txtwrite = new XmlTextWriter(Links, null); txtwrite.WriteStartDocument(); txtwrite.WriteStartElement(constants.Connect); txtwrite.WriteElementString("MaKho", MaHoa(get.setup, ma)); txtwrite.WriteElementString("TenKho", MaHoa(get.setup, ten)); txtwrite.WriteEndElement(); txtwrite.WriteEndDocument(); txtwrite.Close(); giatri.Hanhdong = "Đã lưu lại"; } } } catch (Exception ex) { string s = ex.Message.ToString(); DeleteFile(Links); giatri.Hanhdong = "Đã xóa"; } return giatri; }
/// <summary> /// lay kho theo quay file xml /// </summary> /// <param name="kho"></param> public Boolean ComboxKhoHang(ComboBox kho) { try { Entities.TruyenGiaTri[] tra = new Entities.TruyenGiaTri[1]; tra[0] = CaiDatKho("View", "", ""); if (tra[0].Giatritruyen == "NULL") { MessageBox.Show("Chưa cài đặt kho hàng"); return false; } BindingCombobox(tra, kho, "Giatrithuhai", "Giatritruyen"); return true; } catch (Exception) { return false; } }
/// <summary> /// xoa hang hoa theo don nhap hang /// </summary private int XoaTheoHoaDon(string hanhdong, string ma) { int tra = 0; try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri truyen = new Entities.TruyenGiaTri(); truyen.Hanhdong = "Update"; truyen.Giatritruyen = hanhdong; truyen.Giatrithuhai = ma; clientstrem = cl.SerializeObj(this.client, "XoaTheoHoaDon", truyen); tra = (int)cl.DeserializeHepper(clientstrem, tra); } catch (Exception ex) { string s = ex.Message; tra = 0; } return tra; }
private void update(string ma, string duno) { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri kh = new Entities.TruyenGiaTri("Update", ma, duno); clientstrem = cl.SerializeObj(this.client, "UpdateDuNo", kh); int kq = 0; kq = (int)cl.DeserializeHepper(clientstrem, kq); client.Close(); clientstrem.Close(); if (kq > 0) { } else { string f = "Chưa cập nhật"; } } catch { } }
private Boolean KiemTraTrangThaiDonDatHang(string madondathang) { Boolean bl = false; try { Entities.TruyenGiaTri dat = new Entities.TruyenGiaTri(); dat.Hanhdong = "Select"; dat.Giatritruyen = "ThanhCong"; dat.Giatrithuhai = madondathang; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "KiemTraDonDatHang", dat); Entities.TruyenGiaTri ddh = new Entities.TruyenGiaTri(); ddh = (Entities.TruyenGiaTri)cl.DeserializeHepper(clientstrem, ddh); if (ddh.Giatritruyen == "Yes") { bl = true; } else { bl = false; } } catch { bl = false; } return bl; }
/// <summary> /// do du lieu vao dgv /// </summary> private void HienThi_ChiTiet_DonDatHang() { try { Entities.TruyenGiaTri dat = new Entities.TruyenGiaTri(); dat.Hanhdong = "Select"; dat.Giatritruyen = txtMadondathang.Text; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "HienThi_ChiTiet_DonDatHang", dat); Entities.HienThi_ChiTiet_DonDatHang[] ddh = new Entities.HienThi_ChiTiet_DonDatHang[1]; ddh = (Entities.HienThi_ChiTiet_DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); if (ddh.Length > 0) { XuLyChiTietDonDatHang(ddh); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } } catch (Exception ex) { string s = ex.Message.ToString(); Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
private void GetDate() { try { Entities.TruyenGiaTri kh = new Entities.TruyenGiaTri(); kh.Hanhdong = "Select"; cl = new Server_Client.Client(); client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "GetDateTime", kh); Entities.TruyenGiaTri DateTimes = new Entities.TruyenGiaTri(); DateTimes = (Entities.TruyenGiaTri)cl.DeserializeHepper(clientstrem, DateTimes); DateTime tem = new DateTime(1753, 1, 1); this.giatritruyenthu4 = DateTimes.GiatritruyenTU; try { tem = DateTime.Parse(DateTimes.Giatritruyen).Date; } catch { tem = this.giatritruyenthu4; } Date = tem; } catch { } }
/// <summary> /// vuong hung =================lay hang hoa theo ma hoa don ban hang================ /// </summary> /// <returns></returns> public Entities.LayHangHoaTheoMaKhachHangTraLai[] sp_LayHangHoaTheoMaHoaDonNhap(Entities.TruyenGiaTri lay) { Entities.LayHangHoaTheoMaKhachHangTraLai[] arrC = null; try { string sql = "exec sp_TimHoaDonNhapTheoMaNhaCungCap @MaNhaCungCap,@MaHoaDonNhap"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhaCungCap", SqlDbType.NVarChar, 20).Value = lay.Giatritruyen; cmd.Parameters.Add("MaHoaDonNhap", SqlDbType.VarChar, 20).Value = lay.Giatrithuhai; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.LayHangHoaTheoMaKhachHangTraLai bang = new Entities.LayHangHoaTheoMaKhachHangTraLai(); bang.Mahanghoa = dr[0].ToString(); bang.Tenhanghoa = dr[1].ToString(); bang.Soluong = int.Parse(dr[2].ToString()); bang.Giaban = dr[3].ToString(); bang.Phantramchietkhau = dr[4].ToString(); bang.Chietkhau = dr[5].ToString(); bang.Tongtien = dr[6].ToString(); bang.Thuegiatrigiatang = dr[7].ToString(); arr.Add(bang); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.LayHangHoaTheoMaKhachHangTraLai[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.LayHangHoaTheoMaKhachHangTraLai)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
private Entities.ThongTinCongTy Congty(string maCongTy) { Entities.ThongTinCongTy thongtin = null; try { Entities.TruyenGiaTri truyen = new Entities.TruyenGiaTri("Select", maCongTy); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "LayThongTinCongty", truyen); thongtin = (Entities.ThongTinCongTy)cl.DeserializeHepper(clientstrem, thongtin); client.Close(); clientstrem.Close(); } catch { return null; } return thongtin; }
private void DoDuLieu(Entities.HoaDonNhap dat) { try { Common.Utilities com = new Common.Utilities(); ID = dat.HoaDonNhapID; txtSodonhang.Text = dat.MaHoaDonNhap; txtManhacungcap.Text = dat.MaNhaCungCap; ////////////////////////////////////////MRK FIX if (lblTenNhaCungCap.Text.Equals("")) { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri cc = new Entities.TruyenGiaTri("Select", ""); clientstrem = cl.SerializeObj(this.client, "ThongTinNhaCungCap", cc); Entities.ThongTinNhaCungCap[] ddh = new Entities.ThongTinNhaCungCap[1]; ddh = (Entities.ThongTinNhaCungCap[])cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); if (ddh.Length > 0) { foreach (Entities.ThongTinNhaCungCap item in ddh) { if (item.Manhacungcap.Equals(txtManhacungcap.Text)) { lblTenNhaCungCap.Text = item.Tennhacungcap; } } } else { } } catch { } } ///////////////////////////////////////////////////////// GiaTriCanLuu.Ma = dat.MaNhaCungCap; makNgaydonhang.Text = new Common.Utilities().XuLy(2, dat.NgayNhap.ToString()); makHanthanhtoan.Text = new Common.Utilities().XuLy(2, dat.HanThanhToan.ToString()); txtNohienthoi.Text = dat.NoHienThoi; txtnguoigiaohang.Text = dat.NguoiGiaoHang; cbxHinhthucthanhtoan.SelectedItem = dat.HinhThucThanhToan; cbxKhoHang.SelectedValue = dat.MaKho; maKhoHang = dat.MaKho; txtMadondathang.Text = dat.MaDonDatHang; cbxTienTe_TyGia.SelectedValue = dat.MaTienTe; txtDiengiai.Text = dat.GhiChu; if (dat.MaDonDatHang != "" || dat.MaDonDatHang == "<F4 - TRA CỨU>") { chekChonLoai.Checked = true; } else { chekChonLoai.Checked = false; } txtMadondathang.ReadOnly = true; btnTimMadatmuahang.Enabled = false; chekChonLoai.Enabled = false; if (txtSodonhang.Text != "" || txtSodonhang.Text != "<F4 -Tra cứu>") { HienThi_ChiTiet_HoaDonNhap(txtSodonhang.Text); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } double ckTongHoaDon = 0; if (!string.IsNullOrEmpty(dat.ChietKhau)) ckTongHoaDon = double.Parse(dat.ChietKhau); txtTienCKTM0.Text = new Common.Utilities().FormatMoney(ckTongHoaDon); TinhToan(); txtCKTM0.Text = new Common.Utilities().FormatMoney(100 - (1 - double.Parse(dat.ChietKhau) / double.Parse(txtTongThanhToan.Text.Replace(",", ""))) * 100); txtTongThanhToan.Text = new Common.Utilities().FormatMoney(double.Parse(txtTongThanhToan.Text.Replace(",", "")) - double.Parse(txtTienCKTM0.Text.Replace(",", ""))); txtThanhtoanngay.Text = new TienIch().FormatMoney(dat.ThanhToanNgay); txtTienTraLai.Text = new Common.Utilities().FormatMoney(Double.Parse(dat.ThanhToanNgay) - Double.Parse(dat.TongTien)); double thanhtoankhilapphieu = Double.Parse(dat.ThanhToanSauKhiLapPhieu); if ((Double.Parse(txtThanhtoanngay.Text.Replace(",", "")) + thanhtoankhilapphieu) == Double.Parse(txtTongThanhToan.Text)) { lbtinhtrang.Text = "Đã Thanh Toán"; toolStripStatus_Thanhtoan.Enabled = false; } else { lbtinhtrang.Text = "Chưa Thanh Toán"; toolStripStatus_Thanhtoan.Enabled = true; } string date = new Common.Utilities().MyDateConversion(makNgaydonhang.Text); string date2 = new Common.Utilities().MyDateConversion(makHanthanhtoan.Text); string makho = cbxKhoHang.SelectedValue.ToString(); string matt = cbxTienTe_TyGia.SelectedValue.ToString(); hoa = new Entities.HoaDonNhap[1]; hoa[0] = dat; } catch (Exception ex) { string s = ex.Message; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
private Entities.HoaDonNhap ConfilickData(string table, string values) { Entities.HoaDonNhap ddh = new Entities.HoaDonNhap(); try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri gitri = new Entities.TruyenGiaTri("Select", table, values); clientstrem = cl.SerializeObj(this.client, "CheckHoaDonNhap", gitri); ddh = (Entities.HoaDonNhap)cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); } catch (Exception ex) { string s = ex.Message.ToString(); ddh = null; } return ddh; }
/// <summary> /// lay hang hoa theo ma tra lai nha cung cap /// </summary> /// <param name="truyen"></param> public Entities.LayHangHoaTheoMaKhachHangTraLai[] LayHangHoaTheoMaTraLaiNhaCungCap(Entities.TruyenGiaTri truyen) { Entities.LayHangHoaTheoMaKhachHangTraLai[] arrC = null; try { string sql = "exec sp_LayHangHoaTheoMaTraLaiNhaCungCap @MaTraLaiNhaCungCap"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaTraLaiNhaCungCap", SqlDbType.VarChar, 20).Value = truyen.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { Entities.LayHangHoaTheoMaKhachHangTraLai bang = new Entities.LayHangHoaTheoMaKhachHangTraLai(); bang.Mahanghoa = dr[0].ToString(); bang.Tenhanghoa = dr[1].ToString(); bang.Soluong = int.Parse(dr[2].ToString()); bang.Giaban = dr[3].ToString(); string phantram = "0"; string chietkhau = "0"; string tong = "0"; if (Double.Parse(dr[4].ToString()) == 0) { tong = new Common.Utilities().FormatMoney(int.Parse(dr[2].ToString()) * Double.Parse(dr[3].ToString())); chietkhau = tong; } else { phantram = dr[4].ToString(); tong = new Common.Utilities().FormatMoney(int.Parse(dr[2].ToString()) * Double.Parse(dr[3].ToString())); chietkhau = new Common.Utilities().FormatMoney(Double.Parse(tong) - ((Double.Parse(phantram) / 100 * Double.Parse(dr[3].ToString())) * int.Parse(dr[2].ToString()))); } bang.Phantramchietkhau = phantram; bang.Thuegiatrigiatang = dr[5].ToString(); bang.Chietkhau = chietkhau; bang.Tongtien = tong; arr.Add(bang); } int n = arr.Count; if (n == 0) { arrC = null; } arrC = new Entities.LayHangHoaTheoMaKhachHangTraLai[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.LayHangHoaTheoMaKhachHangTraLai)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }