コード例 #1
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string strQuery = @"SELECT	oh.*
                                 FROM Deca_Order_Header oh 
                                 LEFT JOIN Deca_Order_CancelTracking ct 
                                 ON oh.OrderID = ct.OrderID 
                                 LEFT JOIN Deca_Bank_Transactions bt 
                                 ON oh.OrderID = bt.OrderID
                                 lEFT JOIN Deca_Order_Detail od
                                 ON oh.OrderID = od.OrderID
                                 LEFT JOIN DC_SKU_Property b 
                                 On od.ProductID = b.productId And od.PriceID = b.productPriceId
                                 Where oh.PaymentStatus = 0
                                 AND (oh.Status = 0 OR oh.Status = 1 OR oh.Status = 2 OR oh.Status = 9)
                                 AND ((b.ISACTIVE = 0) 
                                 OR (b.IsActive = 1 AND od.UnitPrice <> b.sellingprice)
                                 OR (od.PriceID not in(Select productPriceId from DC_SKU_Property ))
                                 OR (od.PriceID IN (Select Distinct c.PKproductpriceID from DecaInsight..DC_OCM_Product_Price c where c.StockOnHand <= 0)))
                                  ";
             data = KendoApplyFilter.KendoDataByQuery <Deca_Order_Header>(request, strQuery, "");
         }
         return(Json(data));
     }
 }
コード例 #2
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            if (asset.View)
            {
                using (IDbConnection dbConn = OrmliteConnection.openConn())
                {
                    string sqlQuery = @"SELECT   req.*
                                                ,SUBSTRING(c_code,3, 10) AS BookCode
                                                ,ISNULL(l.PKBookLocation,0) AS PKBookLocation
                                                ,ISNULL(l.FKBookReq,'') AS FKBookReq
	                                            ,ISNULL(l.Website,'') AS Website
	                                            ,ISNULL(l.Category,'') AS Category
	                                            ,ISNULL(l.Location,'') AS Location
	                                            ,ISNULL(l.Nature,'') AS Nature
	                                            ,ISNULL(l.NgayLen,'') AS NgayLen
	                                            ,ISNULL(l.NgayXuong ,'') AS NgayXuong
                                                ,ISNULL(l.InputDate,'') AS InputDate
	                                            ,ISNULL(l.AccountStatus,'') AS AccountStatus
                                                ,ISNULL(cus.CustomerName,'') AS CustomerName
                                        FROM CRM_Book_Req req
                                        INNER JOIN  CRM_Book_Location l on l.FKBookReq = req.pk_book_req
                                        LEFT JOIN  ERPAPD_Customer cus on cus.CustomerCode = req.c_customer_code
                                       ";

                    return(Json(KendoApplyFilter.KendoDataByQuery <BookBannerViewModel>(request, sqlQuery, "")));
                }
            }
            else
            {
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #3
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                var    data = new DataSourceResult();
                string str  = @"
                        select 
	                        b.ten_chi_nhanh
	                        ,h.nam_ke_hoach
	                        ,isnull(d.so_luong_du_kien, 0) so_luong_du_kien
	                        ,isnull(d.ten_san_pham, '') ten_san_pham
	                        ,isnull(d.total_tien_du_kien, 0) total_tien_du_kien
	                        ,isnull(d.ke_hoach_nam_truoc, 0) ke_hoach_nam_truoc
	                        ,isnull(d.thuc_hien_nam_truoc, 0) thuc_hien_nam_truoc
	                        ,isnull(d.chech_lech, 0) chech_lech
                        from PlanHeader h 
                        left join Branch b on b.ma_chi_nhanh = h.don_vi_phu_trach
                        left join (
	                        select
		                        d.nam_ke_hoach
		                        ,p.ten_san_pham
		                        ,sum(so_luong_du_kien) as so_luong_du_kien
		                        ,sum(total_tien_du_kien) as total_tien_du_kien
		                        ,sum(ke_hoach_nam_truoc) as ke_hoach_nam_truoc
		                        ,sum(thuc_hien_nam_truoc) as thuc_hien_nam_truoc
		                        ,sum(chech_lech) as chech_lech
	                        from PlanDetail d 
	                        left join Product p on p.id = d.ma_san_pham
	                        group by ten_san_pham, nam_ke_hoach
                        ) d on d.nam_ke_hoach = h.id
                    ";
                data = KendoApplyFilter.KendoDataByQuery <ReportPlan>(request, str, "");
                return(Json(data));
            }
        }
コード例 #4
0
        public ActionResult PaymentProccessRead([DataSourceRequest] DataSourceRequest request)
        {
            string strQuery = @"SELECT pa.* ,
                 c.c_customer_code AS c_customer_code,
                 c.c_code AS c_contract_code,
                 cu.CustomerName as c_customer_name,
                 ca.c_ngay_du_kien_thu as c_ngay_du_kien_thu,
                 ca.c_ngay_tt_theo_hd as c_ngay_tt_theo_hd,
                 pp.Note as c_ghi_chu,
                 pp.PaymentForm as c_payment_form,
                 pp.NumberReceipt as c_number_receipt,
                 li.Name AS c_bank_name, 
 
                 DATEDIFF(day,ca.c_ngay_du_kien_thu,pa.c_ngay_thanh_toan)  AS c_so_ngay_qua_han,
                 (CASE WHEN DATEDIFF(day,GETDATE(),ca.c_ngay_du_kien_thu) > 0 THEN 2 
                 ELSE (CASE 
		                WHEN DATEDIFF(day,DateAdd(DD,-5,GETDATE()),ca.c_ngay_du_kien_thu) < 0 THEN 4 
		                WHEN DATEDIFF(day,DateAdd(DD,-5,GETDATE()),ca.c_ngay_du_kien_thu) >= 0 THEN 3 END)
		                 END)
		                 as c_trang_thai_no
                 FROM CRM_Payment pa
                 LEFT JOIN CRM_PaymentProgress pp ON pp.PKPayment = pa.c_ma_thanh_toan 
                 LEFT JOIN CRM_GET_MONEY_MONTH_NEXT ca ON ca.pk_gmoney_next = pa.c_ma_lich_thanh_toan 
                 LEFT JOIN CRM_Contract c ON c.pk_contract = pa.c_ma_hop_dong
                 LEFT JOIN ERPAPD_Customer cu ON cu.CustomerCode = c.c_customer_code
                 LEFT JOIN ERPAPD_List li ON li.Code = pp.BankCode";
            var    data     = KendoApplyFilter.KendoDataByQuery <CRM_Payment>(request, strQuery, "");

            return(Json(data));
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            using (IDbConnection dbConn = OrmliteConnection.openConn())
            {
                var data = new DataSourceResult();

                if (asset.View)
                {
                    string strQuery = @"SELECT  cus.*
                                               ,ISNULL(ps1.Value,'N/A') AS StatusName
                                               ,ISNULL(source.Value,'N/A') AS SourceName
                                               ,ISNULL(ps2.Value,'N/A') AS TypeName
                                               ,ISNULL(emp.Name,'N/A') AS EmployeeName
                                               ,ISNULL(team.TeamName,'N/A') AS TeamName
                                               ,ISNULL(unit.Value,'N/A') AS RegionName
                                        FROM ERPAPD_Customer cus
                                        LEFT JOIN [Parameters] ps1 ON ps1.ParamID = cus.Status AND ps1.Type = 'CustomerStatus'
                                        LEFT JOIN [Parameters] source ON source.ParamID = cus.Source AND source.Type = 'CustomerSource'
                                        LEFT JOIN [ERPAPD_MasterData_Customer] ps2 ON ps2.Code = cus.CustomerType AND ps2.Type = 'CustomerType'
                                        LEFT JOIN [ERPAPD_Employee] emp ON cus.StaffId = emp.RefEmployeeID 
                                        LEFT JOIN [CRM_Team] team ON team.TeamID = cus.GroupId 
                                        LEFT JOIN [CRM_Hierarchy] unit ON unit.HierarchyID = cus.UnitId 
                                        ";
                    data = KendoApplyFilter.KendoDataByQuery <ERPAPD_Customer>(request, strQuery, "");

                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #7
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                var    data = new DataSourceResult();
                string str  = @"
                        SELECT 
	                        d.id
	                        , h.ma_phieu
	                        , h.ma_chi_nhanh
	                        , h.ten_phieu
	                        , h.ngay_tao_yeu_cau

                            , h.y_kien_cua_don_vi
                            , h.ngay_duyet_TDV
                            , h.nguoi_duyet_TDV

                            , h.y_kien_HCQT
                            , h.ngay_duyet_HCQT
                            , h.nguoi_duyet_HCQT

                            , h.y_kien_TTCNTT_NHDT
                            , h.ngay_duyet_TTCNTT_NHDT
                            , h.nguoi_duyet_TTCNTT_NHDT

                            , h.y_kien_QLDVKH_NQT
                            , h.ngay_duyet_QLDVKH_NQT
                            , h.nguoi_duyet_QLDVKH_NQT

                            , h.y_kien_khac_HO
                            , h.ngay_duyet_khac_HO
                            , h.nguoi_duyet_khac_HO

	                        , d.ma_san_pham
	                        , d.so_luong
	                        , d.ma_nha_cung_cap
	                        , d.don_gia_vat
	                        , d.thong_so_ky_thuat
	                        , d.chuc_danh_nguoi_su_dung
	                        , d.ke_hoach_nam
	                        , d.trang_thai
                        FROM PRequestHeader h
                        INNER JOIN PRequestDetail d
                        ON h.ma_phieu = d.ma_phieu
                    ";

                if (request.Sorts == null)
                {
                    request.Sorts = new List <Kendo.Mvc.SortDescriptor>();
                }
                request.Sorts.Add(new Kendo.Mvc.SortDescriptor("ma_phieu", System.ComponentModel.ListSortDirection.Ascending));

                if (request.Filters == null)
                {
                    request.Filters = new List <Kendo.Mvc.IFilterDescriptor>();
                }
                data = KendoApplyFilter.KendoDataByQuery <ReportPR>(request, str, "");
                return(Json(data));
            }
        }
コード例 #8
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            using (IDbConnection dbConn = OrmliteConnection.openConn())
            {
                var data = new DataSourceResult();

                if (asset.View)
                {
                    string strQuery = @"SELECT  product.*
                                                ,ISNULL(ProductType.Name,'') AS ProductTypeName
	                                            ,ISNULL(pageType.Name,'') AS PageTypeName
	                                            ,ISNULL(webSite.Name,'') AS WebsiteName
	                                            ,ISNULL(cate.Name,'') AS CategoryName
	                                            ,ISNULL(location.Name,'') AS LocationName
	                                            ,ISNULL(nature.Name,'') AS NatureName
                                        FROM [ERPAPD_Product] product
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 19 
                                        ) productType On productType.Code = product.ProductType
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 20 
                                        ) webSite On webSite.Code = product.Website
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 21 
                                        ) pageType On pageType.Code = product.PageType
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 22 
                                        ) cate On cate.Code = product.Category
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 23 
                                        ) location On location.Code = product.Location
                                        LEFT JOIN 
                                        (
	                                        SELECT a.Code,a.Name
	                                        FROM [ERPAPDDev].[dbo].[ERPAPD_List] a
	                                        INNER JOIN [ERPAPDDev].[dbo].[ERPAPD_ListType] b on b.PKListType = a.FKListtype AND b.PKListType = 25 
                                        ) nature On nature.Code = product.Nature
                                        ";
                    data = KendoApplyFilter.KendoDataByQuery <ERPAPD_Product>(request, strQuery, "");
                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #9
0
        public ActionResult HistoryRemindRead([DataSourceRequest] DataSourceRequest request, string CustomerCode, string Type)
        {
            string strQuery = @"SELECT d.*, (select Top 1 FullName from EmployeeInfo where RefStaffId = d.StaffID) AS StaffName 
                    FROM CRM_Debt_History d
                WHERE d.CustomerCode = '" + CustomerCode + "' AND d.Type = '" + Type + "'";
            var    data     = KendoApplyFilter.KendoDataByQuery <CRM_Debt_History>(request, strQuery, "");

            return(Json(data));
        }
コード例 #10
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var    data     = new DataSourceResult();
         string sqlquery = @"select a.*,b.ten_website, c.hashtagname from cms_PostNotify a left join cms_Websites b on a.ma_website=b.ma_website left join Hashtag c on a.hashtagcode=c.hashtagcode";
         data = KendoApplyFilter.KendoDataByQuery <cms_PostNotify>(request, sqlquery, "");
         return(Json(data));
     }
 }
コード例 #11
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var    data     = new DataSourceResult();
         string sqlquery = @"select a.*,b.ten_website,c.ten_chuyen_muc,d.ten_vi_tri,e.ngay_gio_xuat_ban,e.ghi_chu from cms_News a left join cms_Websites b on a.ma_website=b.ma_website left join cms_Categorys c on a.ma_chuyen_muc=c.ma_chuyen_muc left join cms_Positions d on a.ma_vi_tri=d.ma_vi_tri left join cms_Schedule_News e on a.ma_bai_viet=e.ma_bai_viet";
         data = KendoApplyFilter.KendoDataByQuery <cms_News>(request, sqlquery, "");
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #12
0
        public ActionResult WorksRead([DataSourceRequest] DataSourceRequest request, string status)
        {
            string strQuery = @"SELECT * FROM (SELECT w.*,p.Value as TypeName,c.CustomerName as CustomerName,e.Name as EmName,e.Email as EmEmail  
                FROM CRM_Works w 
                LEFT JOIN Parameters p ON w.Type = p.ParamID 
                LEFT JOIN ERPAPD_Customer c ON w.CustomerID = c.CustomerID  
                LEFT JOIN ERPAPD_Contacts e ON w.Person_contact = e.PKContactID   
                WHERE w.RowCreatedUser = '******' AND w.Status = '" + status + "' ) A ";
            var    data     = KendoApplyFilter.KendoDataByQuery <CRM_Works>(request, strQuery, "");

            return(Json(data));
        }
コード例 #13
0
 public ActionResult ReadOrderDetail([DataSourceRequest] DataSourceRequest request, string ma_don_hang, string ma_gian_hang)
 {
     if (accessDetail != null && (accessDetail.access["all"] || (accessDetail.access["view"] && accessDetail.access["create"] && accessDetail.access["update"])))
     {
         using (var dbConn = MCC.Helpers.OrmliteConnection.openConn(AppConfigs.MCCConnectionString))
         {
             var data = new DataSourceResult();
             data = KendoApplyFilter.KendoDataByQuery <Merchant_OrderDetail>(request, "select a.*,ISNULL(b.book_available,0) as book_available from Merchant_OrderDetail a left join Merchant_Product_Warehouse b on a.ma_san_pham=b.ma_san_pham and a.ma_gian_hang=b.ma_gian_hang where a.ma_don_hang={0} and a.ma_gian_hang={1}".Params(ma_don_hang, ma_gian_hang), "");
             return(Json(data, JsonRequestBehavior.AllowGet));
         }
     }
     return(RedirectToAction("NoAccess", "Error"));
 }
コード例 #14
0
 public ActionResult ReadDetail([DataSourceRequest] DataSourceRequest request, long pkbook = 0)
 {
     if (asset.View)
     {
         using (IDbConnection dbConn = OrmliteConnection.openConn())
         {
             return(Json(KendoApplyFilter.KendoDataByQuery <CRM_BookPR_Location>(request, strQueryPRDetail(pkbook), "")));
         }
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #15
0
 public ActionResult Contract_Extra_Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string strQuery = @"SELECT * FROM CRM_Contract_Extra";
             data = KendoApplyFilter.KendoDataByQuery <CRM_Contract_Extra>(request, strQuery, "");
             return(Json(data));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #16
0
        public ActionResult AppointmentRead([DataSourceRequest] DataSourceRequest request)
        {
            //string value = "RowCreatedUser = '******' AND Status = 'YET'";

            string strQuery = @"SELECT * FROM (SELECT a.*,co.Name as Name,c.CustomerName as CustomerName  FROM CRM_Appointment a 
                LEFT JOIN ERPAPD_Customer c ON a.CustomerID = c.CustomerID  
                LEFT JOIN ERPAPD_Contacts co ON co.PKContactID = a.Person_contact
                WHERE a.RowCreatedUser = '******' AND a.Status = 'YET' AND DATEDIFF(d,GETDATE(),date) >= 0) A ";

            var data = KendoApplyFilter.KendoDataByQuery <CRM_Appointment>(request, strQuery, "");

            //var data = KendoApplyFilter.KendoData<CRM_Appointment>(request, value + "AND Date > GETDATE()");
            return(Json(data));
        }
コード例 #17
0
 public ActionResult BookPRBao_ReadByBookCode([DataSourceRequest] DataSourceRequest request, string type, string bookcode)
 {
     if (asset.View)
     {
         using (IDbConnection dbConn = OrmliteConnection.openConn())
         {
             return(Json(KendoApplyFilter.KendoDataByQuery <CRM_BookPRLocation>(request, strQueryPRBookCode(type, bookcode), "")));
         }
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #18
0
        public ActionResult ReadStockIn([DataSourceRequest] DataSourceRequest request)
        {
            if (accessDetail != null && (accessDetail.access["all"] || accessDetail.access["view"]))
            {
                using (var db = MCC.Helpers.OrmliteConnection.openConn(AppConfigs.MCCConnectionString))
                {
                    var data = KendoApplyFilter.KendoDataByQuery <Merchant_Stock_ViewModel>(request, @"select * from (
                                                                    select 
	                                                                    a.ma_phieu_nhap_kho as ma_phieu, 
	                                                                    ISNULL(b.ten_kho,'') as ten_kho, 
                                                                        ISNULL(b.ma_kho,'') as ma_kho, 
	                                                                    a.ma_don_hang, 
	                                                                    a.ngay_nhap_kho as ngay_nhap_xuat,
	                                                                    a.thu_kho, 
	                                                                    a.nguoi_giao as nguoi_giao_nhan,
	                                                                    a.nguoi_kiem_tra,
	                                                                    a.ngay_tao,
	                                                                    a.nguoi_tao, 
	                                                                    a.dia_diem,
	                                                                    a.trang_thai, 
                                                                        a.ghi_chu,          
	                                                                    'GRN' as loai_phieu from Merchant_StockInHeader a left join Merchant_WareHouse b
                                                                    on a.ma_kho = b.ma_kho
                                                                        where a.ma_gian_hang = {0}
                                                                    union all
                                                                    select 
	                                                                    a.ma_phieu_xuat_kho as ma_phieu, 
	                                                                    ISNULL(b.ten_kho,'') as ten_kho, 
                                                                        ISNULL(b.ma_kho,'') as ma_kho, 
	                                                                    a.ma_don_hang, 
	                                                                    a.ngay_xuat_kho as ngay_nhap_xuat,
	                                                                    a.thu_kho, 
	                                                                    a.nguoi_nhan as nguoi_giao_nhan,
	                                                                    a.nguoi_xuat as nguoi_kiem_tra,
	                                                                    a.ngay_tao,
	                                                                    a.nguoi_tao,
                                                                        a.dia_diem,     
	                                                                    a.trang_thai, 
                                                                        a.ghi_chu,          
	                                                                    'GDN' as loai_phieu from Merchant_StockOutHeader a left join Merchant_WareHouse b
                                                                    on a.ma_kho = b.ma_kho
                                                                        where a.ma_gian_hang = {0}
                                                                    ) as u
                                                                    ".Params(currentUser.ma_gian_hang), "");
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }
            return(RedirectToAction("NoAccess", "Error"));
        }
コード例 #19
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = Helpers.OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string query = @"Select
                                        cu.CustomerID
                                        ,cu.FullName
                                        ,case when cu.Gender = 1 then N'Nam' when cu.Gender = 0 then N'Nữ' else '' end as Gender
                                        ,case when cu.Birthday ='0000-00-00' then '1900-01-01' else cu.Birthday end as Birthday
                                        ,case when cu.StandardMobilePhone = '' then cu.MobilePhone else cu.MobilePhone end as MobilePhone
                                        ,cu.Email
                                        ,cu.ContactAddress
                                        ,isnull(di.TerritoryName,'') as District
                                        ,isnull(pr.TerritoryName,'') as Province 
                                        ,cu.RegisteredDate
                                        ,case when cu.FisrtOrderDate ='0000-00-00 00:00:00' then '1900-01-01' else cu.FisrtOrderDate end as FisrtOrderDate
                                        ,isnull(ord.LastOrderDate,'1900-01-01') as LastOrderDate
                                        ,isnull(ord.OrderNumber,0) as OrderNumber
                                        ,isnull(sv.LastOfSurvey,'1900-01-01') as LastOfSuvey
                                        ,isnull(sv.SurveyTime,0) as SurveyTime
                                 from [dbo].[DC_OCM_Customer] cu
                                 left join DC_OCM_Territory pr on pr.TerritoryID = cu.FKProvince and pr.[Level] = 'Province'
                                 left join DC_OCM_Territory di on di.TerritoryID = cu.FKDistrict and di.[Level] = 'District'
                                 left join (
                                        Select 
                                               CustomerID
                                               ,max(CreatedAt) as LastOfSurvey
                                               ,count(distinct SurveyManagementID) as SurveyTime
                                        from DC_Survey_Management_Proceeded
                                        where [Source] = 'ocmcustomer' and CustomerID IS NOT NULL
                                        group by CustomerID
                                 )sv on sv.CustomerID = cu.CustomerID
                                 left join(
                                        Select 
                                               FKCustomerID as CustomerID
                                               ,Max(CreatedDate) as LastOrderDate
                                               ,count(distinct OrderID) as OrderNumber
                                        from DC_OCM_Order
                                        Group by FKCustomerID
                                 )ord on ord.CustomerID = cu.CustomerID
                                 ";
             data = KendoApplyFilter.KendoDataByQuery <Deca_OCMCustomer>(request, query, "");
         }
         return(Json(data));
     }
 }
コード例 #20
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string strQuery = @"Select distinct * from CRM_Sync_Log";
             data            = KendoApplyFilter.KendoDataByQuery <CRM_Sync_Log>(request, strQuery, "");
             request.Filters = null;
             return(Json(data));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #21
0
        public ActionResult Position_Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = new DataSourceResult();

            if (asset.View)
            {
                string strQuery = @"SELECT  * FROM CRM_Position";
                data = KendoApplyFilter.KendoDataByQuery <CRM_Position>(request, strQuery, "");
                return(Json(data));
            }
            else
            {
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #22
0
        public ActionResult CRMContactList_Read([DataSourceRequest] DataSourceRequest request, string CustomerID)
        {
            using (IDbConnection dbConn = OrmliteConnection.openConn())
            {
                var data = new DataSourceResult();
                if (asset.View)
                {
                    string strQuery = @"SELECT * FROM  [ERPAPD_Contacts] WHERE CustomerID = '" + CustomerID + "'";

                    data = KendoApplyFilter.KendoDataByQuery <ERPAPD_Contacts>(request, strQuery, "");
                    //data = KendoApplyFilter.KendoData<ERPAPD_Contacts>(request);
                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #23
0
 public ActionResult CRMContactList_Read([DataSourceRequest] DataSourceRequest request, string CustomerID)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string strQuery = @"SELECT co.*,cus.CustomerName AS CustomerName FROM  ERPAPD_Contacts co 
             LEFT JOIN ERPAPD_Customer cus ON cus.CustomerID = co.CustomerID where FKCustomer='" + CustomerID + "'";
             data            = KendoApplyFilter.KendoDataByQuery <ERPAPD_Contacts>(request, strQuery, "");
             request.Filters = null;
             return(Json(data));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #24
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         var    dbConn   = Helpers.OrmliteConnection.openConn();
         var    data     = new DataSourceResult();
         string strQuery = @"SELECT * FROM [ERPAPD_Employee]";
         data = KendoApplyFilter.KendoDataByQuery <ERPAPD_Employee>(request, strQuery, "");
         //data = dbConn.Select<ERPAPD_Employee>("SELECT * FROM ERPAPD_Employee ORDER BY RowID DESC");
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #25
0
        public ActionResult BookPRBao_Read([DataSourceRequest] DataSourceRequest request, string type)
        {
            if (asset.View)
            {
                using (IDbConnection dbConn = OrmliteConnection.openConn())
                {
                    string strQuery = strQueryPRBao(type);

                    return(Json(KendoApplyFilter.KendoDataByQuery <CRM_BookPR_View>(request, strQuery, "")));
                }
            }
            else
            {
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #26
0
        public ActionResult PaymentDetailRead([DataSourceRequest] DataSourceRequest request, Int32 pk_contract)
        {
            string strQuery = @"SELECT c_ngay_tt_theo_hd
              ,c_tien_tt_theo_hd
              ,c_ngay_du_kien_thu
              ,c_tien_du_kien_thu
              ,c_status
              ,DATEDIFF(day,GETDATE(),c_ngay_du_kien_thu)  AS c_so_ngay_qua_han
              ,ISNULL((SELECT sum(c_tien_thanh_toan) FROM CRM_Payment WHERE a.pk_gmoney_next = c_ma_lich_thanh_toan),0) AS c_tien_thanh_toan
              ,a.c_tien_du_kien_thu - ISNULL((SELECT sum(c_tien_thanh_toan) FROM CRM_Payment WHERE a.pk_gmoney_next = c_ma_lich_thanh_toan),0) AS c_tien_con_no
              ,a.c_trang_thai_tt
            FROM  CRM_GET_MONEY_MONTH_NEXT a
            WHERE fk_contract =" + pk_contract;
            var    data     = KendoApplyFilter.KendoDataByQuery <CRM_GET_MONEY_MONTH_NEXT>(request, strQuery, "");

            return(Json(data));
        }
コード例 #27
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     using (IDbConnection dbConn = OrmliteConnection.openConn())
     {
         var data = new DataSourceResult();
         if (asset.View)
         {
             string strQuery = @"SELECT   cs.*       
                                 FROM [ERPAPD_MasterData_Customer] cs
                                 WHERE Type = 'TypeOfBusiness'
                                  ";
             data = KendoApplyFilter.KendoDataByQuery <ERPAPD_MasterData_Customer>(request, strQuery, "");
             return(Json(data));
         }
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
コード例 #28
0
 public ActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
     if (asset.View)
     {
         var    dbConn   = Helpers.OrmliteConnection.openConn();
         var    data     = new DataSourceResult();
         string strQuery = @"SELECT * FROM [DC_Article]";
         data = KendoApplyFilter.KendoDataByQuery <DC_Article>(request, strQuery, "");
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
     // var data = DC_Article.GetAllDC_Articles();
     // return Json(data.ToDataSourceResult(request));
 }
コード例 #29
0
        public ActionResult CRM_PageCategory_Read([DataSourceRequest] DataSourceRequest request)
        {
            using (IDbConnection dbConn = OrmliteConnection.openConn())
            {
                var data = new DataSourceResult();
                if (asset.View)
                {
                    string strQuery = @"SELECT c.*,w.WebsiteName as WebsiteName,w1.Value as TypeName
                      FROM CRM_PageCategory c
                      LEFT JOIN CRM_Website w ON w.WebsiteID = c.WebsiteID
					  LEFT JOIN Parameters w1 ON w1.ParamID = c.Type"                    ;
                    data = KendoApplyFilter.KendoDataByQuery <CRM_PageCategory>(request, strQuery, "");
                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }
コード例 #30
0
        public ActionResult CRM_PagePosition_Read([DataSourceRequest] DataSourceRequest request)
        {
            using (IDbConnection dbConn = OrmliteConnection.openConn())
            {
                var data = new DataSourceResult();
                if (asset.View)
                {
                    string strQuery = @"SELECT p.*,
                   (SELECT value FROM Parameters WHERE ParamID = p.ShareNumber) AS ShareName,
                   (SELECT value FROM Parameters WHERE ParamID = p.Size) AS SizeName,
				   (Select WebsiteName From CRM_Website Where RefID = p.WebsiteRefID) AS WebsiteName
                   FROM CRM_PagePosition p";
                    data = KendoApplyFilter.KendoDataByQuery <CRM_PagePosition>(request, strQuery, "");
                    return(Json(data));
                }
                return(RedirectToAction("NoAccessRights", "Error"));
            }
        }