Esempio n. 1
0
        public JsonResult GetListStaffs(int staffID)
        {
            try
            {
                StaffData     st   = new StaffData();
                List <Staffs> item = new List <Staffs>();
                item = st.GetStaff(staffID);


                List <StaffRole> item2 = new List <StaffRole>();
                item2 = st.GetListStaffRole(0);


                return(Json(new
                {
                    data = item,
                    dataStaffRole = item2,
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    data = ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public List <ListCustomerOnMobile> GetListCustomerOnMobile(int StaffID)
        {
            StaffData     st   = new StaffData();
            List <Staffs> item = new List <Staffs>();

            item = st.GetStaff(StaffID);
            Staffs staff = new Staffs();

            staff = item.FirstOrDefault();


            List <ListCustomerOnMobile> list    = new List <ListCustomerOnMobile>();
            MySqlConnection             ObjConn = DBHelper.ConnectDb(ref errMsg);

            try
            {
                string sqlStr = @"  SELECT  c.CustomerId,ct.ContractID,CONCAT(c.CustomerTitleName,c.CustomerFirstName,' ',c.CustomerLastName) AS CustomerName
                ,ct.ContractStartDate,ct.ContractPeriod,ct.ContractPayEveryDay,ct.ContractSpecialholiday
                ,ct.ContractNumber,ct.ContractExpDate,ct.ContractAmount,ct.ContractPayment,
                 (ct.ContractPayment-d.TotalPay ) AS TotalPay
                 ,(       SELECT  DATE(DateAsOf) 
                 FROM  daily_receipts  WHERE ContractID=ct.ContractID AND CustomerID=c.CustomerId AND  PriceReceipts>0
                 ORDER BY DateAsOf DESC LIMIT 1) AS lastDate
                 FROM customer c 
                LEFT JOIN contract ct ON c.CustomerId=ct.contractCustomerID
                 LEFT JOIN (SELECT SUM(PriceReceipts)AS TotalPay , ContractID ,CustomerID  
                 FROM  daily_receipts
                 WHERE   Deleted=0
                GROUP BY   ContractID ,CustomerID ) d ON 
                d.ContractID=ct.ContractID AND d.CustomerID=ct.ContractCustomerID 
                WHERE  ct.ContractID IS NOT NULL
                 AND ct.contractstatus=1 and ct.Activated=1 and ct.Deleted=0 and  c.Deleted=0
                 ";


                DataTable dt1 = DBHelper.List("select * FROM staffrolepermission where StaffPermissionID=23 AND StaffRoleID=" + staff.StaffRoleID, ObjConn);

                if (dt1.Rows.Count != 1)
                {
                    sqlStr += "AND c.SaleID=" + StaffID;
                }


                DataTable dt = DBHelper.List(sqlStr, ObjConn);
                if (dt != null && dt.Rows.Count > 0)
                {
                    list = ListCustomerOnMobile.ToObjectList(dt);
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                ObjConn.Close();
            }
        }
Esempio n. 3
0
        public JsonResult GetStaffs(int staffroleId, int zoneId)
        {
            // รับค่าราคา
            StaffData        st   = new StaffData();
            DataTable        dt   = new DataTable();
            List <ListItems> item = new List <ListItems>();

            dt = st.GetStaff(staffroleId, zoneId);
            if (dt.Rows.Count > 0)
            {
                item = dt.AsEnumerable().Select(dr => new ListItems()
                {
                    ID    = dr.Field <int>("StaffID"),
                    Value = dr.Field <string>("StaffTitleName") + dr.Field <string>("StaffFirstName") + " "
                            + dr.Field <string>("StaffLastName"),
                }).ToList();
            }
            return(Json(new
            {
                data = item,
                success = true
            }, JsonRequestBehavior.AllowGet));
        }