Beispiel #1
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <PRequestHeader>();
         if (accessDetail.xem)
         {
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "a.");
                 data      = dbConn.Select <PRequestHeader>(@"Select distinct a.* From PRequestHeader a
                                                        Inner Join UsersBranch b on b.ma_chi_nhanh = a.ma_chi_nhanh
                                                        Where b.ma_nguoi_dung = '" + currentUser.ma_nguoi_dung + "' and " + where);
             }
             else
             {
                 data = dbConn.Select <PRequestHeader>(@"Select distinct a.* From PRequestHeader a
                                                        Inner Join UsersBranch b on b.ma_chi_nhanh = a.ma_chi_nhanh
                                                        Where b.ma_nguoi_dung = '" + currentUser.ma_nguoi_dung + "'");
             }
         }
         else
         {
             return(RedirectToAction("NoAccessRights", "Error"));
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
            {
                var data  = new DataSourceResult();
                var query = @"SELECT  
	                           Detail.*,
                               P.nha_cung_cap_id,
	                           V.ten_nha_cung_Cap, 
	                           V.dien_thoai, 
	                           P.so_hop_dong,
                               V.email, 
	                           P.ghi_chu

                            FROM ProductPriceHeader P LEFT JOIN Vendor V ON P.nha_cung_cap_id = V.nha_cung_cap_id
	                        LEFT JOIN dbo.ProductPriceDetail Detail ON Detail.ma_chinh_sach_gia = P.ma_chinh_sach_gia
                            ";
                if (accessDetail.xem)
                {
                    if (request.Filters.Any())
                    {
                        var where = KendoApplyFilter.ApplyFilter(request.Filters[0]);
                        data      = KendoApplyFilter.KendoDataByQuery <ProductPriceReport>(request, query, where);
                    }
                    else
                    {
                        data = KendoApplyFilter.KendoDataByQuery <ProductPriceReport>(request, query, "");
                    }
                }
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult ExportData([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                //using (ExcelPackage excelPkg = new ExcelPackage())
                FileInfo fileInfo    = new FileInfo(Server.MapPath(@"~\ExportExcelFile\NCC.xlsx"));
                var      excelPkg    = new ExcelPackage(fileInfo);
                string   fileName    = "NCC_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
                string   contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                var data = new List <Vendor>();
                if (accessDetail.xuat)
                {
                    if (request.Filters.Any())
                    {
                        var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                        data      = dbConn.Select <Vendor>(where).ToList();
                    }
                    else
                    {
                        data = dbConn.Select <Vendor>().ToList();
                    }
                }
                ExcelWorksheet Sheet = excelPkg.Workbook.Worksheets["data"];

                int rowData = 7;
                int stt     = 0;
                foreach (var item in data)
                {
                    var contact = dbConn.SingleOrDefault <ContactInfor>("nha_cung_cap_id={0} and nguoi_lien_he_chinh = 1", item.nha_cung_cap_id);
                    int i       = 1;
                    stt++;
                    rowData++;
                    Sheet.Cells[rowData, i++].Value = stt;
                    Sheet.Cells[rowData, i++].Value = item.ten_nha_cung_cap;
                    Sheet.Cells[rowData, i++].Value = item.ten_thuong_goi;
                    Sheet.Cells[rowData, i++].Value = item.ma_so_thue;
                    Sheet.Cells[rowData, i++].Value = item.dia_chi;
                    Sheet.Cells[rowData, i++].Value = item.von_dieu_le;
                    Sheet.Cells[rowData, i++].Value = item.quy_mo;
                    Sheet.Cells[rowData, i++].Value = item.pham_vi_cung_ung;
                    //Mat hang kinh doanh
                    Sheet.Cells[rowData, i++].Value = "";
                    Sheet.Cells[rowData, i++].Value = item.thoi_gian_cung_ung;
                    Sheet.Cells[rowData, i++].Value = item.khach_hang_cung_cap;
                    Sheet.Cells[rowData, i++].Value = item.nha_cung_cap_cua_hdbank;
                    Sheet.Cells[rowData, i++].Value = contact != null ? contact.ten_nguoi_lien_he : "";
                    Sheet.Cells[rowData, i++].Value = contact != null ? contact.so_dien_thoai : "";
                    Sheet.Cells[rowData, i++].Value = contact != null ? contact.email : "";

                    Sheet.Cells[rowData, i++].Value = item.file_dinh_kem;
                    Sheet.Cells[rowData, i++].Value = item.ghi_chu;
                }
                MemoryStream output = new MemoryStream();
                excelPkg.SaveAs(output);
                output.Position = 0;
                return(File(output.ToArray(), contentType, fileName));
            }
        }
        public ActionResult ExportData([DataSourceRequest] DataSourceRequest request)
        {
            if (asset.Export)
            {
                using (var dbConn = Helpers.OrmliteConnection.openConn())
                {
                    //using (ExcelPackage excelPkg = new ExcelPackage())
                    FileInfo fileInfo = new FileInfo(Server.MapPath(@"~\ExportExcelFile\Deca_Telesales_Agent_KPI.xlsx"));
                    var      excelPkg = new ExcelPackage(fileInfo);

                    string fileName    = "Deca_Telesales_Agent_KPI" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
                    string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                    var data = new List <Deca_Telesales_Agent_KPI>();
                    if (request.Filters.Any())
                    {
                        var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                        data      = dbConn.Select <Deca_Telesales_Agent_KPI>(where).ToList();
                    }
                    else
                    {
                        data = dbConn.Select <Deca_Telesales_Agent_KPI>().ToList();
                    }


                    ExcelWorksheet dataSheet = excelPkg.Workbook.Worksheets["TelesalesAgentKPI"];

                    int rowData = 1;

                    foreach (var item in data)
                    {
                        int i = 1;
                        rowData++;
                        dataSheet.Cells[rowData, i++].Value = item.Agent;
                        dataSheet.Cells[rowData, i++].Value = item.Revenue;
                        dataSheet.Cells[rowData, i++].Value = item.Order;
                        dataSheet.Cells[rowData, i++].Value = item.Call;
                        dataSheet.Cells[rowData, i++].Value = item.TalkTime;
                        dataSheet.Cells[rowData, i++].Value = item.CreatedAt;
                        dataSheet.Cells[rowData, i++].Value = item.CreatedBy;
                        dataSheet.Cells[rowData, i++].Value = item.UpdatedAt;
                        dataSheet.Cells[rowData, i++].Value = item.UpdatedBy;
                    }

                    MemoryStream output = new MemoryStream();
                    excelPkg.SaveAs(output);
                    output.Position = 0;
                    return(File(output.ToArray(), contentType, fileName));
                }
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
Beispiel #5
0
 //CanhLV
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <User>();
         if (accessDetail.xem)
         {
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0]);
                 data      = dbConn.Select <User>(@" Select * From 
                                               (
                                                 Select  *
                                                             ,ISNULL(STUFF ((
                                                             Select DISTINCT ',' + a.ma_chi_nhanh
                                                             From UsersBranch a
                                                                 Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                             Where a.ma_nguoi_dung = usr.ma_nguoi_dung
                                                             For XML Path('') 
                                                             ), 1, 1, ''),'') AS ma_chi_nhanh
                                                     ,ISNULL(STUFF ((
                                                             Select DISTINCT ',' + b.ten_chi_nhanh
                                                             From UsersBranch a
                                                                 Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                             Where a.ma_nguoi_dung = usr.ma_nguoi_dung
                                                             For XML Path('') 
                                                             ), 1, 1, ''),'') AS ten_chi_nhanh
                                                 From [User] usr
                                                ) data Where " + where
                                                  );
             }
             else
             {
                 data = dbConn.Select <User>(@"Select  *
                                                 ,ISNULL(STUFF ((
                                                         Select DISTINCT ',' + a.ma_chi_nhanh
                                                         From UsersBranch a
                                                             Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                         Where a.ma_nguoi_dung = usr.ma_nguoi_dung
                                                         For XML Path('') 
                                                         ), 1, 1, ''),'') AS ma_chi_nhanh
                                                  ,ISNULL(STUFF ((
                                                         Select DISTINCT ',' + b.ten_chi_nhanh
                                                         From UsersBranch a
                                                            Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                         Where a.ma_nguoi_dung = usr.ma_nguoi_dung
                                                         For XML Path('') 
                                                         ), 1, 1, ''),'') AS ten_chi_nhanh
                                         From [User] usr"
                                             );
             }
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #6
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            var    dbConn         = Helpers.OrmliteConnection.openConn();
            string whereCondition = "";

            if (request.Filters.Count > 0)
            {
                whereCondition = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
            }
            var data = dbConn.Select <Parameters>(whereCondition);

            return(Json(data.ToDataSourceResult(request)));
        }
        public ActionResult ExportData([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                //using (ExcelPackage excelPkg = new ExcelPackage())
                FileInfo fileInfo = new FileInfo(Server.MapPath(@"~\ExportExcelFile\User_Template.xlsx"));
                var      excelPkg = new ExcelPackage(fileInfo);

                string fileName    = "User_Template_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
                string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                var data = new List <tw_User>();
                if (accessDetail != null && (accessDetail.access["all"] || accessDetail.access["export"]))
                {
                    if (request.Filters.Any())
                    {
                        var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                        data      = dbConn.Select <tw_User>(where).ToList();
                    }
                    else
                    {
                        data = dbConn.Select <tw_User>().ToList();
                    }
                }
                ExcelWorksheet Sheet = excelPkg.Workbook.Worksheets["Data"];

                int rowData   = 1;
                var territory = dbConn.Select <Territory>();
                foreach (var item in data)
                {
                    int i = 1;
                    rowData++;
                    Sheet.Cells[rowData, i++].Value = item.name;
                    Sheet.Cells[rowData, i++].Value = item.fullName;
                    Sheet.Cells[rowData, i++].Value = item.gender;
                    Sheet.Cells[rowData, i++].Value = item.birthday;
                    Sheet.Cells[rowData, i++].Value = item.phone;
                    Sheet.Cells[rowData, i++].Value = item.email;
                    Sheet.Cells[rowData, i++].Value = item.address;
                    Sheet.Cells[rowData, i++].Value = territory.SingleOrDefault(s => s.Id == item.country) != null?territory.SingleOrDefault(s => s.Id == item.country).Name : "";

                    Sheet.Cells[rowData, i++].Value = territory.SingleOrDefault(s => s.Id == item.city) != null?territory.SingleOrDefault(s => s.Id == item.city).Name : "";

                    Sheet.Cells[rowData, i++].Value = territory.SingleOrDefault(s => s.Id == item.district) != null?territory.SingleOrDefault(s => s.Id == item.district).Name : "";
                }
                MemoryStream output = new MemoryStream();
                excelPkg.SaveAs(output);
                output.Position = 0;
                return(File(output.ToArray(), contentType, fileName));
            }
        }
Beispiel #8
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         var    data           = new DataSourceResult();
         string whereCondition = "";
         if (request.Filters.Count > 0)
         {
             whereCondition = " AND " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
         }
         data = new CRM_Adv().GetPage(request, whereCondition);
         return(Json(data));
     }
 }
Beispiel #9
0
        public ActionResult City_Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = new List <CRM_Location_City>();

            if (request.Filters.Any())
            {
                var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "data.");
                data      = CRM_Location_City.GetCRM_Location_Citys(where, "CityID DESC");
            }
            else
            {
                data = CRM_Location_City.GetCRM_Location_Citys("1=1", "CityID DESC");
            }
            return(Json(data.ToDataSourceResult(request)));
        }
Beispiel #10
0
        public ActionResult Country_Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = new List <DC_Location_Countries>();

            if (request.Filters.Any())
            {
                var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "data.");
                data      = DC_Location_Countries.GetDC_Location_Countries(where, "CountryID DESC");
            }
            else
            {
                data = DC_Location_Countries.GetDC_Location_Countries("1=1", "CountryID DESC");
            }
            return(Json(data.ToDataSourceResult(request)));
        }
        public ActionResult Alias_Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = new List <khu_vuc>();

            if (request.Filters.Any())
            {
                var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                data      = khu_vuc.GetCRM_Location_Alias(where, "ma_khu_vuc DESC");
            }
            else
            {
                data = khu_vuc.GetCRM_Location_Alias("1=1", "ma_khu_vuc DESC");
            }
            return(Json(data.ToDataSourceResult(request)));
        }
Beispiel #12
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <DC_Telesales_ResultList>();
         if (request.Filters.Any())
         {
             var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             data      = dbConn.Select <DC_Telesales_ResultList>("SELECT * FROM DC_Telesales_ResultList WHERE " + where).OrderBy(p => p.SubId).ToList();
         }
         else
         {
             data = dbConn.Select <DC_Telesales_ResultList>().OrderBy(p => p.Id).ToList();
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #13
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <DC_Telesales_QuestionList>();
         if (request.Filters.Any())
         {
             var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             data      = dbConn.Select <DC_Telesales_QuestionList>(where);
         }
         else
         {
             data = dbConn.Select <DC_Telesales_QuestionList>();
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #14
0
 public ActionResult TeleSale_Announcement_Read([DataSourceRequest] DataSourceRequest request, string UserName)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <DC_TeleSale_AnnouncementByCS>();
         if (request.Filters.Any())
         {
             var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             data      = dbConn.Select <DC_TeleSale_AnnouncementByCS>("SELECT * FROM DC_TeleSale_AnnouncementByCS");
         }
         else
         {
             data = dbConn.Select <DC_TeleSale_AnnouncementByCS>("SELECT * FROM DC_TeleSale_AnnouncementByCS");
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #15
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         var    dbConn         = Helpers.OrmliteConnection.openConn();
         string whereCondition = "";
         if (request.Filters.Count > 0)
         {
             whereCondition = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
         }
         var data = dbConn.Select <CRM_Debit_Management>(whereCondition);
         return(Json(data.ToDataSourceResult(request)));
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         var dbConn = Helpers.OrmliteConnection.openConn();
         var data   = new List <CRM_CategoryHierarchy>();
         if (request.Filters.Any())
         {
             var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             data      = dbConn.Select <CRM_CategoryHierarchy>(where + " Order by ID DESC");
         }
         data = dbConn.Select <CRM_CategoryHierarchy>();
         return(Json(data.ToDataSourceResult(request)));
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
Beispiel #17
0
        public ActionResult ReadStatement([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                if (accessDetail.xem)
                {
                    var data   = new DataSourceResult();
                    var strsql = @" SELECT * FROM (SELECT d.*, d.don_gia_vat * d.so_luong AS thanh_tien, b.dia_chi as dia_chi_don_vi
                                                    FROM StatementHeader h
                                                    INNER JOIN StatementDetail d
                                                    ON h.ma_phieu = d.ma_phieu_header
                                                    LEFT JOIN dbo.Vendor v
                                                    ON  d.ma_nha_cung_cap = v.nha_cung_cap_id
                                                    INNER JOIN Branch b
													on d.ma_chi_nhanh=b.ma_chi_nhanh
													and d.ma_don_vi=b.ma_don_vi
                                                    WHERE ISNULL(d.ma_don_dat_hang,'') = ''
                                    ) data ";

                    string whereCondition = "";

                    if (request.Filters != null)
                    {
                        if (request.Filters.Count != 0)
                        {
                            whereCondition = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                        }
                        else
                        {
                            whereCondition = " 1 = 0 ";
                        }
                    }
                    else
                    {
                        whereCondition = " 1 = 0 ";
                    }

                    data = KendoApplyFilter.KendoDataByQuery <StatementDetail>(request, strsql, whereCondition);
                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
Beispiel #18
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <Group>();
         if (accessDetail.xem)
         {
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 data      = dbConn.Query <Group>(where).ToList();
             }
             else
             {
                 data = dbConn.Select <Group>().ToList();
             }
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #19
0
 public ActionResult District_Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <CRM_Location_District>();
         if (request.Filters.Any())
         {
             var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "data.");
             data      = CRM_Location_District.GetCRM_Location_Districts(where, "DistrictID DESC");
         }
         else
         {
             data = CRM_Location_District.GetCRM_Location_Districts("1=1", "DistrictID DESC");
         }
         var a = new DataSourceResult();
         a.Data  = data;
         a.Total = data.Count();
         return(Json(a));
     }
 }
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         if (accessDetail.xem)
         {
             var WhereCondition = "";
             if (request.Filters != null)
             {
                 if (request.Filters.Count > 0)
                 {
                     WhereCondition = " AND " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 }
             }
             var data = dbConn.SqlList <ReportQualityService>("EXEC p_Get_ReportQualityService '1','200',@WhereCondition", new { WhereCondition = WhereCondition });
             return(Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new List <Users>();
         if (asset.View)
         {
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 data      = dbConn.Query <Users>(where + " AND IsAppUser = 1").ToList();
             }
             else
             {
                 data = dbConn.Select <Users>("IsAppUser = 1").ToList();
             }
         }
         return(Json(data.ToDataSourceResult(request)));
     }
 }
Beispiel #22
0
        public ActionResult ReadPYC([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                if (accessDetail.xem)
                {
                    var data   = new DataSourceResult();
                    var strsql = @" SELECT * FROM (SELECT pod.*, h.ma_don_vi, h.ma_chi_nhanh, pod.so_luong_duyet*pod.don_gia_vat as thanh_tien
                                                FROM PRequestHeader h
                                                INNER JOIN PRequestDetail pod
                                                ON h.ma_phieu = pod.ma_phieu
                                                LEFT JOIN dbo.Branch d
                                                ON h.ma_chi_nhanh = d.ma_chi_nhanh
                                                WHERE ISNULL(pod.ma_to_trinh,'') = ''
                                                 AND h.trang_thai={0}
                                    ) data WHERE 1 = 1 ".Params(AllConstant.TRANGTHAI_DA_DUYET);

                    string whereCondition = "";

                    if (request.Filters != null)
                    {
                        if (request.Filters.Count != 0)
                        {
                            whereCondition = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                        }
                    }

                    //data = KendoApplyFilter.KendoDataByQuery<PRequestDetail>(request, strsql, whereCondition);
                    //var data = dbConn.SqlList<PORequestDetail>("EXEC p_get_PO_CreateStatement @WhereCondition", new { WhereCondition =  whereCondition });
                    var lstResult = dbConn.SqlList <PRequestDetail>(strsql + whereCondition);
                    lstResult.ForEach(s => {
                        if (!string.IsNullOrEmpty(s.ma_san_pham_thay_the))
                        {
                            s.ma_san_pham = s.ma_san_pham_thay_the;
                        }
                    });
                    return(Json(lstResult.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
Beispiel #23
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         if (accessDetail.xem)
         {
             //var data = new List<User>();
             var WhereCondition = "";
             if (request.Filters != null)
             {
                 if (request.Filters.Count > 0)
                 {
                     WhereCondition = " AND " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 }
             }
             var data = dbConn.SqlList <UserProductCategory>("EXEC p_Get_UserProductCategory 1,200,@WhereCondition", new { WhereCondition = WhereCondition });
             return(Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
Beispiel #24
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         if (accessDetail.xem)
         {
             var query = @"SELECT S.*, B.ten_chi_nhanh AS ten_don_vi FROM InvoiceHeader S LEFT JOIN Branch B ON S.ma_don_vi=B.ma_chi_nhanh";
             var data  = new DataSourceResult();
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0]);
                 data      = KendoApplyFilter.KendoDataByQuery <InvoiceHeader>(request, query, where);
             }
             else
             {
                 data = KendoApplyFilter.KendoDataByQuery <InvoiceHeader>(request, query, "");
             }
             return(Json(data, JsonRequestBehavior.AllowGet));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
Beispiel #25
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         if (asset.View)
         {
             //string whereCondition = "";
             //if (request.Filters.Count > 0)
             //{
             //    whereCondition = " AND " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             //}
             //var data = new CRM_Contract().GetPage(request, whereCondition);
             //var jsonResult = Json(data, JsonRequestBehavior.AllowGet);
             //jsonResult.MaxJsonLength = int.MaxValue;
             //return jsonResult;
             string where = "";
             if (request.Filters.Count > 0)
             {
                 where = " and " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
             }
             //Debug.Write(DateTime.Now);
             var data = CRM_Contract.GetPage(request.Page, request.PageSize, where);
             //Debug.Write(DateTime.Now);
             request.Page    = 1;
             request.Filters = null;
             var result = data.ToDataSourceResult(request);
             if (data.Rows.Count > 0)
             {
                 result.Total = Convert.ToInt32(data.Rows[0]["RowCount"]);
             }
             var jsonResult = Json(result);
             jsonResult.MaxJsonLength = int.MaxValue;
             return(jsonResult);
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
 public ActionResult Read_DetailAvoidCallingTimeFrame([DataSourceRequest] DataSourceRequest request, string HeaderID)
 {
     if (asset.View)
     {
         using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
         {
             var data = new List <DC_DetailAvoidCallingTimeFrame>();
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 data      = dbConn.Select <DC_DetailAvoidCallingTimeFrame>("SELECT * FROM DC_DetailAvoidCallingTimeFrame Where " + where);
             }
             else
             {
                 data = dbConn.Select <DC_DetailAvoidCallingTimeFrame>("SELECT * FROM DC_DetailAvoidCallingTimeFrame WHERE HeaderID = '" + HeaderID + "'");
             }
             return(Json(data.ToDataSourceResult(request)));
         }
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
Beispiel #27
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data  = new DataSourceResult();
         var query = @"SELECT P.id, P.ma_to_trinh_ncc, P.ten_to_trinh_ncc, P.nha_cung_cap_id, V.ten_nha_cung_Cap, V.dien_thoai, P.so_hop_dong,
                             V.email, V.dia_chi, V.website, P.ngay_ap_dung, P.ngay_ket_thuc, P.trang_thai, P.ghi_chu, P.ngay_bao_gia
                             , p.file_hop_dong, p.file_bao_gia, p.nguoi_tao, p.ngay_tao, p.nguoi_cap_nhat, p.ngay_cap_nhat
                     FROM StatementVendorHeader P LEFT JOIN Vendor V ON P.nha_cung_cap_id = V.nha_cung_cap_id";
         if (accessDetail.xem)
         {
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0]);
                 data      = KendoApplyFilter.KendoDataByQuery <StatementVendorHeader>(request, query, where);
             }
             else
             {
                 data = KendoApplyFilter.KendoDataByQuery <StatementVendorHeader>(request, query, "");
             }
         }
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult ReadData([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         string where = "";
         if (request.Filters.Any())
         {
             where = " where " + KendoApplyFilter.ApplyFilter(request.Filters[0], "");
         }
         var data = CRM_Customer_Debt.ReadData(request.Page, request.PageSize, where);
         request.Page    = 1;
         request.Filters = null;
         var result = data.ToDataSourceResult(request);
         if (data.Rows.Count > 0)
         {
             result.Total = Convert.ToInt32(data.Rows[0]["RowCount"]);
         }
         return(Json(result));
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
 public ActionResult CSDailyNewView_ReadHot([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
         {
             var data = new List <CRM_CS_Daily_New>();
             if (request.Filters.Any())
             {
                 var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "");
                 data      = dbConn.Select <CRM_CS_Daily_New>("SELECT * FROM CRM_CS_Daily_New Where " + where + " AND Hot = 1 AND [Status] = 1 order by Id DESC");
             }
             else
             {
                 data = dbConn.Select <CRM_CS_Daily_New>("SELECT * FROM CRM_CS_Daily_New where Hot = 1 AND [Status] = 1 order by Id DESC ");
             }
             return(Json(data.ToDataSourceResult(request)));
         }
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
Beispiel #30
0
        public ActionResult ReadUserInGroup([DataSourceRequest] DataSourceRequest request, int ma_nhom)
        {
            using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
            {
                if (accessDetail.xem)
                {
                    var data = new List <UserInGroup>();
                    if (request.Filters.Any())
                    {
                        var where = KendoApplyFilter.ApplyFilter(request.Filters[0], "") + " and ma_nhom =" + ma_nhom;
                        data      = dbConn.Select <UserInGroup>(@"
                            select * from(
                                    select 
	                                    u.id,
	                                    u.ma_nguoi_dung,
	                                    u.ten_nguoi_dung, "     +
                                                                ma_nhom + @" as ma_nhom,                                        
	                                    case when uig.id_nhom_nguoi_dung is null then 0 else 1 end as thuoc_nhom, 
                                        u.email,
                                        ISNULL(STUFF ((
                                                Select DISTINCT ',' + a.ma_chi_nhanh
                                                From UsersBranch a
                                                    Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                Where a.ma_nguoi_dung = u.ma_nguoi_dung
                                                For XML Path('') 
                                                ), 1, 1, ''),'') AS ma_chi_nhanh,
                                        ISNULL(STUFF ((
                                                Select DISTINCT ',' + b.ten_chi_nhanh
                                                From UsersBranch a
                                                    Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                Where a.ma_nguoi_dung = u.ma_nguoi_dung
                                                For XML Path('') 
                                                ), 1, 1, ''),'') AS ten_chi_nhanh
                                    from [User] u
                                    left join ( Select * From UserInGroup where id_nhom_nguoi_dung = " + ma_nhom + @") uig on uig.ma_nguoi_dung = u.ma_nguoi_dung 
                                ) data  where " + where);
                    }
                    else
                    {
                        data = dbConn.Select <UserInGroup>(@" select * from(
                                    select 
	                                    u.id,
	                                    u.ma_nguoi_dung,
	                                    u.ten_nguoi_dung, "     +
                                                           ma_nhom + @" as ma_nhom,
	                                    case when uig.id_nhom_nguoi_dung is null then 0 else 1 end as thuoc_nhom, 
                                        u.email,
                                        ISNULL(STUFF ((
                                                Select DISTINCT ',' + a.ma_chi_nhanh
                                                From UsersBranch a
                                                    Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                Where a.ma_nguoi_dung = u.ma_nguoi_dung
                                                For XML Path('') 
                                                ), 1, 1, ''),'') AS ma_chi_nhanh,
                                        ISNULL(STUFF ((
                                                Select DISTINCT ',' + b.ten_chi_nhanh
                                                From UsersBranch a
                                                    Inner Join Branch b ON a.ma_chi_nhanh = b.ma_chi_nhanh
                                                Where a.ma_nguoi_dung = u.ma_nguoi_dung
                                                For XML Path('') 
                                                ), 1, 1, ''),'') AS ten_chi_nhanh
                                    from [User] u
                                    left join ( Select * From UserInGroup where id_nhom_nguoi_dung = " + ma_nhom + @") uig on uig.ma_nguoi_dung = u.ma_nguoi_dung 
                                ) data  where  ma_nhom = " + ma_nhom);
                    }
                    return(Json(data.ToDataSourceResult(request)));
                }
                else
                {
                    return(RedirectToAction("NoAccessRights", "Error"));
                }
            }
        }