Exemple #1
0
        public JsonResult BindCaculteAge(string date)
        {
            string            aa = "";
            BL_PatientOPDBill db = new BL_PatientOPDBill();

            if (date != "NaN-NaN-NaN")
            {
                aa = Convert.ToDateTime(date).ToString("yyyy-MM-dd");
            }
            return(new JsonResult {
                Data = aa, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult OtherBilling(OPDBill obj, FormCollection fc)
        {
            HospitlLocationID();
            // FormCollection fc = new FormCollection();
            //   OPDBill obj = new OPDBill();
            string Mode = "Add";

            try
            {
                //string hh = TempData["Reg"].ToString();
                //  obj.PatientType
                rpt             = Request.Form["rpt"];
                obj.ChargesType = Request.Form["RadioCharge"];
                obj.PaymentType = Request.Form["payment_type"];
                obj.BillDate    = Convert.ToDateTime(fc["bill_date"]).ToString("dd-MMM-yyyy"); // +" " + fc["bill_time"];
                                                                                               // obj.Gender = Request.Form["gen"].ToString();
                obj.PreBalance = Convert.ToDecimal(fc["PreBalanceandDiposit"]);
                if (fc["OldBillNo"] == "" || fc["OldBillNo"] == null)
                {
                    obj.BillNoId = 0;
                }
                else
                {
                    obj.BillNoId = Convert.ToInt32(fc["OldBillNo"]);
                }
                if (Request.Form["DateOfBirth"] != "")
                {
                    //string aaa = Request.Form["DateOfBirth"].ToString();
                    obj.DateOfBirth = Convert.ToDateTime(Request.Form["DateOfBirth"]).ToString("dd-MM-yyyy");
                    DateTime DAT = Convert.ToDateTime(DateBirth);
                    TimeSpan tim = DateTime.Now - DAT;
                    obj.TotalDay = tim.TotalDays.ToString(); //CalGetDaysAge();   //Math.Abs(tim.Days).ToString();
                }
                else
                {
                    obj.DateOfBirth = System.DateTime.Now.ToString("dd-mmm-yyyy");
                }



                switch (obj.PaymentType)
                {
                case "Cheque":
                    obj.Number  = Request.Form["Number"];        // "Cheques";// dr["Number"] = ucCheques1.txtChequeNO.Text;
                    obj.Name    = Request.Form["Name"];
                    obj.Date    = Request.Form["paymentDate"];
                    obj.Remarks = Request.Form["Remarks"];
                    break;

                case "Credit Card":
                    obj.Number  = Request.Form["Number"];
                    obj.Name    = Request.Form["Name"];
                    obj.Date    = Request.Form["paymentDate"];
                    obj.Remarks = Request.Form["Remarks"];
                    break;

                case "Debit Card":
                    obj.Number  = Request.Form["Number"];
                    obj.Name    = Request.Form["Name"];
                    obj.Date    = Request.Form["paymentDate"];
                    obj.Remarks = Request.Form["Remarks"];
                    break;

                case "E-money":
                    obj.Number  = Request.Form["Number"];
                    obj.Name    = Request.Form["Name"];
                    obj.Date    = Request.Form["paymentDate"];
                    obj.Remarks = "EMoney";
                    break;

                case "EFT":
                    obj.Number  = Request.Form["Number"];
                    obj.Name    = Request.Form["Name"];
                    obj.Date    = Request.Form["paymentDate"];
                    obj.Remarks = Request.Form["Remarks"];
                    break;

                default:
                    obj.Number  = "Cash";
                    obj.Name    = "Cash";
                    obj.Date    = System.DateTime.Now.ToString();
                    obj.Remarks = "Cash";
                    break;
                }
                double Qty  = 0;
                double Rate = 0;
                obj.BillDate = Convert.ToDateTime(fc["bill_date"]).ToString("dd-MMM-yyyy");// +" " + fc["bill_time"];
                string svcid                = fc["svc_hid"].ToString();
                string svcname              = fc["svc_nm_name"].ToString();
                string unitid               = fc["unithid"].ToString();
                string docid                = fc["doc_hid"].ToString();
                string rate                 = fc["rate1table"].ToString();
                string ServiceType          = fc["ServiceType"].ToString();
                string DoctorCharge         = fc["DoctorCharges"].ToString();
                string qty                  = fc["qty"].ToString();
                string Mode1                = fc["Mode"].ToString();
                string Discount_Service     = fc["Discount_Service"].ToString();
                string Discount_serviceType = fc["DiscountServiceType"].ToString();
                string Aurth                = fc["Authorization"].ToString();
                // string tot = fc["total"].ToString();
                String[] service_ID        = svcid.Split(',');
                String[] service_Name      = svcname.Split(',');
                String[] service_unit_ID   = unitid.Split(',');
                String[] service_doc_ID    = docid.Split(',');
                String[] service_rate      = rate.Split(',');
                String[] service_qty       = qty.Split(',');
                String[] ServiceType1      = ServiceType.Split(',');
                string[] ServiceDisAmt     = Discount_Service.Split(',');
                string[] ServiceDisType    = Discount_serviceType.Split(',');
                String[] Mod               = Mode1.Split(',');
                string[] Doctorcharges     = DoctorCharge.Split(',');
                string[] ForAuthoriazation = Aurth.Split(',');
                //String[] total_a = tot.Split(',');
                ServiceName[] svc_array = new ServiceName[service_ID.Length];
                for (int i = 0; i < service_ID.Length; i++)
                {
                    svc_array[i]                     = new ServiceName();
                    svc_array[i].SvcID               = service_ID[i].ToString();
                    svc_array[i].SvcName             = service_Name[i].ToString();
                    svc_array[i].UnitID              = service_unit_ID[i].ToString();
                    svc_array[i].DoctorID            = service_doc_ID[i].ToString();
                    svc_array[i].Rate                = service_rate[i].ToString();
                    svc_array[i].Quantity            = service_qty[i].ToString();
                    svc_array[i].ServiceType         = ServiceType1[i].ToString();
                    svc_array[i].Doctorcharges       = Doctorcharges[i].ToString();
                    svc_array[i].Discount_Service    = ServiceDisAmt[i].ToString();
                    svc_array[i].DiscountServiceType = ServiceDisType[i].ToString();
                    svc_array[i].Authorization       = ForAuthoriazation[i].ToString();
                    double ServiceAmt = 0;

                    //       TotalPer = ((Amount * DiscountPercent) / 100);
                    svc_array[i].Mode = Mod[i].ToString();


                    if (svc_array[i].Rate != "")
                    {
                        Rate = Convert.ToDouble(svc_array[i].Rate);
                    }
                    if (svc_array[i].Quantity != "")
                    {
                        Qty = Convert.ToDouble(svc_array[i].Quantity);
                        double totalAmt = Rate * Qty;


                        if (svc_array[i].DiscountServiceType == "%")
                        {
                            ServiceAmt = ((totalAmt * Convert.ToDouble(svc_array[i].Discount_Service)) / 100);
                            svc_array[i].sevicedisAmt = ServiceAmt.ToString();
                        }
                        if (svc_array[i].DiscountServiceType == "Rs")
                        {
                            svc_array[i].sevicedisAmt = Convert.ToDouble(svc_array[i].Discount_Service).ToString();
                        }
                        totalAmt           = totalAmt - Convert.ToDouble(svc_array[i].sevicedisAmt);
                        svc_array[i].Total = totalAmt.ToString();//total_a[i].ToString();
                    }
                }
                obj.Services = svc_array;
                if (Mode == "Add")
                {
                    HospitlLocationID();
                    // _OPDBill.Save1(obj);
                    Buisness_Logic.Other.BL_OtherBilling BL_OtherBill = new Buisness_Logic.Other.BL_OtherBilling();
                    BL_OtherBill.Save(obj);
                    OPDBill OPDbill = new OPDBill();
                    if (OPDbill.MessageError == "Done")
                    {
                        BL_PatientOPDBill db = new BL_PatientOPDBill();

                        OPDbill.BillNo = obj.BillNo;
                        Connect();
                        SqlCommand cmd = new SqlCommand("RptPatientOPDBills", con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
                        cmd.Parameters.AddWithValue("@LocationID", LocationID);
                        cmd.Parameters.AddWithValue("@BillNo", OPDbill.BillNo);
                        //Session["HospitalIDReport"] = "1";
                        //Session["LocationIDReport"] = "1";
                        Session["HospitalIDReport"] = HospitalID;
                        Session["LocationIDReport"] = LocationID;
                        Session["BillNoReport"]     = OPDbill.BillNo.ToString();
                        Session["rptReport"]        = rpt.ToString();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataSet        ds = new DataSet();
                        //  con.Open();
                        da.Fill(ds);
                        //con.Close();
                        //return ds;
                        if (ds.Tables[0].Rows.Count != 0)
                        {
                            //DialogResult ObjDialogResult = MessageBox.Show("With Balance Amount", "Keystone ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            //if (ObjDialogResult == DialogResult.No)
                            //{
                            return(RedirectToAction("RptPatientOPDBills", "PatientReport"));
                        }



                        TempData["Msg"] = "Save Sussefully";
                        return(RedirectToAction("OtherBilling", "OtherBilling"));
                    }
                    else
                    {
                        TempData["Msg"] = OPDbill.MessageError;
                        return(RedirectToAction("OtherBilling", "OtherBilling"));
                    }
                    // Sms
                    //test.Controllers.Hospital.SMSSettingController objsms = new Hospital.SMSSettingController();
                    //DataSet dssms = new DataSet();
                    //dssms = objsms.GetMasterSetting(HospitalID, LocationID);

                    //string SmsChk = "";
                    //if (fc["sms"] == null)
                    //{
                    //    SmsChk = "false";
                    //}
                    //else
                    //{
                    //    SmsChk = "true";
                    //}

                    //if (SmsChk == "true" && Convert.ToBoolean(dssms.Tables[0].Rows[0]["OPDBillDrSMS"].ToString()) == true)
                    //{
                    //    objsms.SendSMS(Convert.ToInt32(obj.PatientRegNO), Convert.ToInt32(TempData["RefferDoctorID"]), TempData["DoctorPrintName"].ToString(), "OPD1", TempData["RDoctorPrintName"].ToString());
                    //}

                    //--------------------------

                    //con.Close();
                    //return ds;
                    //if (ds.Tables[0].Rows.Count != 0)
                    //{
                    //    //DialogResult ObjDialogResult = MessageBox.Show("With Balance Amount", "Keystone ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //    //if (ObjDialogResult == DialogResult.No)
                    //    //{
                    //    return RedirectToAction("RptPatientOPDBills");


                    //}
                }
            }
            catch (Exception ex)
            {
                TempData["Msg"] = ex.Message;
                return(RedirectToAction("OtherBilling", "OtherBilling"));
            }
            return(View());
        }