Example #1
0
        private void PasteData(string filePath)
        {
            List <Gen_Company> listofCompany = General.GetQueryable <Gen_Company>(null).ToList();


            System.Data.DataSet ds = new System.Data.DataSet();
            ds.ReadXml(filePath);
            DataTable dt = ds.Tables["td"];



            DateTime?pickupdate = null;
            string   bookingNo  = string.Empty;
            string   passenger  = string.Empty;
            string   toDoorNo   = string.Empty;
            string   account    = string.Empty;

            string comment = string.Empty;
            string vehicle = string.Empty;
            //  int? vehicleTypeId = null;
            string phone = string.Empty;
            string from  = string.Empty;
            string to    = string.Empty;


            int rowsCnt = dt.Rows.Count.ToInt();

            try
            {
                grdBookings.RowCount = rowsCnt;
                int rowNo = 0;
                for (int i = 0; i < rowsCnt; i += 14)
                {
                    //for (int j = 0; j < 1; j++)
                    //{
                    pickupdate = dt.Rows[i][0].ToDateTimeorNull();
                    passenger  = dt.Rows[i + 2][0].ToStr().ToProperCase();

                    account = dt.Rows[i + 4][0].ToStr().Trim();
                    comment = dt.Rows[i + 5][0].ToStr().Trim();


                    vehicle = dt.Rows[i + 7][0].ToStr().Trim();

                    phone = dt.Rows[i + 8][0].ToStr().Trim();

                    from = dt.Rows[i + 9][0].ToStr().ToUpper().Replace(",", " ").Replace("  ", " ");
                    to   = dt.Rows[i + 10][0].ToStr().ToUpper().Replace(",", " ").Replace("  ", " ");



                    if (!string.IsNullOrEmpty(account) && account != "Cash" && listofCompany.Count(c => c.CompanyName.ToLower() == account.ToLower()) == 0)
                    {
                        CompanyBO objCompanyMaster = new CompanyBO();
                        try
                        {
                            objCompanyMaster.New();

                            objCompanyMaster.Current.CompanyName = account;
                            objCompanyMaster.Current.Email       = "*****@*****.**";
                            objCompanyMaster.Current.ContactName = account;
                            objCompanyMaster.Current.Address     = "unknown";
                            objCompanyMaster.Current.TelephoneNo = string.Empty;
                            objCompanyMaster.Current.MobileNo    = string.Empty;
                            objCompanyMaster.Current.WebsiteUrl  = string.Empty;
                            objCompanyMaster.Current.Fax         = string.Empty;

                            objCompanyMaster.Current.IsClosed = false;

                            objCompanyMaster.Current.HasOrderNo       = false;
                            objCompanyMaster.Current.HasPupilNo       = false;
                            objCompanyMaster.Current.AdminFees        = 0;
                            objCompanyMaster.Current.HasComcabCharges = false;

                            objCompanyMaster.Current.DiscountPercentage = 0;

                            objCompanyMaster.Current.FareDeductionPercent = 0;

                            objCompanyMaster.Current.HasVat = false;

                            objCompanyMaster.Current.HasBookedBy = false;

                            objCompanyMaster.Current.CompanyCode = string.Empty;

                            objCompanyMaster.Current.AccountTypeId = Enums.ACCOUNT_TYPE.ACCOUNT;


                            objCompanyMaster.Current.AccountNo        = string.Empty;
                            objCompanyMaster.Current.WebLoginId       = string.Empty;
                            objCompanyMaster.Current.WebLoginPassword = string.Empty;
                            objCompanyMaster.Current.IsWebLoginActive = false;


                            objCompanyMaster.Current.BackgroundColor = string.Empty;
                            objCompanyMaster.Current.TextColor       = string.Empty;
                            objCompanyMaster.Current.PasswordAccount = string.Empty;
                            objCompanyMaster.Current.PasswordEnable  = false;

                            objCompanyMaster.Save();



                            listofCompany.Add(objCompanyMaster.Current);
                        }
                        catch (Exception ex)
                        {
                            if (objCompanyMaster.Errors.Count > 0)
                            {
                                MessageBox.Show(objCompanyMaster.ShowErrors());
                            }

                            break;
                        }
                    }



                    ;
                    grdBookings.Rows[rowNo].Cells[COLS.PickupDateTime].Value = pickupdate;

                    int vehicleTypeId = General.GetObject <Fleet_VehicleType>(c => c.VehicleType.ToLower() == vehicle.ToLower()).DefaultIfEmpty().Id;

                    if (vehicleTypeId == 0)
                    {
                        vehicleTypeId = AppVars.objPolicyConfiguration.DefaultVehicleTypeId.ToInt();
                    }

                    grdBookings.Rows[rowNo].Cells[COLS.VehicleType].Value = vehicleTypeId;


                    grdBookings.Rows[rowNo].Cells[COLS.PhoneNo].Value   = phone;
                    grdBookings.Rows[rowNo].Cells[COLS.Passenger].Value = passenger;
                    grdBookings.Rows[rowNo].Cells[COLS.From].Value      = from;
                    grdBookings.Rows[rowNo].Cells[COLS.To].Value        = to;
                    grdBookings.Rows[rowNo].Cells[COLS.Notes].Value     = comment;
                    grdBookings.Rows[rowNo].Cells[COLS.Account].Value   = account;

                    rowNo++;



                    //   }
                }
            }
            catch (Exception ex)
            {
            }

            finally
            {
            }
        }
        private void PasteData()
        {
            List <Gen_Company> listofCompany = General.GetQueryable <Gen_Company>(null).ToList();

            objWBView.GetLock();


            int rowsCnt = objWBView.ActiveWorksheet.UsedRange.RowCount;
            int cellCnt = objWBView.ActiveWorksheet.UsedRange.CellCount.ToInt();

            if (cellCnt < 2)
            {
                return;
            }



            try
            {
                grdBookings.RowCount = rowsCnt;
                for (int i = 0; i < rowsCnt; i++)
                {
                    //for (int j = 0; j < 1; j++)
                    //{
                    DateTime pickupdate = objWBView.ActiveWorksheet.Cells[i, 0].Value.ToDateTime();
                    string   vehicle    = objWBView.ActiveWorksheet.Cells[i, 1].Value.ToStr().Trim();



                    string phone     = objWBView.ActiveWorksheet.Cells[i, 2].Value.ToStr().Trim().ToLower();
                    string passenger = objWBView.ActiveWorksheet.Cells[i, 3].Value.ToStr().Trim();
                    string from      = objWBView.ActiveWorksheet.Cells[i, 4].Value.ToStr().Trim().ToLower();
                    string to        = objWBView.ActiveWorksheet.Cells[i, 5].Value.ToStr().Trim();
                    string comment   = objWBView.ActiveWorksheet.Cells[i, 6].Value.ToStr().Trim().ToLower();
                    string account   = objWBView.ActiveWorksheet.Cells[i, 7].Value.ToStr().Trim();



                    if (!string.IsNullOrEmpty(account) && account != "Cash" && listofCompany.Count(c => c.CompanyName.ToLower() == account.ToLower()) == 0)
                    {
                        CompanyBO objCompanyMaster = new CompanyBO();
                        try
                        {
                            objCompanyMaster.New();

                            objCompanyMaster.Current.CompanyName = account;
                            objCompanyMaster.Current.Email       = "*****@*****.**";
                            objCompanyMaster.Current.ContactName = account;
                            objCompanyMaster.Current.Address     = "unknown";
                            objCompanyMaster.Current.TelephoneNo = string.Empty;
                            objCompanyMaster.Current.MobileNo    = string.Empty;
                            objCompanyMaster.Current.WebsiteUrl  = string.Empty;
                            objCompanyMaster.Current.Fax         = string.Empty;

                            objCompanyMaster.Current.IsClosed = false;

                            objCompanyMaster.Current.HasOrderNo       = false;
                            objCompanyMaster.Current.HasPupilNo       = false;
                            objCompanyMaster.Current.AdminFees        = 0;
                            objCompanyMaster.Current.HasComcabCharges = false;

                            objCompanyMaster.Current.DiscountPercentage = 0;

                            objCompanyMaster.Current.FareDeductionPercent = 0;

                            objCompanyMaster.Current.HasVat = false;

                            objCompanyMaster.Current.HasBookedBy = false;

                            objCompanyMaster.Current.CompanyCode = string.Empty;

                            objCompanyMaster.Current.AccountTypeId = Enums.ACCOUNT_TYPE.ACCOUNT;


                            objCompanyMaster.Current.AccountNo        = string.Empty;
                            objCompanyMaster.Current.WebLoginId       = string.Empty;
                            objCompanyMaster.Current.WebLoginPassword = string.Empty;
                            objCompanyMaster.Current.IsWebLoginActive = false;


                            objCompanyMaster.Current.BackgroundColor = string.Empty;
                            objCompanyMaster.Current.TextColor       = string.Empty;
                            objCompanyMaster.Current.PasswordAccount = string.Empty;
                            objCompanyMaster.Current.PasswordEnable  = false;

                            objCompanyMaster.Save();



                            listofCompany.Add(objCompanyMaster.Current);
                        }
                        catch (Exception ex)
                        {
                            if (objCompanyMaster.Errors.Count > 0)
                            {
                                MessageBox.Show(objCompanyMaster.ShowErrors());
                            }

                            break;
                        }
                    }



                    string via      = objWBView.ActiveWorksheet.Cells[i, 8].Value.ToStr().Trim();
                    string flightno = objWBView.ActiveWorksheet.Cells[i, 9].Value.ToStr().Trim();



                    grdBookings.Rows[i].Cells[COLS.PickupDateTime].Value = pickupdate;



                    int vehicleTypeId = General.GetObject <Fleet_VehicleType>(c => c.VehicleType.ToLower() == vehicle.ToLower()).DefaultIfEmpty().Id;

                    if (vehicleTypeId == 0)
                    {
                        vehicleTypeId = AppVars.objPolicyConfiguration.DefaultVehicleTypeId.ToInt();
                    }

                    grdBookings.Rows[i].Cells[COLS.VehicleType].Value = vehicleTypeId;


                    grdBookings.Rows[i].Cells[COLS.PhoneNo].Value   = phone;
                    grdBookings.Rows[i].Cells[COLS.Passenger].Value = passenger;
                    grdBookings.Rows[i].Cells[COLS.From].Value      = from;
                    grdBookings.Rows[i].Cells[COLS.To].Value        = to;
                    grdBookings.Rows[i].Cells[COLS.Notes].Value     = comment;
                    grdBookings.Rows[i].Cells[COLS.Account].Value   = account;



                    grdBookings.Rows[i].Cells[COLS.Via].Value      = via;
                    grdBookings.Rows[i].Cells[COLS.FlightNo].Value = flightno;



                    //   }
                }
            }
            catch (Exception ex)
            {
            }

            finally
            {
                objWBView.ActiveWorksheet.Cells.Delete();

                objWBView.ReleaseLock();
            }
        }
Example #3
0
        public override void Save()
        {
            try
            {
                var list = (from a in grdCompanyCharges.Rows
                            select new
                {
                    Id = a.Cells[COL_CompanyCharges.Id].Value.ToInt(),

                    MileageId = a.Cells[COL_CompanyCharges.MileageId].Value.ToInt(),
                    Mileage = a.Cells[COL_CompanyCharges.Mileage].Value.ToBool(),

                    FaresId = a.Cells[COL_CompanyCharges.FaresId].Value.ToInt(),
                    Fares = a.Cells[COL_CompanyCharges.Fares].Value.ToBool(),

                    ParkingChargesId = a.Cells[COL_CompanyCharges.ParkingChargesId].Value.ToInt(),
                    ParkingCharges = a.Cells[COL_CompanyCharges.ParkingCharges].Value.ToBool(),

                    WaitingTimeId = a.Cells[COL_CompanyCharges.WaitingTimeId].Value.ToInt(),
                    WaitingTime = a.Cells[COL_CompanyCharges.WaitingTime].Value.ToBool(),

                    PassengerId = a.Cells[COL_CompanyCharges.PassengerId].Value.ToInt(),
                    Passenger = a.Cells[COL_CompanyCharges.Passenger].Value.ToBool(),

                    ExtraChargesId = a.Cells[COL_CompanyCharges.ExtraChargesId].Value.ToInt(),
                    ExtraCharges = a.Cells[COL_CompanyCharges.ExtraCharges].Value.ToBool(),

                    SignatureId = a.Cells[COL_CompanyCharges.SignatureId].Value.ToInt(),
                    Signature = a.Cells[COL_CompanyCharges.Signature].Value.ToBool(),
                }).ToList();

                int CompanyId = 0;
                foreach (var item in list)
                {
                    CompanyId = item.Id;

                    var list2 = list.Where(c => c.Id == CompanyId).ToList();

                    var list3 = (from a in list2
                                 select new
                    {
                        CompanyId = a.Id,
                        MileageId = a.Mileage == true ? a.MileageId.ToIntorNull() : null,
                        FaresId = a.Fares == true ? a.FaresId.ToIntorNull() : null,
                        ExtraChargesId = a.ExtraCharges == true ? a.ExtraChargesId.ToIntorNull() : null,
                        WaitingTimeId = a.WaitingTime == true ? a.WaitingTimeId.ToIntorNull() : null,
                        ParkingChargesId = a.ParkingCharges == true ? a.ParkingChargesId.ToIntorNull() : null,
                        PassengerId = a.Passenger == true ? a.PassengerId.ToIntorNull() : null,
                        SignatureId = a.Signature == true ? a.SignatureId.ToIntorNull() : null,
                    }).ToList();

                    List <Gen_Company_ExtraCharge> objCharges = new List <Gen_Company_ExtraCharge>();

                    foreach (var item3 in list3)
                    {
                        if (item3.MileageId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.MileageId
                            });
                        }
                        if (item3.FaresId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.FaresId
                            });
                        }
                        if (item3.ParkingChargesId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.ParkingChargesId
                            });
                        }
                        if (item3.ExtraChargesId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.ExtraChargesId
                            });
                        }
                        if (item3.WaitingTimeId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.WaitingTimeId
                            });
                        }
                        if (item3.PassengerId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.PassengerId
                            });
                        }
                        if (item3.SignatureId != null)
                        {
                            objCharges.Add(new Gen_Company_ExtraCharge {
                                CompanyId = item3.CompanyId, Charges = item3.SignatureId
                            });
                        }
                    }
                    objMaster.GetByPrimaryKey(CompanyId);
                    objMaster.Edit();
                    string[] skipChargesProperties = { "Gen_Company", "Gen_Charge" };

                    IList <Gen_Company_ExtraCharge> savedChargesList = objMaster.Current.Gen_Company_ExtraCharges;

                    Utils.General.SyncChildCollection(ref savedChargesList, ref objCharges, "Id", skipChargesProperties);
                    objMaster.Save();
                    objMaster.Clear();
                }

                ENUtils.ShowMessage("Account Additional Charges saved successfully.");
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }