Exemplo n.º 1
0
            /// <summary>
            /// Update Category
            /// </summary>
            /// <param name="data">Category Information</param>
            /// <returns>Number Affected Row</returns>
            public static Tuple <ErrorObject, string> Category(tblCategory data)
            {
                erros = new ErrorObject();
                try
                {
                    using (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        var row = db.tblCategory.Single(p => p.id == data.id);
                        row.name         = data.name;
                        row.idCategory   = data.idCategory;
                        row.idCellarArea = data.idCellarArea;
                        row.detail       = data.detail;
                        row.upDateDate   = data.upDateDate;
                        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));
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Insert Department Information
            /// </summary>
            /// <param name="data">Department Information</param>
            /// <returns>Number Affected Row</returns>
            public static Tuple <ErrorObject, string> Department(tblDepartment data)
            {
                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        int propertyFind = db.tblDepartment.Count();
                        if (propertyFind > 0)
                        {
                            data.id = db.tblDepartment.Max(s => s.id);
                        }
                        else
                        {
                            data.id = 1;
                        }
                        db.tblDepartment.Add(data);
                        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));
                }
            }
Exemplo n.º 3
0
 /// <summary>
 /// Insert Category
 /// </summary>
 /// <param name="data">Information Cateogy</param>
 /// <returns>Number Affected Row</returns>
 public static Tuple <ErrorObject, string> Category(tblCategory data)
 {
     erros = new ErrorObject();
     try
     {
         using (EileenGaldamezEntities db = new EileenGaldamezEntities())
         {
             int propertyFind = db.tblCategory.Count();
             if (propertyFind > 0)
             {
                 data.id = db.tblCategory.Max(s => s.id + 1);
             }
             else
             {
                 data.id = 1;
             }
             db.tblCategory.Add(data);
             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));
     }
 }
Exemplo n.º 4
0
            /// <summary>
            /// Return all items to menu
            /// </summary>
            /// <returns>All items to menu</returns>
            public static Tuple <ErrorObject, List <GetMenuResult> > GetCellarAreaListMenu()
            {
                List <GetMenuResult> data = new List <GetMenuResult>();

                erros = new ErrorObject();

                try
                {
                    using (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        var datas = (from CA in db.tblCellarArea
                                     join C in db.tblCategory
                                     on CA.id equals C.idCellarArea
                                     select new GetMenuResult {
                            Department = CA.name,
                            CategoryID = C.id,
                            CellarAreaID = CA.id,
                            FatherCategoryID = (int)C.idCategory,
                            Area = C.name
                        }).OrderBy(C => C.CellarAreaID).ToList();

                        foreach (var data3 in datas)
                        {
                            int f = (from C in db.tblCategory where C.idCategory == data3.CategoryID select C.id).Count();

                            data.Add(new GetMenuResult()
                            {
                                Area             = data3.Area,
                                CellarAreaID     = data3.CellarAreaID,
                                CategoryID       = data3.CategoryID,
                                Department       = data3.Department,
                                FatherCategoryID = data3.FatherCategoryID,
                                Father           = (f > 0 ? true : false)
                            });
                        }
                    };

                    return(new Tuple <ErrorObject, List <GetMenuResult> >(erros.IfError(false), data));
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, List <GetMenuResult> >(erros, data));
                }
            }
Exemplo n.º 5
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 (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        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));
                }
            }
Exemplo n.º 6
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));
                }
            }
Exemplo n.º 7
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 (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        c = db.tblCategory.OrderBy(d1 => d1.idCategory).OrderBy(d1 => d1.id).OrderBy(f => f.idCellarArea).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));
                }
            }
Exemplo n.º 8
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));
                }
            }
Exemplo n.º 9
0
            /// <summary>
            /// Update Category and All category child
            /// </summary>
            /// <param name="data">Category information</param>
            /// <returns>Number Affected Row</returns>
            public static Tuple <ErrorObject, string> CategoryAndAllChildCellarArea(tblCategory data)
            {
                List <int> Child = new List <int>();

                erros = new ErrorObject();
                try
                {
                    using (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        var row = db.tblCategory.Single(p => p.id == data.id);
                        row.name         = data.name;
                        row.idCategory   = data.idCategory;
                        row.idCellarArea = data.idCellarArea;
                        row.detail       = data.detail;
                        row.upDateDate   = data.upDateDate;
                        result           = db.SaveChanges();
                        Message          = "Affected Row: " + result.ToString();

                        Child = (
                            from C in db.tblCategory
                            where C.idCategory == data.id
                            select C.id).ToList();

                        if (Child.Count > 0)
                        {
                            foreach (var item in Child)
                            {
                                var row2 = db.tblCategory.Single(p => p.id == item);
                                row2.idCellarArea = data.idCellarArea;
                                db.SaveChanges();
                            }
                        }
                        return(new Tuple <ErrorObject, string>(erros.IfError(false), Message));
                    }
                }
                catch (Exception ex)
                {
                    erros.InfoError(ex);
                    return(new Tuple <ErrorObject, string>(erros, String.Empty));
                }
            }
Exemplo n.º 10
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));
                }
            }
Exemplo 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 (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        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));
                }
            }
Exemplo 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 (EileenGaldamezEntities db = new EileenGaldamezEntities())
                    {
                        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));
                }
            }
Exemplo n.º 13
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));
                }
            }
Exemplo n.º 14
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));
                }
            }
Exemplo n.º 15
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));
                }
            }
Exemplo n.º 16
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));
                }
            }
Exemplo n.º 17
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));
                }
            }
Exemplo n.º 18
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 (EileenGaldamezEntities db = new EileenGaldamezEntities())
         {
             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));
     }
 }
Exemplo n.º 19
0
            /// <summary>
            /// Update State Fields To Specific AssignmentType ID
            /// </summary>
            /// <param name="AssignmentTypeID">AssignmentType ID</param>
            /// <param name="state">Active Or Disable</param>
            /// <returns>AssignmentType ID</returns>
            public static Tuple <ErrorObject, string> AssignmentTypeDisable(int AssignmentTypeID, string state)
            {
                erros = new ErrorObject();
                try
                {
                    using (HSCMEntities db = new HSCMEntities())
                    {
                        var row = db.tblAssignmentType.Single(p => p.id == AssignmentTypeID);
                        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));
                }
            }