Esempio n. 1
0
            /// <summary>
            /// Return Category List
            /// </summary>
            /// <returns>Category List</returns>
            public static Tuple <ErrorObject, List <tblCategory> > GetCategory()
            {
                List <tblCategory> c = new List <tblCategory>();

                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        c = db.tblCategory.OrderBy(d1 => d1.idCategory).ThenBy(d1 => d1.id).ToList();
                        return(new Tuple <ErrorObject, List <tblCategory> >(erros.IfError(false), c));
                    };
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblCategory> >(erros, c));
                }
            }
Esempio n. 2
0
            /// <summary>
            /// Return Department Information
            /// </summary>
            /// <param name="CategoryID">Category ID</param>
            /// <returns>Department Information</returns>
            public static Tuple <ErrorObject, tblCategory> GetCategory(int CategoryID)
            {
                tblCategory c = new tblCategory();

                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        c = db.tblCategory.Find(CategoryID);
                        return(new Tuple <ErrorObject, tblCategory>(erros.IfError(false), c));
                    }
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, tblCategory>(erros, c));
                }
            }
Esempio n. 3
0
            /// <summary>
            /// Return Department List To Only father
            /// </summary>
            /// <returns></returns>
            public static Tuple <ErrorObject, List <tblCategory> > GetCategoryToFather()
            {
                List <tblCategory> c = new List <tblCategory>();

                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        c = db.tblCategory.Where(f => f.idCategory.ToString() == String.Empty).ToList();
                        return(new Tuple <ErrorObject, List <tblCategory> >(erros.IfError(false), c));
                    }
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblCategory> >(erros, c));
                }
            }
Esempio n. 4
0
            /// <summary>
            /// Update Cellar Area Information
            /// </summary>
            /// <param name="data">Cellar Area Information</param>
            /// <returns>Number Affected Row</returns>
            public static Tuple <ErrorObject, string> CellarArea(tblCellarArea data)
            {
                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        db.Entry(data).State = EntityState.Modified;
                        result  = db.SaveChanges();
                        Message = "Affected Row: " + result.ToString();

                        return(new Tuple <ErrorObject, string>(erros.IfError(false), Message));
                    }
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, string>(erros, String.Empty));
                }
            }
Esempio n. 5
0
            /// <summary>
            /// Return Cellar Area Name
            /// </summary>
            /// <param name="id">CellarAreaID</param>
            /// <returns>Cellar Area Name</returns>
            public static Tuple <ErrorObject, tblCellarArea> GetCellarAreaName(int id)
            {
                tblCellarArea CellarArea = new tblCellarArea();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        CellarArea.name = db.tblCellarArea.Find(id).name;
                    }
                    erros.Error = false;
                    return(new Tuple <ErrorObject, tblCellarArea>(erros.IfError(false), CellarArea));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, tblCellarArea>(erros, CellarArea));
                }
            }
Esempio n. 6
0
            /// <summary>
            /// Return All Cellar Area
            /// </summary>
            /// <returns>All Cellar Area Or null If Exist Error</returns>
            public static Tuple <ErrorObject, List <tblCellarArea> > GetCellarArea()
            {
                List <tblCellarArea> CellarArea = new List <tblCellarArea>();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        CellarArea = db.tblCellarArea.ToList();
                    };

                    return(new Tuple <ErrorObject, List <tblCellarArea> >(erros.IfError(false), CellarArea));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblCellarArea> >(erros, CellarArea));
                }
            }
Esempio n. 7
0
            /// <summary>
            /// Return Department Name To Specific ID
            /// </summary>
            /// <param name="id">Department ID</param>
            /// <returns>Department Name</returns>
            public static Tuple <ErrorObject, tblDepartment> GetDepartmentName(int id)
            {
                tblDepartment Department = new tblDepartment();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        Department.name = db.tblDepartment.Find(id).name;
                    }
                    erros.Error = false;
                    return(new Tuple <ErrorObject, tblDepartment>(erros.IfError(false), Department));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, tblDepartment>(erros, Department));
                }
            }
Esempio n. 8
0
            /// <summary>
            /// Return All Department
            /// </summary>
            /// <returns>All Department Or null If Exist Error</returns>
            public static Tuple <ErrorObject, List <tblDepartment> > GetDepartment()
            {
                List <tblDepartment> Department = new List <tblDepartment>();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        Department = db.tblDepartment.ToList();
                    };

                    return(new Tuple <ErrorObject, List <tblDepartment> >(erros.IfError(false), Department));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblDepartment> >(erros, Department));
                }
            }
Esempio n. 9
0
            /// <summary>
            /// Return Assignment Type Name
            /// </summary>
            /// <param name="id">Assignment Type ID</param>
            /// <returns>Assignment Type Name</returns>
            public static Tuple <ErrorObject, tblAssignmentType> GetAssignmentTypeName(int id)
            {
                tblAssignmentType AssignmentType = new tblAssignmentType();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        AssignmentType.name = db.tblAssignmentType.Find(id).name;
                    }
                    erros.Error = false;
                    return(new Tuple <ErrorObject, tblAssignmentType>(erros.IfError(false), AssignmentType));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, tblAssignmentType>(erros, AssignmentType));
                }
            }
Esempio n. 10
0
            /// <summary>
            /// Return All Assignment Type
            /// </summary>
            /// <returns>All Assignment Type Or null If Exist Error</returns>
            public static Tuple <ErrorObject, List <tblAssignmentType> > GetAssignmentType()
            {
                List <tblAssignmentType> AssignmentType = new List <tblAssignmentType>();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        AssignmentType = db.tblAssignmentType.ToList();
                    };

                    return(new Tuple <ErrorObject, List <tblAssignmentType> >(erros.IfError(false), AssignmentType));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblAssignmentType> >(erros, AssignmentType));
                }
            }
Esempio n. 11
0
            /// <summary>
            /// Return Provider By Specific ID
            /// </summary>
            /// <param name="id">Provider ID</param>
            /// <returns>Provider By Specific ID Or null If Exist Error</returns>
            public static Tuple <ErrorObject, tblProvider> GetProvider(int id)
            {
                tblProvider Provider = new tblProvider();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        Provider = db.tblProvider.Find(id);
                    }
                    erros.Error = false;
                    return(new Tuple <ErrorObject, tblProvider>(erros.IfError(false), Provider));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, tblProvider>(erros, Provider));
                }
            }
Esempio n. 12
0
            /// <summary>
            /// Return All Provider
            /// </summary>
            /// <returns>All Provider Or null If Exist Error</returns>
            public static Tuple <ErrorObject, List <tblProvider> > GetProviderList()
            {
                List <tblProvider> Provider = new List <tblProvider>();

                erros = new ErrorObject();

                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        Provider = db.tblProvider.ToList();
                    };

                    return(new Tuple <ErrorObject, List <tblProvider> >(erros.IfError(false), Provider));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <tblProvider> >(erros, Provider));
                }
            }
Esempio n. 13
0
 /// <summary>
 /// Update State Fields To Specific Category ID
 /// </summary>
 /// <param name="CategoryID">Category ID</param>
 /// <param name="state"></param>
 /// <returns>Number Affected Row</returns>
 public static Tuple <ErrorObject, string> CategoryDisable(int CategoryID, string state)
 {
     erros = new ErrorObject();
     try
     {
         using (HSCMEntities db = new HSCMEntities())
         {
             var row = db.tblCategory.Single(p => p.id == CategoryID);
             row.state      = state;
             row.deleteDate = DateTime.Now;
             result         = db.SaveChanges();
             Message        = "Affected Row: " + result.ToString();
             erros.Error    = false;
             return(new Tuple <ErrorObject, string>(erros.IfError(false), Message));
         }
     }
     catch (Exception ex)
     {
         erros.InfoError(ex);
         return(new Tuple <ErrorObject, string>(erros, String.Empty));
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Return True Or False If Container Child
 /// </summary>
 /// <param name="id">Category ID</param>
 /// <returns>True Or False If Container Child</returns>
 public static Tuple <ErrorObject, bool> ContainerChild(int CategoryID)
 {
     erros = new ErrorObject();
     try
     {
         using (HSCMEntities db = new HSCMEntities())
         {
             var algo = db.tblCategory.Where(ty => ty.idCategory == CategoryID).ToList();
             if (algo.Count > 0)
             {
                 return(new Tuple <ErrorObject, bool>(erros, true));
             }
             else
             {
                 return(new Tuple <ErrorObject, bool>(erros, false));
             }
         }
     }
     catch (Exception ex)
     {
         erros.InfoError(ex);
         return(new Tuple <ErrorObject, bool>(erros, false));
     }
 }