예제 #1
0
        public bool EditDeliveryServiceField(int id, string code, string value, out string msg)
        {
            bool res             = false;
            var  deliveryService = new pdv_deliveryService();

            try
            {
                deliveryService = GetDeliveryService(id);

                if (deliveryService != null)
                {
                    switch (code)
                    {
                    case "name": deliveryService.name = value;
                        break;

                    case "code": deliveryService.code = value;
                        break;
                    }
                    SaveDeliveryService(deliveryService);
                    res = true;
                    msg = "Успешно";
                }
                else
                {
                    msg = "Не удалось найти статус документ";
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
                msg = "Произошла ошибка, поле не изменено";
            }
            return(res);
        }
예제 #2
0
        public ActionResult DeliveryServices_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);

            try
            {
                var fields             = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList();
                var newDeliveryService = new pdv_deliveryService
                {
                    id   = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)),
                    name = AjaxModel.GetValueFromSaveField("name", fields),
                    code = AjaxModel.GetValueFromSaveField("code", fields)
                };

                mng.Mails.SaveDeliveryService(newDeliveryService);
                return(Json(new
                {
                    result = true,
                    id = newDeliveryService.id,
                    msg = "Операция успешна"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                return(Json(new
                {
                    result = false,
                    id = 0,
                    msg = "Ошибка"
                }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public int SaveDeliveryService(pdv_deliveryService item, bool withSave = true)
        {
            var res = 0;

            try
            {
                res = _db.SaveDeliveryService(item);
            }
            catch (Exception ex)
            {
                _debug(ex, new { item }, "item");
            }
            return(res);
        }
예제 #4
0
        public pdv_deliveryService GetDeliveryService(int id)
        {
            var res = new pdv_deliveryService();

            try
            {
                res = _db.GetDeliveryService().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
                _debug(ex, new { }, "");
            }
            return(res);
        }
예제 #5
0
 public int SaveDeliveryService(pdv_deliveryService element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.pdv_deliveryService.Add(element);
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
     }
     if (withSave)
     {
         Save();
     }
     return(element.id);
 }