public ActionResult CreateProcess(FormCollection frm)
        {
            int kt = 0;
            try
            {
                int ? parentId = null;
                if (frm["ParentId"] != "" && frm["ParentId"]!=null)
                {
                    parentId = int.Parse(frm["ParentId"]);
                }

                int? postion = null;
                if (frm["Position"] != null && frm["Position"] != "")
                {
                    postion = int.Parse(frm["Position"]);
                }
                // TODO: Add insert logic here
                Models.Informations ad = new Models.Informations()
                {
                    Subject = frm["Subject"],
                    TextTooltip = frm["TextTooltip"],
                    Contents = frm["Contents"],
                    Links = frm["Links"],
                    ParentId = parentId,
                    Position= postion

                };

                kt = InformationsBusiness.AddInformations(ad);
            }
            catch
            {
                kt = 0;
            }

            if (kt > 0)
            {
                return RedirectToAction("ListInformations", "Informations", new { add = "success" });
            }
            else
            {
                return RedirectToAction("ListInformations", "Informations", new { add = "error" });
            }
        }
        public static int AddInformations(Informations ad)
        {
            int ins = 0;
            try
            {
                if (ad.ParentId != null)
                {
                    int? maxPos = GetMaxPositionBaseOnParent((int)(ad.ParentId));

                    if (ad.Position != null)
                    {
                        if (maxPos == null)
                        {
                            ad.Position = 1;
                        }
                        else
                        {
                            if (ad.Position > maxPos)
                            {
                                ad.Position = maxPos + 1;
                            }
                            else
                            {
                                int kt = UpdatePostion((int)ad.ParentId, (int)ad.Position,null,"asc");
                            }
                        }
                    }

                }
                ins = DataAccessLayer.InformationsDA.AddInfor(ad);
            }
            catch (Exception)
            {
                return 0;
            }

            return ins;
        }
        public static int EditInformations(Informations ad)
        {
            int upt = 0;
            int check = 0;
            try
            {
                Informations inforOld = InformationsBusiness.GetInformationsById(ad.Id)[0];

                if (ad.ParentId != null)
                {
                    int? maxPos = GetMaxPositionBaseOnParent((int)(ad.ParentId));

                    if (ad.Position != null)
                    {
                        if (maxPos == null)
                        {
                            ad.Position = 1;
                        }
                        else
                        {
                            if (inforOld.Position != null)
                            {
                                if (ad.Position >= maxPos)
                                {
                                    UpdatePostionDesc((int)ad.ParentId, (int)inforOld.Position);
                                    ad.Position = maxPos;
                                }
                                else
                                {
                                    if (ad.Position < inforOld.Position)
                                    {
                                        UpdatePostion((int)ad.ParentId, (int)ad.Position,null,"asc");
                                        if (ad.ParentId == inforOld.ParentId)
                                        {
                                            check = 1;
                                        }
                                    }
                                    else
                                    {
                                        UpdatePostion((int)ad.ParentId, (int)ad.Position,inforOld.Position,"dessc");
                                    }
                                }
                            }
                            else
                            {
                                if (ad.Position > maxPos)
                                {
                                    ad.Position = maxPos + 1;
                                }
                                else
                                {
                                    int kt = UpdatePostion((int)ad.ParentId, (int)ad.Position,null,"asc");
                                }
                            }
                        }
                    }
                    else if (ad.Position == null && inforOld.Position!= null)
                    {
                        if (ad.ParentId != inforOld.ParentId)
                        {
                            UpdatePostionDesc((int)inforOld.ParentId, (int)inforOld.Position);
                        }
                        else
                        {
                            UpdatePostionDesc((int)ad.ParentId,(int)inforOld.Position);
                        }
                    }
                }
                upt = DataAccessLayer.InformationsDA.EditInfor(ad);
                if (upt > 0 && check == 1)
                {
                    UpdatePostionDesc((int)ad.ParentId, (int)inforOld.Position);
                }
            }
            catch (Exception)
            {
                return 0;
            }
            return upt;
        }
        private static List<Informations> AddInformationToList(DataTable dt)
        {
            List<Informations> ls = new List<Informations>();
            try
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int? position = null;
                    int? parentId = null;
                    if (dt.Rows[i]["Position"].ToString() != "")
                    {
                        position = int.Parse(dt.Rows[i]["Position"].ToString());
                    }
                    if (dt.Rows[i]["ParentId"].ToString() != "")
                    {
                        parentId = int.Parse(dt.Rows[i]["ParentId"].ToString());
                    }
                    Informations ad = new Informations()
                    {
                        Id = int.Parse(dt.Rows[i]["Id"].ToString()),
                        Subject = dt.Rows[i]["Subject"].ToString(),
                        TextTooltip = dt.Rows[i]["TextTooltip"].ToString(),
                        Contents = dt.Rows[i]["Contents"].ToString(),
                        ParentId = parentId,
                        ParentName = dt.Rows[i]["ParentName"].ToString(),
                        Position = position,
                        IsDeleted = int.Parse(dt.Rows[i]["IsDeleted"].ToString()),
                        Links = dt.Rows[i]["Links"].ToString()
                    };

                    ls.Add(ad);

                }
            }
            catch (Exception)
            {
                return new List<Informations>();
            }
            return ls;
        }