Esempio n. 1
0
 private void BT_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         pd_grid.Rows.Clear();
         Button btn = (Button)sender;
         co.ROOM_NO = Convert.ToString(btn.Content);
         DataTable dt = co.TransferAmount();
         if (dt.Rows[0]["AMOUNT"].ToString() == "" || dt.Rows[0]["AMOUNT"].ToString() == null)
         {
             RC_TransferAmount = 0;
         }
         else
         {
             RC_TransferAmount = Convert.ToDecimal(dt.Rows[0]["AMOUNT"]);
         }
         roomno = co.ROOM_NO;
         DataTable dt_user = co.UserDetails();
         grduserdetails.ItemsSource = dt_user.DefaultView;
         if (dt_user.Rows.Count > 0)
         {
             DepartureDate = Convert.ToDateTime(dt_user.Rows[0]["DEPARTURE_DATE"]);
         }
         DataTable dt_RoomCharges = co.RoomAdditionalCharges();
         DataTable Checking_RC    = co.CheckingIfRoomChanged();
         if (dt_RoomCharges.Rows.Count > 0)
         {
             RC_CheckinId = dt_RoomCharges.Rows[0]["CHECKIN_ID"].ToString();
             if (dt_RoomCharges.Rows[0]["ADVANCE"].ToString() == null || dt_RoomCharges.Rows[0]["ADVANCE"].ToString() == "")
             {
                 RC_Advance = 0;
             }
             else
             {
                 RC_Advance = Convert.ToDecimal(dt_RoomCharges.Rows[0]["ADVANCE"]);
             }
             if (dt_RoomCharges.Rows[0]["DISCOUNT"].ToString() == null || dt_RoomCharges.Rows[0]["DISCOUNT"].ToString() == "")
             {
                 RC_Discount = 0;
             }
             else
             {
                 RC_Discount = Convert.ToDecimal(dt_RoomCharges.Rows[0]["DISCOUNT"]);
             }
             if (dt_RoomCharges.Rows[0]["POSTCHARGES"].ToString() == null || dt_RoomCharges.Rows[0]["POSTCHARGES"].ToString() == "")
             {
                 RC_Charges = 0;
             }
             else
             {
                 RC_Charges = Convert.ToDecimal(dt_RoomCharges.Rows[0]["POSTCHARGES"]);
             }
             if (dt_RoomCharges.Rows[0]["DIS_PER"].ToString() == null || dt_RoomCharges.Rows[0]["DIS_PER"].ToString() == "")
             {
                 RC_Dis_Per = 0;
             }
             else
             {
                 RC_Dis_Per = Convert.ToDecimal(dt_RoomCharges.Rows[0]["DIS_PER"]);
             }
             if (dt_RoomCharges.Rows[0]["REFUND"].ToString() == null || dt_RoomCharges.Rows[0]["REFUND"].ToString() == "")
             {
                 RC_Refund = 0;
             }
             else
             {
                 RC_Refund = Convert.ToDecimal(dt_RoomCharges.Rows[0]["REFUND"]);
             }
         }
         DataTable RC_NA = co.GetNightAudit(RC_CheckinId);
         if (RC_NA.Rows.Count > 0)
         {
             for (int k = 0; k < RC_NA.Rows.Count; k++)
             {
                 RC_Tariff1 = Convert.ToDecimal(RC_NA.Rows[k]["ROOM_TARRIF"]);
                 if (RC_NA.Rows[k]["GST"].ToString() == null || RC_NA.Rows[k]["GST"].ToString() == "")
                 {
                     RC_Tax1 = 0;
                 }
                 else
                 {
                     RC_Tax1 = Convert.ToDecimal(RC_NA.Rows[k]["GST"]);
                 }
                 RC_Tax2         = RC_Tariff1 * RC_Tax1 / 100;
                 RC_FinalTariff += RC_Tariff1;
                 RC_FinalTax    += RC_Tax2;
             }
         }
         if (RC_Dis_Per == 0)
         {
             discountamount = Convert.ToString(Math.Round(RC_Discount, 2, MidpointRounding.AwayFromZero));
         }
         else
         {
             rpercentage    = (RC_FinalTariff * RC_Dis_Per) / 100;
             discountamount = Convert.ToString(Math.Round(rpercentage, 2, MidpointRounding.AwayFromZero));
         }
         rtotalpendingamnt  = RC_FinalTariff + RC_FinalTax + RC_Charges - RC_Advance - Convert.ToDecimal(discountamount) + RC_Refund + RC_TransferAmount;
         totalpendingamount = Convert.ToString(Math.Round(rtotalpendingamnt, 2, MidpointRounding.AwayFromZero));
         DataRow pd = pd_grid.NewRow();
         pd["Roomno"]         = co.ROOM_NO;
         pd["Tarrif"]         = Math.Round(RC_FinalTariff, 2, MidpointRounding.AwayFromZero);
         Ch_Tarrif            = Math.Round(RC_FinalTariff, 2, MidpointRounding.AwayFromZero);
         pd["Charges"]        = Math.Round(RC_Charges, 2, MidpointRounding.AwayFromZero);
         Ch_Charges           = Math.Round(RC_Charges, 2, MidpointRounding.AwayFromZero);
         pd["Cgst"]           = Math.Round(RC_FinalTax / 2, 2, MidpointRounding.AwayFromZero);
         Ch_CSGST             = Math.Round(RC_FinalTax / 2, 2, MidpointRounding.AwayFromZero);
         pd["Sgst"]           = Math.Round(RC_FinalTax / 2, 2, MidpointRounding.AwayFromZero);
         pd["Advance"]        = Math.Round(RC_Advance, 2, MidpointRounding.AwayFromZero);
         Ch_Advance           = Math.Round(RC_Advance, 2, MidpointRounding.AwayFromZero);
         pd["Discount"]       = discountamount;
         Ch_Discount          = Convert.ToDecimal(discountamount);
         pd["Refund"]         = Math.Round(RC_Refund, 2, MidpointRounding.AwayFromZero);
         Ch_Refunds           = Math.Round(RC_Refund, 2, MidpointRounding.AwayFromZero);
         Ch_PendingAmount     = Math.Round(rtotalpendingamnt, 2, MidpointRounding.AwayFromZero);
         pd["Transfer"]       = Math.Round(RC_TransferAmount, 2, MidpointRounding.AwayFromZero);
         pd["Pending_Amount"] = totalpendingamount;
         pd_grid.Rows.Add(pd);
         grdpaymentdetails.ItemsSource = pd_grid.DefaultView;
         RC_FinalTariff = 0;
         RC_FinalTax    = 0;
     }
     catch (Exception) { }
 }