//public ActionResult AjaxMethod_CustOldBill(string custNM)
        //{
        //    KeystoneProject.Buisness_Logic.Pharmacy.BL_PatientMedicalBill BL_obj = new BL_PatientMedicalBill();
        //    KeystoneProject.Models.Pharmacy.PatientMedicalBill obj = new PatientMedicalBill();
        //    List<PatientMedicalBill> searchList = new List<PatientMedicalBill>();

        //    DataTable dt = new DataTable();
        //    DataSet ds = BL_obj.BindCustID(custNM);
        //    dt = BL_obj.GetOldBill(Convert.ToInt16(ds.Tables[0].Rows[0]["CustomerID"].ToString()));

        //    foreach (DataRow dr in dt.Rows)
        //    {
        //        searchList.Add(
        //            new PatientMedicalBill
        //            {
        //                BillNo = Convert.ToString(dr["BillNo"]),
        //            });
        //    }

        //    return new JsonResult { Data = searchList, JsonRequestBehavior = JsonRequestBehavior.AllowGet };


        //}

        public ActionResult AjaxMethod_batchno(string prodnm)
        {
            KeystoneProject.Buisness_Logic.Pharmacy.BL_PatientMedicalBill BL_obj = new BL_PatientMedicalBill();
            KeystoneProject.Models.Pharmacy.PatientMedicalBill            obj    = new PatientMedicalBill();
            List <PatientMedicalBill> searchList = new List <PatientMedicalBill>();

            DataTable dt  = new DataTable();
            DataSet   ds1 = BL_obj.BindProductName(prodnm);

            int ProductID = Convert.ToInt16(ds1.Tables[0].Rows[0]["ProductID"].ToString());

            DataSet ds = BL_obj.GetMedicalBillForProductStock(ProductID);

            List <PatientMedicalBill> obj1 = new List <Models.Pharmacy.PatientMedicalBill>();

            if (ds.Tables[0].Rows.Count > 0)
            {
                Connect();
                SqlCommand cmd = new SqlCommand("select  ProductDetailsID ,BatchNo,ExpiryDate,SalesRate,CurrentStock ,CurrentStock1, PurchaseRate,MRP  from ProductDetails left join Product  on  Product .ProductID = ProductDetails.ProductID where Product.HospitalID = " + HospitalID + " and Product.LocationID = " + LocationID + " and CurrentStock > 0  and Convert(varchar(10),ExpiryDate,120) > (GETDATE()) and ProductDetails.ProductID =" + ProductID + "  and ProductDetails.RowStatus = 0 order by ExpiryDate asc", con);
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                con.Close();
            }
            else
            {
                Connect();
                SqlCommand cmd = new SqlCommand("select  ProductDetailsID ,BatchNo,ExpiryDate,SalesRate,CurrentStock ,CurrentStock1, PurchaseRate,MRP,SalesRate  from ProductDetails left join Product  on  Product .ProductID = ProductDetails.ProductID where Product.HospitalID = " + HospitalID + " and Product.LocationID = " + LocationID + " and  Convert(varchar(10),ExpiryDate,120) > (GETDATE()) and ProductDetails.ProductID =" + ProductID + "  and ProductDetails.RowStatus = 0 order by ExpiryDate asc", con);
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                con.Close();
            }
            string color = "";

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string date = Convert.ToDateTime(dr["ExpiryDate"]).AddDays(-90).ToString();
                if (Convert.ToDateTime(DateTime.Now) > Convert.ToDateTime(date))
                {
                    color = "#90EE90";
                }
                else
                {
                    color = "#D3D3D3";
                }
                obj1.Add(new Models.Pharmacy.PatientMedicalBill
                {
                    ProductDetailsID = dr["ProductDetailsID"].ToString(),
                    batchNumber      = dr["BatchNo"].ToString(),
                    expiryDate       = dr["ExpiryDate"].ToString(),
                    ExparyDateColor  = color,
                });
            }
            return(new JsonResult {
                Data = obj1, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult BindProductName(string Name)
        {
            DataSet ds = BL_obj.BindProductName(Name);
            List <PatientMedicalBill> obj = new List <Models.Pharmacy.PatientMedicalBill>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                obj.Add(new Models.Pharmacy.PatientMedicalBill
                {
                    ProductID   = dr["ProductID"].ToString(),
                    ProductName = dr["ProductName"].ToString(),
                });
            }
            return(new JsonResult {
                Data = obj, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = 86753090
            });

            //  return new JsonResult { Data = obj, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }