/// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ThongTinNhaCungCap()
 {
     dh      = null;
     Sql     = null;
     conn    = null;
     cmd     = null;
     arr     = null;
     dr      = null;
     cungcap = null;
     cn      = null;
 }
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ThongTinNhaCungCap()
 {
     dh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     cungcap = null;
     cn = null;
 }
 /// <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.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;
 }
Esempio n. 5
0
 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);
     }
 }