public DischargeBill GetDischargeBill_Update(DischargeBill opidDischargeBill)
        {
            DataTable dt = new MedicalGatway().GetDischargeBillByPatientId_Update(opidDischargeBill.OPID);

            opidDischargeBill.OPID           = dt.Rows[0]["OPID"].ToString();
            opidDischargeBill.PatientName    = dt.Rows[0]["PatientName"].ToString();
            opidDischargeBill.DiscTime       = dt.Rows[0]["DischargeTime"].ToString();
            opidDischargeBill.DeisDate       = Convert.ToDateTime(dt.Rows[0]["DischargeOn"]).Date;
            opidDischargeBill.RegNo          = dt.Rows[0]["RegNo"].ToString();
            opidDischargeBill.OTMedicine     = Convert.ToDouble(dt.Rows[0]["OT_Med_Total"]);
            opidDischargeBill.HospitalCharge = Convert.ToDouble(dt.Rows[0]["Hsptl_Total"]);
            opidDischargeBill.OTservice      = Convert.ToDouble(dt.Rows[0]["OT_Total"]);
            opidDischargeBill.PharmacyBill   = Convert.ToDouble(dt.Rows[0]["Phar_Total"]);
            opidDischargeBill.Age            = dt.Rows[0]["Age"].ToString();
            opidDischargeBill.BloodGroup     = dt.Rows[0]["BloodGroup"].ToString();
            //  opidDischargeBill.OT_TOtalBill = dt.Rows[0]["OT_TOtalBill"].ToString();
            opidDischargeBill.PBill          = Convert.ToDouble(dt.Rows[0]["Path_Total"].ToString());
            opidDischargeBill.NoOfDay        = dt.Rows[0]["NoOfDay"].ToString();
            opidDischargeBill.TotalBedCharge = dt.Rows[0]["cabin_Total"].ToString();
            opidDischargeBill.TConsultBill   = dt.Rows[0]["Con_Total"].ToString();
            opidDischargeBill.TotalBill      = Convert.ToDouble(dt.Rows[0]["TotalBill"]);
            opidDischargeBill.AdvancedPayble = Convert.ToDouble(dt.Rows[0]["Advance"]);
            opidDischargeBill.Remarks        = dt.Rows[0]["Remarks"].ToString();
            opidDischargeBill.BillNo         = dt.Rows[0]["BillNo"].ToString();

            return(opidDischargeBill);
        }
        public int SaveDischargeBill(DischargeBill aDischargeBill)
        {
            Query = "INSERT INTO [dbo].[tbl_DischargeBill]([BillNo],[Date],[OPID],[HospitalCharge],[NurseCharge],[DoctorCharge],[RoomBedCharge],[ServiceCharge]," +
                    "[MedicalCharge],[PathologyBill],[TotalBill],[SubTotal],[Discount],[AdvancePaid],[NetPayble],[BillType],[Remarks],[InwardText],[OTService],[OTMedicin],[vat])"
                    + "VALUES(@BillNo,@Date,@OPID,@HospitalCharge,@NurseCharge,@DoctorCharge,@RoomBedCharge,@ServiceCharge,@MedicalCharge," +
                    "@PathologyBill,@TotalBill,@SubTotal,@Discount,@AdvancePaid,@NetPayble,@BillType,@Remarks,@InwardText,@OTService,@OTMedicin,@vat)";
            Command             = new SqlCommand(Query, Connection);
            Command.CommandType = CommandType.Text; Command.Parameters.AddWithValue(@"BillNo", aDischargeBill.BillNo);
            Command.Parameters.AddWithValue(@"Date", aDischargeBill.Date);
            Command.Parameters.AddWithValue(@"OPID", aDischargeBill.OPID);
            Command.Parameters.AddWithValue(@"HospitalCharge", aDischargeBill.HospitalCharge);
            Command.Parameters.AddWithValue(@"NurseCharge", aDischargeBill.NurseCharge);
            Command.Parameters.AddWithValue(@"DoctorCharge", aDischargeBill.DoctorCharge);
            Command.Parameters.AddWithValue(@"RoomBedCharge", aDischargeBill.RoomBedCharge);
            Command.Parameters.AddWithValue(@"ServiceCharge", aDischargeBill.ServiceCharge);
            Command.Parameters.AddWithValue(@"MedicalCharge", aDischargeBill.MedicalCharge);
            Command.Parameters.AddWithValue(@"PathologyBill", aDischargeBill.PathologyBill);
            Command.Parameters.AddWithValue(@"TotalBill", aDischargeBill.TotalBill);
            Command.Parameters.AddWithValue(@"SubTotal", aDischargeBill.SubTotal);
            Command.Parameters.AddWithValue(@"Discount", aDischargeBill.discount);
            Command.Parameters.AddWithValue(@"AdvancePaid", aDischargeBill.AdvancedPayble);
            Command.Parameters.AddWithValue(@"NetPayble", aDischargeBill.NetPayble);
            Command.Parameters.AddWithValue(@"BillType", aDischargeBill.BillType);
            Command.Parameters.AddWithValue(@"Remarks", aDischargeBill.Remarks ?? "");
            Command.Parameters.AddWithValue(@"InwardText", aDischargeBill.InwardText);
            Command.Parameters.AddWithValue(@"OTService", aDischargeBill.OTService);
            Command.Parameters.AddWithValue(@"OTMedicin", aDischargeBill.OTMedicin);
            Command.Parameters.AddWithValue(@"vat", aDischargeBill.vat);

            int count = Command.ExecuteNonQuery();

            return(count);
        }
        public int DeleteDischargeBill(DischargeBill aDischargeBill)
        {
            Query               = "Delete Tbl_DischargeBill where BillNo = @BillNo";
            Command             = new SqlCommand(Query, Connection);
            Command.CommandType = CommandType.Text;
            Command.Parameters.AddWithValue(@"BillNo", aDischargeBill.BillNo);
            int count = Command.ExecuteNonQuery();

            return(count);
        }
        public MessageModel SaveDischargeBill(DischargeBill aDischargeBill)
        {
            MessageModel message = new MessageModel();

            int count = new DischargeGateway().SaveDischargeBill(aDischargeBill);

            if (count > 0)
            {
                message.MessageBody  = "Save Successfully";
                message.MessageTitle = "Message";
            }
            return(message);
        }
        public DischargeBill VateCalcule(DischargeBill dischargeBill)
        {
            try
            {
                double totalBill     = dischargeBill.TotalBill;
                double serviceCharge = (totalBill * dischargeBill.servicePercent) / 100;
                double taxAmount     = ((totalBill + serviceCharge) * dischargeBill.Tax) / 100;

                dischargeBill.ServiceCharge = serviceCharge;
                dischargeBill.Tax           = taxAmount;
                dischargeBill.SubTotal      = taxAmount + dischargeBill.TotalBill + serviceCharge;
                dischargeBill.discount      = dischargeBill.discount;
                double afterDiscount = Convert.ToDouble(dischargeBill.SubTotal - dischargeBill.discount - dischargeBill.AdvancedPayble);
                dischargeBill.NetPayble = afterDiscount;
                // dischargeBill.TotalBill = totalBill;
                return(dischargeBill);
            }
            catch (Exception)
            {
            }
            return(dischargeBill);
        }