public bool UpdateDetails(ExpenseCategoryModel smodel)
        {
            connection();
            SqlCommand cmd = new SqlCommand("UpdateexpenseCategory", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@id", smodel.id);
            cmd.Parameters.AddWithValue("@detail", smodel.detail);
            cmd.Parameters.AddWithValue("@priority", smodel.priority);

            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();

            if (i >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 根据编号获取数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult GetExpenseCategoryById(string id)
        {
            var retModel = new JsonReturnModel();

            try
            {
                var bootItem = inn.newItem("b_ExpenseCategory", "get");
                bootItem.setAttribute("id", id);
                Item result = bootItem.apply();
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }
                ExpenseCategoryModel model = new ExpenseCategoryModel();

                model.Id                 = result.getProperty("id");
                model.b_CostName         = result.getProperty("b_costname");
                model.b_CorresponSubject = result.getProperty("b_corresponsubject");
                retModel.data            = model;
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit(int id, ExpenseCategoryModel smodel)
 {
     try {
         ExpenseCategoryDBHandle sdb = new ExpenseCategoryDBHandle();
         sdb.UpdateDetails(smodel);
         return(RedirectToAction("Index"));
     } catch {
         return(View());
     }
 }
        /// <summary>
        /// 支出类别关系的改变
        /// </summary>
        /// <param name="OrgCode"></param>
        /// <param name="OrgPhId"></param>
        /// <param name="mydelete"></param>
        /// <param name="myinsert"></param>
        /// <returns></returns>
        public CommonResult <CorrespondenceSettings2Model> UpdateZCLB(string OrgCode, string OrgPhId, List <CorrespondenceSettings2Model> mydelete, List <ExpenseCategoryModel> myinsert)
        {
            CommonResult <CorrespondenceSettings2Model> result = new CommonResult <CorrespondenceSettings2Model>();

            if (mydelete != null && mydelete.Count > 0)
            {
                for (int i = 0; i < mydelete.Count; i++)
                {
                    CorrespondenceSettings2Model delete = mydelete[i];
                    var Deleteid = delete.PhId;
                    try
                    {
                        base.Delete <System.Int64>(Deleteid);
                    }
                    catch (Exception e)
                    {
                        result.Status = ResponseStatus.Error;
                        result.Msg    = "设置失败,请重新设置!";
                    }
                }
            }
            if (myinsert != null && myinsert.Count > 0)
            {
                for (int i = 0; i < myinsert.Count; i++)
                {
                    ExpenseCategoryModel insert = myinsert[i];
                    var Dwdm    = OrgPhId;
                    var Dydm    = insert.Dm;
                    var Dylx    = "08";
                    var DefStr1 = OrgCode;
                    try
                    {
                        CorrespondenceSettings2Model correspondence = new CorrespondenceSettings2Model();
                        correspondence.PersistentState = SUP.Common.Base.PersistentState.Added;
                        correspondence.Dwdm            = Dwdm;
                        correspondence.Dydm            = Dydm;
                        correspondence.Dylx            = Dylx;
                        correspondence.DefStr1         = DefStr1;
                        correspondence.DefStr2         = "0";
                        SavedResult <Int64> savedResult2 = base.Save <Int64>(correspondence, "");
                    }
                    catch (Exception e)
                    {
                        result.Status = ResponseStatus.Error;
                        result.Msg    = "设置失败,请重新设置!";
                    }
                }
            }
            return(result);
        }
        private List <ExpenseCategoryModel> MapDataTableToExpenseCategory(DataTable dt)
        {
            List <ExpenseCategoryModel> result = new List <ExpenseCategoryModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.AsEnumerable())
                {
                    var obj = new ExpenseCategoryModel();
                    obj.CategoryId   = Convert.ToInt32(dr["CategoryID"]);
                    obj.CategoryName = dr["Name"].ToString();
                    result.Add(obj);
                }
            }

            return(result);
        }
 public ActionResult Create(ExpenseCategoryModel smodel)
 {
     try {
         if (ModelState.IsValid)
         {
             ExpenseCategoryDBHandle sdb = new ExpenseCategoryDBHandle();
             if (sdb.Add(smodel))
             {
                 ViewBag.Message = "Details Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     } catch (Exception e) {
         e.GetBaseException();
         return(View());
     }
 }
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveExpenseCategory(ExpenseCategoryModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                //判断费用类别是否已经存在
                if (ExpenseCategoryBll.IsExistExpenseCategory(inn, model.b_CostName, model.Id))
                {
                    retModel.AddError("errorMessage", @OABordrinCommon.Common.GetLanguageValueByParam("输入的费用类别已经存在!", "ERCommon", "ERItemType", ViewBag.language));
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                Item item = null;
                if (string.IsNullOrEmpty(model.Id))
                {
                    item = inn.newItem("b_ExpenseCategory", "add");
                }
                else
                {
                    item = inn.newItem("b_ExpenseCategory", "edit");
                    item.setAttribute("id", model.Id);
                }
                item.setProperty("b_costname", model.b_CostName);
                item.setProperty("b_corresponsubject", model.b_CorresponSubject);
                var result = item.apply();
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string Save()
        {
            /*string mstformData = System.Web.HttpContext.Current.Request.Form["mstformData"];
             * string otype = System.Web.HttpContext.Current.Request.Form["otype"];
             * var mstforminfo = DataConverterHelper.JsonToEntity<ExpenseCategoryModel>(mstformData);
             *
             * List<ExpenseCategoryModel> expenseCategories = mstforminfo.AllRow;
             * var checkresult = ExpenseCategoryService.ExecuteDataCheck(ref expenseCategories,otype);
             * if (checkresult != null && checkresult.Status == ResponseStatus.Error)
             * {
             *  return DataConverterHelper.SerializeObject(checkresult);
             * }
             *
             * var savedresult = ExpenseCategoryService.Save<Int64>(mstforminfo.AllRow);*/
            string Data2    = System.Web.HttpContext.Current.Request.Params["Data2"];
            string edittype = System.Web.HttpContext.Current.Request.Params["edittype"];

            ExpenseCategoryModel expenseCategory = JsonConvert.DeserializeObject <ExpenseCategoryModel>(Data2);


            var savedresult = ExpenseCategoryService.Save2(expenseCategory, edittype);

            return(DataConverterHelper.SerializeObject(savedresult));
        }
Beispiel #9
0
 public ExpenseCategoryModel Update(int businessId, ExpenseCategoryModel model)
 {
     return(ApiRequest <ExpenseCategoryModel, ExpenseCategoryModel>("/business/" + businessId + "/employeeexpensecategory/" + model.Id, model, Method.PUT));
 }
Beispiel #10
0
 public ExpenseCategoryModel Create(int businessId, ExpenseCategoryModel model)
 {
     return(ApiRequest <ExpenseCategoryModel, ExpenseCategoryModel>("/business/" + businessId + "/employeeexpensecategory", model, Method.POST));
 }
Beispiel #11
0
 public static ExpenseCategory ToEntity(this ExpenseCategoryModel model, ExpenseCategory destination)
 {
     return(model.MapTo(destination));
 }
Beispiel #12
0
 public static ExpenseCategory ToEntity(this ExpenseCategoryModel model)
 {
     return(model.MapTo <ExpenseCategoryModel, ExpenseCategory>());
 }