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()); }
public JsonResult OldBillNo_IndexChange(int BillNO, OPDBill obj) { Buisness_Logic.Other.BL_OtherBilling Bl_obj = new Buisness_Logic.Other.BL_OtherBilling(); HospitlLocationID(); string Mode = "Add"; if (BillNO > 0) { if (Mode == "Add") { dsPatientBills.Reset(); dsPatientBills = Bl_obj.GetOtherBills(BillNO, HospitalID, LocationID); if (dsPatientBills.Tables.Count > 0) { obj.ForAuthorization = "0"; //if (dsPatientBills.Tables[0].Rows.Count > 0) //{ // string ForAuthorization = dsPatientBills.Tables[0].Rows[0]["ForAuthorization"].ToString(); // if (ForAuthorization == "1") // { // obj.ForAuthorization = ForAuthorization.ToString(); // } // } obj.PaymentType = dsPatientBills.Tables[0].Rows[0]["PaymentType"].ToString(); switch (obj.PaymentType) { case "Cheque": obj.Number = dsPatientBills.Tables[0].Rows[0]["Number"].ToString(); obj.Name = dsPatientBills.Tables[0].Rows[0]["Name"].ToString(); obj.Date = dsPatientBills.Tables[0].Rows[0]["Date"].ToString(); obj.Remarks = dsPatientBills.Tables[0].Rows[0]["Remarks"].ToString(); break; case "Credit Card": obj.Number = dsPatientBills.Tables[0].Rows[0]["Number"].ToString(); obj.Name = dsPatientBills.Tables[0].Rows[0]["Name"].ToString(); obj.Date = dsPatientBills.Tables[0].Rows[0]["Date"].ToString(); obj.Remarks = dsPatientBills.Tables[0].Rows[0]["Remarks"].ToString(); break; case "Debit Card": obj.Number = dsPatientBills.Tables[0].Rows[0]["Number"].ToString(); obj.Name = dsPatientBills.Tables[0].Rows[0]["Name"].ToString(); obj.Date = dsPatientBills.Tables[0].Rows[0]["Date"].ToString(); obj.Remarks = dsPatientBills.Tables[0].Rows[0]["Remarks"].ToString(); break; case "E-Money": obj.Number = dsPatientBills.Tables[0].Rows[0]["Number"].ToString(); obj.Name = dsPatientBills.Tables[0].Rows[0]["Name"].ToString(); obj.Date = dsPatientBills.Tables[0].Rows[0]["Date"].ToString(); obj.Remarks = dsPatientBills.Tables[0].Rows[0]["Remarks"].ToString(); break; case "EFT": obj.Number = dsPatientBills.Tables[0].Rows[0]["Number"].ToString(); obj.Name = dsPatientBills.Tables[0].Rows[0]["Name"].ToString(); obj.Date = dsPatientBills.Tables[0].Rows[0]["Date"].ToString(); obj.Remarks = dsPatientBills.Tables[0].Rows[0]["Remarks"].ToString(); break; default: obj.Number = "Cash"; obj.Name = "Cash"; obj.Date = System.DateTime.Now.ToString("yyyy-MM-dd"); obj.Remarks = "Cash"; break; } } if (dsPatientBills.Tables[0].Rows.Count > 0) { obj.BillDate = Convert.ToDateTime(dsPatientBills.Tables[0].Rows[0]["BillDate"]).ToString("yyyy-MM-dd"); //time = dsPatientBills.Tables[0].Rows[0]["BillDate"].ToString(); obj.grosstotal = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["GrossAmount"]); obj.TaxPercent = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["TaxPercent"]); obj.SerTaxAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["TaxAmount"]); obj.TotalAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["TotalAmount"]); obj.DiscountPercent = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["DiscountPercent"]); obj.DiscountAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["DiscountAmount"]); obj.DiscountReason = dsPatientBills.Tables[0].Rows[0]["DiscountReason"].ToString(); //if (disID != "0") //{ // DataSet ds = _OPDBill.GetDiscountReasonID(Convert.ToString(disID)); // if (ds.Tables[0].Rows.Count > 0) // { // obj.DiscountReason = ds.Tables[0].Rows[0]["DiscountReason"].ToString(); // } //} //else //{ // obj.DiscountReason = dsPatientBills.Tables[0].Rows[0]["DiscountReason"].ToString(); //} if (dsPatientBills.Tables[0].Rows.Count > 0) { if (dsPatientBills.Tables[0].Rows[0]["PreBalanceAmount"].ToString() != null && dsPatientBills.Tables[0].Rows[0]["PreBalanceAmount"].ToString().Trim() != "") { obj.PreBalance = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["PreBalanceAmount"]); if (Convert.ToDecimal(PreBalance) > 0) { obj.PreBalance = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["PreBalanceAmount"]); } } else { obj.PreBalance = Convert.ToDecimal("0.00"); } } } obj.NetPayableAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["NetPayableAmount"]); obj.PaidAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["PaidAmount"]); obj.BalanceAmount = Convert.ToDecimal(dsPatientBills.Tables[0].Rows[0]["BalanceAmount"]); obj.BillNo = BillNO; } } List <OPDBill> searchlist = new List <OPDBill>(); searchlist.Add(obj); return(new JsonResult { Data = searchlist, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public bool Save(OPDBill obj) { int BillNo = 0; int PatientLabDetailID = 0; string ServiceType = ""; Connect(); con.Open(); #region IUPatientBillsOPD _PatientBill SqlCommand cmdPatientBills = new SqlCommand("IUOtherBill", con); cmdPatientBills.CommandType = CommandType.StoredProcedure; cmdPatientBills.Parameters.AddWithValue("@HospitalID", HospitalID); cmdPatientBills.Parameters.AddWithValue("@LocationID", LocationID); if (obj.BillNoId == 0) { cmdPatientBills.Parameters.AddWithValue("@BillNo", obj.BillNoId); cmdPatientBills.Parameters["@BillNo"].Direction = ParameterDirection.Output; cmdPatientBills.Parameters.AddWithValue("@Mode", "Add"); } else { cmdPatientBills.Parameters.AddWithValue("@BillNo", obj.BillNoId); cmdPatientBills.Parameters.AddWithValue("@Mode", "Edit"); } cmdPatientBills.Parameters.AddWithValue("@BillDate", Convert.ToDateTime(obj.BillDate)); cmdPatientBills.Parameters.AddWithValue("@PatientRegNO", obj.PatientRegNO); cmdPatientBills.Parameters.AddWithValue("@OPDIPDID", obj.PatientOPDNo); cmdPatientBills.Parameters.AddWithValue("@BillType", "IPDOtherBill"); cmdPatientBills.Parameters.AddWithValue("@GrossAmount", obj.grosstotal); cmdPatientBills.Parameters.AddWithValue("@TaxPercent", obj.TaxPercent); cmdPatientBills.Parameters.AddWithValue("@TaxAmount", obj.SerTaxAmount); cmdPatientBills.Parameters.AddWithValue("@Commisson", obj.Commisson); cmdPatientBills.Parameters.AddWithValue("@ReffCommission", obj.ReffCommission); cmdPatientBills.Parameters.AddWithValue("@TotalAmount", obj.TotalAmount); cmdPatientBills.Parameters.AddWithValue("@DiscountPercent", obj.DiscountPercent); cmdPatientBills.Parameters.AddWithValue("@DiscountAmount", obj.DiscountAmount); cmdPatientBills.Parameters.AddWithValue("@DiscountReason", obj.DiscountReason); cmdPatientBills.Parameters.AddWithValue("@NetPayableAmount", obj.NetPayableAmount); cmdPatientBills.Parameters.AddWithValue("@BalanceAmount", obj.BalanceAmount); cmdPatientBills.Parameters.AddWithValue("@PreBalanceAmount", obj.PreBalance); //cmd.Parameters.AddWithValue("@BalanceAmount", obj.BalanceAmount); decimal BAmt1 = Convert.ToDecimal(obj.BalanceAmount); if (BAmt1 <= 0) { cmdPatientBills.Parameters.AddWithValue("@IsPaid", 0); } else { cmdPatientBills.Parameters.AddWithValue("@IsPaid", 1); } cmdPatientBills.Parameters.AddWithValue("@PaidAmount", obj.PaidAmount); cmdPatientBills.Parameters.AddWithValue("@DipositAmount", "0.00"); cmdPatientBills.Parameters.AddWithValue("@IsBillMade", 0); cmdPatientBills.Parameters.AddWithValue("@PaymentType", obj.PaymentType); cmdPatientBills.Parameters.AddWithValue("@Number", obj.Number); cmdPatientBills.Parameters.AddWithValue("@Name", obj.Name); cmdPatientBills.Parameters.AddWithValue("@Date", Convert.ToDateTime(obj.Date)); cmdPatientBills.Parameters.AddWithValue("@Remarks", obj.Remarks); // cmdPatientBills.Parameters.AddWithValue("@SancationAmount", obj.SancationAmount); cmdPatientBills.Parameters.AddWithValue("@FinancialYearID", obj.FinancialYearID); cmdPatientBills.Parameters.AddWithValue("@CreationID", UserID); // cmdPatientBills.Parameters.AddWithValue("@ForAuthorization", obj.ForAuthorization); int i = cmdPatientBills.ExecuteNonQuery(); BillNo = Convert.ToInt32(cmdPatientBills.Parameters["@BillNo"].Value); #endregion if (i > 0) { for (int j = 0; j < obj.Services.Length; j++) { SqlCommand cmd1 = new SqlCommand("IUOtherBillsDetails", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@HospitalID", HospitalID); cmd1.Parameters.AddWithValue("@LocationID", LocationID); cmd1.Parameters.AddWithValue("@BillNo", BillNo); cmd1.Parameters.AddWithValue("@ServiceID", obj.Services[j].SvcID); cmd1.Parameters.AddWithValue("@Servicename", obj.Services[j].SvcName); cmd1.Parameters.AddWithValue("@UnitID", obj.UnitID); cmd1.Parameters.AddWithValue("@ChargesType", obj.ChargesType); cmd1.Parameters.AddWithValue("@Rate", obj.Services[j].Rate); cmd1.Parameters.AddWithValue("@Quantity", obj.Services[j].Quantity); cmd1.Parameters.AddWithValue("@Discount", obj.Services[j].sevicedisAmt); cmd1.Parameters.AddWithValue("@Commisson", obj.Commisson); cmd1.Parameters.AddWithValue("@ReffCommission", obj.ReffCommission); cmd1.Parameters.AddWithValue("@ServiceType", obj.Services[j].ServiceType); // cmd1.Parameters.AddWithValue("@DoctorCharges", ""); cmd1.Parameters.AddWithValue("@TotalAmount", obj.Services[j].Total); cmd1.Parameters.AddWithValue("@HideInBilling", "Yes"); cmd1.Parameters.AddWithValue("@DoctorID", obj.Services[j].DoctorID); cmd1.Parameters.AddWithValue("@CreationID", UserID); cmd1.Parameters.AddWithValue("@Discount_Service", obj.Services[j].Discount_Service); cmd1.Parameters.AddWithValue("@DiscountServiceType", obj.Services[j].DiscountServiceType); //cmd1.Parameters.AddWithValue("@ForAuthorization", obj.Services[j].Authorization); cmd1.Parameters.AddWithValue("@Mode", "Add"); int BillsDetails = cmd1.ExecuteNonQuery(); if (obj.Services[j].ServiceType == "OPDLabBills") { ServiceType = obj.Services[j].ServiceType; } } } return(true); }