public JsonResult Delete_medBill(int MedicalBillID)
        {
            string _Del = null;

            try
            {
                KeystoneProject.Buisness_Logic.Pharmacy.BL_PatientMedicalBill objdb = new BL_PatientMedicalBill();
                PatientMedicalBill objSG = new Models.Pharmacy.PatientMedicalBill();

                int DependaincyName = objdb.DeleteBill(MedicalBillID);

                if (DependaincyName > 0)
                {
                    _Del = "Medical Bill Deleted Successfully !";
                }
                else
                {
                    _Del = "Medical Bill can not be Deleted !";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new JsonResult {
                Data = _Del, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult AjaxMethod_CustName(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>();

            DataSet   ds = BL_obj.BindCustID(custNM);
            DataTable dt = new DataTable();

            dt = BL_obj.Bind_CustDetail(Convert.ToInt32(ds.Tables[0].Rows[0]["CustomerID"]));

            foreach (DataRow dr in dt.Rows)
            {
                searchList.Add(
                    new PatientMedicalBill
                {
                    CustomerName = Convert.ToString(dr["CustomerName"]),
                    Address      = Convert.ToString(dr["Address"]),
                });
            }
            return(new JsonResult
            {
                Data = searchList,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult AjaxMethod_regno(int regno)
        {
            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();

            dt = BL_obj.Bind_patDetail(regno);

            foreach (DataRow dr in dt.Rows)
            {
                searchList.Add(
                    new PatientMedicalBill
                {
                    PatientName     = Convert.ToString(dr["PatientName"]),
                    PatientRegNO    = Convert.ToString(dr["PatientRegNO"]),
                    CustomerName    = Convert.ToString(dr["PatientName"]),
                    PatientType     = Convert.ToString(dr["PatientType"]),
                    Address         = Convert.ToString(dr["Address"]),
                    DoctorPrintName = Convert.ToString(dr["DoctorPrintName"]),
                });
            }
            return(new JsonResult
            {
                Data = searchList,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        //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 AjaxMethod_OldBill_regno(int regno)
        {
            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();

            dt = BL_obj.GetOldBill(regno);

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

            return(new JsonResult {
                Data = searchList, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult AjaxMethod_OldBill(string patnm)
        {
            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.BindRegno(patnm);

            dt = BL_obj.GetOldBill(Convert.ToInt16(ds.Tables[0].Rows[0]["PatientRegNO"].ToString()));

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

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