private void Save()
        {
            try
            {
                if (objDriverCommision.Current == null)
                {
                    return;
                }
                string Description = txtReason.Text.ToStr().Trim();
                if (string.IsNullOrEmpty(Description))
                {
                    ENUtils.ShowMessage("Required : Description");
                    return;
                }
                objDriverCommision.Edit();
                objDriverCommision.Current.Balance = numCurrBalance.Value.ToDecimal();
                Fleet_DriverCommissionExpense objDriverCommissionExpense = new Fleet_DriverCommissionExpense();
                if (rdoCredit.IsChecked)
                {
                    objDriverCommissionExpense.Credit = spnCommissionPay.Value.ToDecimal();
                    objDriverCommissionExpense.Amount = spnCommissionPay.Value.ToDecimal();
                }
                else
                {
                    objDriverCommissionExpense.Debit  = spnCommissionPay.Value.ToDecimal();
                    objDriverCommissionExpense.Amount = spnCommissionPay.Value.ToDecimal();
                }
                objDriverCommissionExpense.Date        = DateTime.Now;
                objDriverCommissionExpense.Description = Description;
                objDriverCommissionExpense.IsPaid      = true;
                if (objDriverCommision.Current.Fleet_DriverCommissionExpenses.Count == 0)
                {
                    objDriverCommision.Current.Fleet_DriverCommissionExpenses.Add(objDriverCommissionExpense);
                }
                else
                {
                    objDriverCommision.Current.Fleet_DriverCommissionExpenses.Add(objDriverCommissionExpense);
                }


                objDriverCommision.Current.EditOn  = DateTime.Now;
                objDriverCommision.Current.EditLog = AppVars.LoginObj.UserName.ToStr();
                objDriverCommision.Current.EditBy  = AppVars.LoginObj.LuserId.ToInt();

                objDriverCommision.Save();
                DisplayRecord();
                //this.Close();
            }
            catch (Exception ex)
            {
                if (objDriverCommision.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objDriverCommision.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
コード例 #2
0
        void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                objMaster = new DriverCommisionBO();

                try
                {
                    objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt());

                    string Transaction = grdLister.CurrentRow.Cells["TransNo"].Value.ToStr();
                    int    DriverId    = grdLister.CurrentRow.Cells["DriverID"].Value.ToInt();

                    var query = General.GetQueryable <Fleet_DriverCommision>(c => c.DriverId == DriverId).OrderByDescending(c => c.Id).FirstOrDefault();

                    if (query != null)
                    {
                        string Transno = query.TransNo.ToStr();

                        if (Transno == Transaction)
                        {
                            objMaster.Delete(objMaster.Current);
                        }
                        else
                        {
                            ENUtils.ShowMessage("You Can not delete a record..");
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (objMaster.Errors.Count > 0)
                    {
                        ENUtils.ShowMessage(objMaster.ShowErrors());
                    }
                    else
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                    e.Cancel = true;
                }
            }
        }
コード例 #3
0
        private bool OnSave(int DriverId, decimal oldBalance, decimal DriverCommissionPerBooking, decimal pdaCommission, decimal InitialBalance, decimal CommissionPayValue, ref decimal accJobs, ref long transId, ref decimal rentDue, ref decimal currBalance)
        {
            bool IsSaved = false;


            try
            {
                bool RentForProcessedJobs = AppVars.objPolicyConfiguration.RentForProcessedJobs.ToBool();


                var CommissionList = General.GetGeneralList <Fleet_DriverCommision_Charge>(c => c.BookingId != null && c.TransId != null);



                Expression <Func <Booking, bool> > _exp = null;
                if (AppVars.objPolicyConfiguration.PickBookingOnInvoicingType.ToInt() == 2)
                {
                    _exp = c => ((c.PaymentTypeId != Enums.PAYMENT_TYPES.CASH && c.BookingStatusId == Enums.BOOKINGSTATUS.NOPICKUP) || c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED)

                           && (c.FareRate != null) &&
                           ((RentForProcessedJobs == true && (c.IsProcessed != null && c.IsProcessed == true)) || (RentForProcessedJobs == false && (c.IsProcessed == null || c.IsProcessed == false))) &&
                           (c.DriverId == DriverId) &&
                           (c.PickupDateTime.Value.Date >= dtpFromDate.Value.Value.Date && c.PickupDateTime.Value.Date <= dtpTillDate.Value.Value.Date);
                }
                else
                {
                    _exp = c => c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED

                           && (c.FareRate != null) &&
                           ((RentForProcessedJobs == true && (c.IsProcessed != null && c.IsProcessed == true)) || (RentForProcessedJobs == false && (c.IsProcessed == null || c.IsProcessed == false))) &&
                           (c.DriverId == DriverId) &&
                           (c.PickupDateTime.Value.Date >= dtpFromDate.Value.Value.Date && c.PickupDateTime.Value.Date <= dtpTillDate.Value.Value.Date);
                }



                var list2 = (from a in General.GetGeneralList <Booking>(_exp)
                             join b in CommissionList on a.Id equals b.BookingId into table2
                             from b in table2.DefaultIfEmpty()
                             where (b == null)
                             select new
                {
                    Id = a.Id,
                    TotalFare = a.FareRate.ToDecimal(),
                    CompanyId = a.CompanyId,
                    AccountTypeId = a.Gen_Company != null ? a.Gen_Company.AccountTypeId : a.PaymentTypeId,
                    DriverCommissionAmount = a.DriverCommission,
                    DriverCommissionType = a.DriverCommissionType,
                    IsCommissionWise = a.IsCommissionWise,
                    AgentCommission = a.AgentCommission
                }).ToList();


                if (list2.Count > 0)
                {
                    objMaster = new DriverCommisionBO();
                    objMaster.New();

                    List <Fleet_DriverCommision_Charge> ListDetail = (from a in list2
                                                                      select new Fleet_DriverCommision_Charge
                    {
                        //Id = a.Id,
                        TransId = objMaster.Current.Id,
                        BookingId = a.Id,
                        CommissionPerBooking = (a.TotalFare * DriverCommissionPerBooking) / 100
                                               //CommissionPerBooking=a.DriverCommissionAmount
                    }).ToList();


                    decimal Total        = list2.Sum(c => c.TotalFare).ToDecimal();
                    decimal ACCJobsTotal = list2.Where(c => c.CompanyId != null).Sum(c => c.TotalFare).ToDecimal();

                    double totalWeeks = (dtpTillDate.Value.ToDate().Subtract(dtpFromDate.Value.ToDate()).TotalDays) / 7;

                    if (totalWeeks <= 0)
                    {
                        totalWeeks = 1;
                    }

                    decimal TotalPDARent = (pdaCommission * totalWeeks.ToInt());

                    decimal AgentCommission       = list2.Sum(c => c.AgentCommission).ToDecimal();
                    decimal DriverCommissionTotal = 0;
                    DriverCommissionTotal = ((Total - AgentCommission) * DriverCommissionPerBooking / 100);
                    decimal owed = ((AgentCommission + TotalPDARent + DriverCommissionTotal) - ACCJobsTotal);

                    rentDue = owed;


                    objMaster.Current.AccJobsTotal    = ACCJobsTotal;
                    objMaster.Current.DriverOwed      = rentDue;
                    objMaster.Current.CommissionTotal = DriverCommissionTotal;
                    objMaster.Current.JobsTotal       = Total;
                    objMaster.Current.AgentFeesTotal  = AgentCommission;


                    objMaster.Current.CommisionPay = CommissionPayValue.ToDecimal();

                    objMaster.Current.Balance = (rentDue + oldBalance);//RentPay - DriverRent;

                    objMaster.Current.DriverCommision = DriverCommissionPerBooking;

                    // add pda rent
                    objMaster.Current.PDARent = pdaCommission;

                    objMaster.Current.AddBy      = AppVars.LoginObj.LuserId.ToInt();
                    objMaster.Current.AddLog     = AppVars.LoginObj.LoginName.ToStr();
                    objMaster.Current.AddOn      = DateTime.Now;
                    objMaster.Current.TransDate  = DateTime.Now; //dtpTransactionDate.Value.ToDateTime();
                    objMaster.Current.DriverId   = DriverId;     //ddlDriver.SelectedValue.ToIntorNull();
                    objMaster.Current.OldBalance = oldBalance;   // (CurrentBalance - RentPay);
                    objMaster.Current.FromDate   = dtpFromDate.Value.ToDate();
                    objMaster.Current.ToDate     = dtpTillDate.Value.ToDate();
                    objMaster.Current.TransFor   = "Weekly";//ddlDayWise.SelectedText.ToStr();


                    objMaster.Current.Fuel  = 0; //Fuel.ToDecimal();
                    objMaster.Current.Extra = 0; // Extra.ToDecimal();


                    string[] skipProperties = { "Fleet_DriverCommision", "Booking" };
                    IList <Fleet_DriverCommision_Charge> savedList = objMaster.Current.Fleet_DriverCommision_Charges;

                    var list = objMaster.Current.Fleet_DriverCommision_Charges.ToList();


                    Utils.General.SyncChildCollection(ref savedList, ref ListDetail, "Id", skipProperties);


                    objMaster.Save();

                    currBalance = objMaster.Current.Balance.ToDecimal();
                    IsSaved     = true;
                    transId     = objMaster.Current.Id;
                }
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }

            return(IsSaved);
        }