예제 #1
0
        public bool EditActField(aspnet_Users userRol, int id, string code, string value, out string msg, Shtoda_acts user)
        {
            bool res      = false;
            var  document = new Shtoda_acts();

            try
            {
                if (!_IsCanUserChange(userRol))
                {
                    msg = "Недостаточна прав для редактирования!";
                }
                else
                {
                    document = GetAct(id);

                    if (document != null)
                    {
                        SaveAct(document);
                        res = true;
                        msg = "Успешно";
                    }
                    else
                    {
                        msg = "Не удалось найти документ";
                    }
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
예제 #2
0
        public bool EditAct(aspnet_Users user, int id, string name, string value, out string msg)
        {
            var res  = false;
            var item = new Shtoda_acts();

            msg = "";
            try
            {
                if (!_IsCanUserChange(user))
                {
                    msg = "Недостаточна прав для редактирования!";
                }

                else
                {
                    item = GetAct(id);
                    if (item != null)
                    {
                        switch (name)
                        {
                        case "desc":
                            item.desc = value;
                            break;

                        case "number":
                            item.number = value;
                            break;

                        case "statusName":
                            if (value != "")
                            {
                                item.statusID = RDL.Convert.StrToInt(value, 0);
                            }
                            break;

                        case "contagentName":
                            if (value != "")
                            {
                                item.contagentID = RDL.Convert.StrToInt(value, 0);
                            }
                            break;
                        }
                        SaveAct(item);
                        res = true;
                        msg = "Успешно";
                    }
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { id, name }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
예제 #3
0
 public void SaveAct(Shtoda_acts item)
 {
     try
     {
         _db.SaveAct(item);
     }
     catch (Exception ex)
     {
         _debug(ex, new { item }, "");
     }
 }
예제 #4
0
        public Shtoda_acts GetAct(int id)
        {
            var res = new Shtoda_acts();

            try
            {
                res = _db.GetActs().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { id }, "");
            }
            return(res);
        }
예제 #5
0
        public bool CreateAct(string name)
        {
            var res = false;
            var act = new Shtoda_acts();

            try
            {
                act = new Shtoda_acts {
                    id = 0, desc = name
                };
                SaveAct(act);
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { name }, "");
            }
            return(res);
        }