Exemplo n.º 1
0
 public DataTable KhachGiaoDich(string makhach, char loai)
 {
     try
     {
         using (QLCuaHangDataContext cuahang = new QLCuaHangDataContext())
         {
             DataTable dt = new DataTable();
             dt.Columns.Add("MaKhach");
             dt.Columns.Add("TenKhach");
             dt.Columns.Add("SDT");
             dt.Columns.Add("DiaChi");
             dt.Columns.Add("GhiChuKhach");
             dt.Columns.Add("MaNX");
             dt.Columns.Add("Ngay");
             dt.Columns["Ngay"].DataType = typeof(DateTime);
             dt.Columns.Add("GhiChuNX");
             DataRow dr;
             foreach (var kgd in cuahang.SP_XemKhachGiaoDich(makhach, loai))
             {
                 dr                = dt.NewRow();
                 dr["MaKhach"]     = kgd.MaKhach;
                 dr["TenKhach"]    = kgd.TenKhach;
                 dr["SDT"]         = kgd.SDT;
                 dr["DiaChi"]      = kgd.DiaChi;
                 dr["GhiChuKhach"] = kgd.GhiChuKhach;
                 dr["MaNX"]        = kgd.MaNX;
                 if (kgd.Ngay != null)
                 {
                     dr["Ngay"] = kgd.Ngay;
                 }
                 else
                 {
                     dr["Ngay"] = DBNull.Value;
                 }
                 dr["GhiChuNX"] = kgd.GhiChuNX;
                 dt.Rows.Add(dr);
             }
             return(dt);
         }
     }
     catch (Exception ex)
     {
         myme.ShowError(ex);
         return(null);
     }
 }