Пример #1
0
        private static List <VehicleStatusBL> BuildFromTable(DataTable dtTable)
        {
            List <VehicleStatusBL> _list = new List <VehicleStatusBL>();

            if (dtTable != null)
            {
                foreach (DataRow dr in dtTable.Rows)
                {
                    VehicleStatusBL _thisMember = new VehicleStatusBL(dr);
                    _list.Add(_thisMember);
                }
            }
            return(_list);
        }
Пример #2
0
        public static List <VehicleStatusBL> getVehicleStatusByShopId(Int32 iShopId)
        {
            List <VehicleStatusBL> lstVehicleStatus = new List <VehicleStatusBL>();

            try
            {
                int iUnsoldEstimateId   = -1;
                int iImpoetedEstimateId = -2;
                int iDelivetedId        = 0;

                List <VehicleStatusBL> lstVehicleStatusForShop = VehicleStatusBL.getDataByShopId(iShopId);
                if (lstVehicleStatusForShop != null && lstVehicleStatusForShop.Count > 0)
                {
                    lstVehicleStatus = lstVehicleStatusForShop;
                }
                //check for unsold estimate is exist into database; if not then add with index -1; do same for other 2 also
                VehicleStatusBL objUnsoldEstimate = lstVehicleStatus.Find(_objUnsoldEstimate => _objUnsoldEstimate.strVehicleStatus == "Unsold Estimate");
                if (objUnsoldEstimate == null)
                {
                    VehicleStatusBL _objUnsoldEstimate = new VehicleStatusBL("Unsold Estimate", -1);
                    lstVehicleStatus.Add(_objUnsoldEstimate);
                }
                else
                {
                    //If exist then take the id because the old records may contain old id as -1
                    iUnsoldEstimateId = objUnsoldEstimate.ID;
                }

                VehicleStatusBL objImportedEstimate = lstVehicleStatus.Find(_objImportedEstimate => _objImportedEstimate.strVehicleStatus == "Imported Estimate");
                if (objImportedEstimate == null)
                {
                    VehicleStatusBL _objImportedEstimate = new VehicleStatusBL("Imported Estimate", -2);
                    lstVehicleStatus.Add(_objImportedEstimate);
                }
                else
                {
                    iImpoetedEstimateId = objImportedEstimate.ID;
                }

                VehicleStatusBL objDelivered = lstVehicleStatus.Find(_objDelivered => _objDelivered.strVehicleStatus == "Delivered");
                if (objDelivered == null)
                {
                    VehicleStatusBL _objDelivered = new VehicleStatusBL("Delivered", 0);
                    lstVehicleStatus.Add(_objDelivered);
                }
                else
                {
                    iDelivetedId = objDelivered.ID;
                }

                VehicleStatusBL objImportedEstimtes = lstVehicleStatus.Find(_objVehicleStatus => _objVehicleStatus.strVehicleStatus == "Imported Estimate");
                if (objImportedEstimtes != null)
                {
                    lstVehicleStatus.Remove(objImportedEstimtes);
                    lstVehicleStatus.Insert(0, objImportedEstimtes);
                }
            }
            catch (Exception ex)
            {
            }
            return(lstVehicleStatus);
        }