예제 #1
0
        /// <summary>
        /// Retrives the company or division Sale Products.
        /// searchword parameter is empty, returns all sale products.
        /// searchword parameter length is >0, retruns the relevant products.
        /// </summary>
        /// <param name="searchword"></param>
        /// <returns></returns>
        public JsonResult GetSaleProducts(string searchword)
        {
            DataSet dsSaleProducts = new DataSet();

            // Execute the Query and returns the DataSet.
            string companyCode = _objcurrentInfo.GetCompanyCode();
            string userCode    = _objcurrentInfo.GetCompanyCode();

            dsSaleProducts = _objSPData.GetSaleProducts(companyCode, userCode);
            List <DCRProductDetailsModel> lstSaleProducts = new List <DCRProductDetailsModel>();

            if (dsSaleProducts != null && dsSaleProducts.Tables.Count > 0)
            {
                DataTable dtSaleProducts = dsSaleProducts.Tables[0];
                // Convert the DataTable to list.
                lstSaleProducts = (from Products in dtSaleProducts.AsEnumerable()
                                   select new DCRProductDetailsModel
                {
                    label = Products["Product_Name"].ToString(),
                    value = Products["Product_Code"].ToString()
                }).ToList <DCRProductDetailsModel>();
            }
            // returns the list.
            _totalListCount = lstSaleProducts.Count;
            return(Json(lstSaleProducts, JsonRequestBehavior.AllowGet));
        }