Ejemplo n.º 1
0
        public static List <TruckTypeBLL> GetAll()
        {
            string strSql = "spGetAllTruckType";

            SqlDataReader       reader;
            SqlConnection       conn = null;
            List <TruckTypeBLL> list;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql);
                if (reader.HasRows)
                {
                    list = new List <TruckTypeBLL>();
                    while (reader.Read())
                    {
                        TruckTypeBLL obj = new TruckTypeBLL();
                        if (reader["Id"] == DBNull.Value)
                        {
                            throw new InvalidIdException("Id Can't be null");
                        }
                        obj.Id            = new Guid(reader["Id"].ToString());
                        obj.TruckTypeName = reader["TruckTypeName"].ToString();
                        obj.Status        = (TruckStatus)(int.Parse(reader["Status"].ToString()));
                        if (reader["CreatedBy"] != DBNull.Value)
                        {
                            obj.CreatedBy = new Guid(reader["CreatedBy"].ToString());
                        }
                        if (reader["CreatedTimestamp"] != DBNull.Value)
                        {
                            obj.CreatedTimestamp = DateTime.Parse(reader["CreatedTimestamp"].ToString());
                        }
                        if (reader["LastModifiedBy"] != DBNull.Value)
                        {
                            obj.LastModifiedBy = new Guid(reader["LastModifiedBy"].ToString());
                        }
                        if (reader["LastModifiedTimestamp"] != DBNull.Value)
                        {
                            obj.LastModifiedTimestamp = DateTime.Parse(reader["LastModifiedTimestamp"].ToString());
                        }

                        list.Add(obj);
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        protected void FindTruckRegistration(string truckNo, bool isTrailer)
        {
            ((TruckInfo)SubscriberData).TruckTypeId      = Guid.Empty;
            ((TruckInfo)SubscriberData).TruckModelId     = Guid.Empty;
            ((TruckInfo)SubscriberData).TruckModelYearId = Guid.Empty;
            ((TruckInfo)SubscriberData).IsNew            = false;

            TruckRegisterBLL obj = null;

            if (truckNo.Trim() != string.Empty)
            {
                obj = new TruckRegisterBLL().GetTruckInfoByTruckNumber(truckNo, isTrailer);
            }
            if (obj != null)
            {
                TruckModelYearBLL objTMY = new TruckModelYearBLL();
                objTMY = objTMY.GetbyId(obj.TruckModelYearId);
                if (objTMY != null)
                {
                    ((TruckInfo)SubscriberData).TruckModelYearId = objTMY.Id;
                    TruckModelBLL objTM = new TruckModelBLL();
                    objTM = objTM.GetbyId(objTMY.TruckModelId);
                    if (objTM != null)
                    {
                        ((TruckInfo)SubscriberData).TruckModelId = objTM.Id;
                        TruckTypeBLL objTT = new TruckTypeBLL();
                        objTT = objTT.GetbyId(objTM.TruckTypeId);
                        if (objTT != null)
                        {
                            ((TruckInfo)SubscriberData).TruckTypeId = objTT.Id;
                        }
                    }
                }
            }
            else
            {
                ((TruckInfo)SubscriberData).IsNew = true;
            }
            foreach (Control subscriber in Subscribers)
            {
                if (subscriber == null)
                {
                    continue;
                }
                switch (subscriber.ID)
                {
                case "cddExtender_TruckTypeId":
                    ((CascadingDropDown)subscriber).SelectedValue = (((TruckInfo)SubscriberData).TruckTypeId.ToString());
                    break;

                case "cddExtender_TruckModelId":
                    ((CascadingDropDown)subscriber).SelectedValue = (((TruckInfo)SubscriberData).TruckModelId.ToString());
                    break;

                case "cddExtender_TruckModelYearId":
                    ((CascadingDropDown)subscriber).SelectedValue = (((TruckInfo)SubscriberData).TruckModelYearId.ToString());
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 private static int TruckTypeComp(TruckTypeBLL ltt, TruckTypeBLL rtt)
 {
     if (ltt == null)
     {
         if (rtt == null)
         {
             return(0);
         }
         else
         {
             return(1);
         }
     }
     else
     {
         if (rtt == null)
         {
             return(-1);
         }
         else
         {
             return(ltt.TruckTypeName.CompareTo(rtt.TruckTypeName));
         }
     }
 }
Ejemplo n.º 4
0
        public CascadingDropDownNameValue[] GetAllTruckType(string knownCategoryValues, string category)
        {
            List <CascadingDropDownNameValue> l = new List <CascadingDropDownNameValue>();
            TruckTypeBLL        objTruckType    = new TruckTypeBLL();
            List <TruckTypeBLL> list            = new List <TruckTypeBLL>();

            list = objTruckType.GetAllTrucksTypes();
            foreach (TruckTypeBLL o in list)
            {
                l.Add(new CascadingDropDownNameValue(o.TruckTypeName.ToString(), o.Id.ToString()));
            }


            return(l.ToArray());
        }
Ejemplo n.º 5
0
        protected void txtTrailerPlateNo_TextChanged(object sender, EventArgs e)
        {
            ViewState["TrailerRegisterId"] = null;
            Nullable <Guid> TruckTypeId, TruckModelId;

            TruckTypeId  = null;
            TruckModelId = null;

            TruckRegisterBLL obj = new TruckRegisterBLL();

            obj = obj.GetTruckInfoByTruckNumber(this.txtTrailerPlateNo.Text, true);
            if (obj != null)
            {
                TruckModelYearBLL objTMY = new TruckModelYearBLL();
                objTMY = objTMY.GetbyId(obj.TruckModelYearId);
                if (objTMY != null)
                {
                    TruckModelBLL objTM = new TruckModelBLL();
                    objTM = objTM.GetbyId(objTMY.TruckModelId);
                    if (objTM != null)
                    {
                        TruckTypeBLL objTT = new TruckTypeBLL();
                        objTT        = objTT.GetbyId(objTM.TruckTypeId);
                        TruckModelId = objTM.Id;
                        if (objTT != null)
                        {
                            TruckTypeId = objTT.Id;
                        }
                    }
                }


                if (TruckTypeId != null)
                {
                    this.cboTruckType2_CascadingDropDown1.SelectedValue = TruckTypeId.ToString();
                }
                if (TruckModelId != null)
                {
                    this.cboTrailerModel_CascadingDropDown2.SelectedValue = TruckModelId.ToString();
                }
                if (obj.TruckModelYearId != null)
                {
                    this.cboTrailerModelYear_CascadingDropDown3.SelectedValue = obj.TruckModelYearId.ToString();
                }
                this.cboTruckModel.Enabled     = false;
                ViewState["TrailerRegisterId"] = obj.Id.ToString();
            }// Big if
        }
Ejemplo n.º 6
0
        public CascadingDropDownNameValue[] GetTruckType(string knownCategoryValues, string category)
        {
            try
            {
                List <CascadingDropDownNameValue> l = new List <CascadingDropDownNameValue>();
                TruckTypeBLL        objTT           = new TruckTypeBLL();
                List <TruckTypeBLL> listTT          = new List <TruckTypeBLL>();
                listTT = objTT.GetActiveTrucksTypes().OrderBy(tt => tt.TruckTypeName).ToList();
                foreach (TruckTypeBLL o in listTT)
                {
                    l.Add(new CascadingDropDownNameValue(o.TruckTypeName, o.Id.ToString()));
                }

                return(l.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
            //private CachedDictionary<ECXLookUp.CNIDType> nidTypeLookup = new CachedDictionary<ECXLookUp.CNIDType>(
            //                delegate(ECXLookUp.CNIDType nidType)
            //                {
            //                    return nidType.Name;
            //                },
            //                delegate(object key)
            //                {
            //                    return null;
            //                },
            //                delegate()
            //                {
            //                    ECXLookUp.ECXLookup ecxLookup = new WarehouseApplication.ECXLookUp.ECXLookup();
            //                    ECXLookUp.CNIDType[] nidTypes = ecxLookup.GetActiveNIDTypes(BLL.Utility.GetWorkinglanguage());
            //                    List<KeyValuePair<object, WarehouseApplication.ECXLookUp.CNIDType>> kvps = new List<KeyValuePair<object, WarehouseApplication.ECXLookUp.CNIDType>>();
            //                    foreach (ECXLookUp.CNIDType nidType in nidTypes)
            //                    {
            //                        kvps.Add(new KeyValuePair<object, WarehouseApplication.ECXLookUp.CNIDType>(nidType.Id, nidType));
            //                    }
            //                    return kvps;
            //                });
            //private Dictionary<object, string> shedLookup = new Dictionary<object,string>();
            //private Dictionary<object, string> stackLookup = new Dictionary<object,string>();
            //private CachedDictionary<BagTypeBLL> bagTypeLookup = new CachedDictionary<BagTypeBLL>(
            //    delegate(BagTypeBLL bagType)
            //    {
            //        return bagType.BagTypeName;
            //    },
            //    delegate(object key)
            //    {
            //        return BagTypeBLL.GetBagType((Guid)key);
            //    },
            //    delegate()
            //    {
            //        List<KeyValuePair<object, BagTypeBLL>> kvps = new List<KeyValuePair<object, BagTypeBLL>>();
            //        foreach (BagTypeBLL bagType in BagTypeBLL.GetAllBagTypes())
            //        {
            //            kvps.Add(new KeyValuePair<object, BagTypeBLL>(bagType.Id, bagType));
            //        }
            //        return kvps;
            //    });

            //private WarehouseBLL currentWareHouse = new WarehouseBLL() {
            //    Code = "102",
            //    WarehouseId = new Guid("fa0a52e8-9308-4d5e-b323-88ca5ba232ed")
            //};
            #region ILookupSource Members

            public IDictionary <object, string> GetLookup(string lookupName)
            {
                try
                {
                    Dictionary <object, string> lookup = new Dictionary <object, string>();
                    switch (lookupName)
                    {
                    case "CommodityGrade":
                        return(new CachedDictionary <CommodityGradeBLL>(
                                   delegate(CommodityGradeBLL commodityGrade)
                        {
                            return commodityGrade.GradeName;
                        },
                                   delegate(object key)
                        {
                            return CommodityGradeBLL.GetCommodityGrade((Guid)key);
                        },
                                   delegate()
                        {
                            List <KeyValuePair <object, CommodityGradeBLL> > kvps = new List <KeyValuePair <object, CommodityGradeBLL> >();
                            foreach (CommodityGradeBLL commodityGrade in CommodityGradeBLL.GetAllCommodityDetail())
                            {
                                kvps.Add(new KeyValuePair <object, CommodityGradeBLL>(commodityGrade.CommodityGradeId, commodityGrade));
                            }
                            return kvps;
                        }));

                    case "Client":
                        return(new CachedDictionary <ClientBLL>(
                                   clientLookup,
                                   delegate(ClientBLL client)
                        {
                            return client.ClientName;
                        },
                                   delegate(object key)
                        {
                            return ClientBLL.GetClinet((Guid)key);
                        }));

                    case "ClientId":
                        return(new CachedDictionary <ClientBLL>(
                                   clientLookup,
                                   delegate(ClientBLL client)
                        {
                            return client.ClientId;
                        },
                                   delegate(object key)
                        {
                            return ClientBLL.GetClinet((Guid)key);
                        }));

                    case "Warehouse":
                        return(new CachedDictionary <WarehouseBLL>(
                                   warehouseLookup,
                                   delegate(WarehouseBLL warehouse)
                        {
                            return warehouse.WarehouseName;
                        },
                                   delegate(object key)
                        {
                            return WarehouseBLL.GetById((Guid)key);
                        }));

                    case "WarehouseManager":
                        return(new CachedDictionary <string>(
                                   delegate(string warehouseManager)
                        {
                            return warehouseManager;
                        },
                                   delegate(object key)
                        {
                            //return UserRightBLL.GetUsersWithRight("WHPWM").Find(u => u.UserId == (Guid)key).FullName;
                            return UserRightBLL.GetUserNameByUserId((Guid)key);
                        }));

                    case "NIDType":
                        //ICollection<object> keys = nidTypeLookup.Keys;
                        //return nidTypeLookup;
                        List <NIDTypeBLL> nidTypes = NIDTypeBLL.GetAllNIDTypes();
                        nidTypes.ForEach(nidType => lookup.Add(nidType.Id, nidType.Name));
                        break;

                    case "VerifyingClerk":
                        //return GetWorkersLookup("VerifyingClerk");
                        UserRightBLL.GetUsersWithRight("VerifyingClerk").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "InventoryController":
                        //return GetWorkersLookup("InventoryController");
                        UserRightBLL.GetUsersWithRight("InventoryController").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Loader":
                        //return GetWorkersLookup("Loader");
                        UserRightBLL.GetUsersWithRight("Loader").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Weigher":
                        //return GetWorkersLookup("Weigher");
                        UserRightBLL.GetUsersWithRight("Weigher").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Sampler":
                        //return GetWorkersLookup("Sampler");
                        UserRightBLL.GetUsersWithRight("Sampler").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Grader":
                        //return GetWorkersLookup("Grader");
                        UserRightBLL.GetUsersWithRight("Grader").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Gatekeeper":
                        //return GetWorkersLookup("Gatekeeper");
                        UserRightBLL.GetUsersWithRight("Gatekeeper").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "Inspector":
                        //return GetWorkersLookup("Gatekeeper");
                        UserRightBLL.GetUsersWithRight("WHPCT").ForEach(user => lookup.Add(user.UserId, user.FullName));
                        break;

                    case "BagType":
                        foreach (BagTypeBLL bagType in BagTypeBLL.GetAllBagTypes())
                        {
                            lookup.Add(bagType.Id, bagType.BagTypeName);
                        }
                        break;

                    case "BagWeight":
                        foreach (BagTypeBLL bagType in BagTypeBLL.GetAllBagTypes())
                        {
                            lookup.Add(bagType.Id, bagType.Tare.ToString());
                        }
                        break;

                    case "CurrentWarehouse":
                        lookup.Add("Id", WarehouseBLL.CurrentWarehouse.WarehouseId.ToString());
                        lookup.Add("WarehouseCode", WarehouseBLL.CurrentWarehouse.Code);
                        //lookup.Add("WarehouseManagerId", currentWareHouse.WarehouseId.ToString());
                        //lookup.Add("WarehouseManagerName", "");
                        break;

                    case "CurrentUser":
                        lookup.Add("Id", UserBLL.GetCurrentUser().ToString());
                        lookup.Add("Name", UserBLL.GetName(UserBLL.GetCurrentUser()));
                        break;

                    case "WorkerStatus":
                        lookup.Add(0, "Status 1");
                        lookup.Add(1, "Status 2");
                        break;

                    case "EmployeeRole":
                        lookup.Add(WorkType.GINGrading, "0e604921-ee27-4406-97ce-846b47b1cd75");
                        lookup.Add(WorkType.GINLoading, "0e604921-ee27-4406-97ce-846c47b1cd75");
                        lookup.Add(WorkType.GINSampling, "0e604921-ee27-4406-97ce-84db47b1cd75");
                        lookup.Add(WorkType.GINScaling, "0e604921-ee27-4406-97ce-846e47b1cd75");
                        break;

                    case "Shed":
                        foreach (ShedBLL shed in new ShedBLL().GetActiveShedByWarehouseId(WarehouseBLL.CurrentWarehouse.WarehouseId))
                        {
                            lookup.Add(shed.Id, shed.ShedNumber);
                        }
                        break;

                    case "Stack":
                        foreach (Guid shedId in GetLookup("Shed").Keys)
                        {
                            foreach (StackBLL stack in new StackBLL().GetActiveStackbyShedId(shedId))
                            {
                                lookup.Add(stack.Id, stack.StackNumber);
                            }
                        }
                        break;

                    case "TruckType":
                        lookup.Add(Guid.Empty, "Not Registred");
                        TruckTypeBLL        objTT = new TruckTypeBLL();
                        List <TruckTypeBLL> list  = objTT.GetActiveTrucksTypes();
                        list.Sort(TruckTypeComp);
                        list.ForEach(tt => lookup.Add(tt.Id, tt.TruckTypeName));
                        break;
                    }
                    lookup.OrderBy(lkup => lkup.Value);
                    return(lookup);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Item not found for the {0} lookup.", lookupName), ex);
                }
            }