Esempio n. 1
0
        public static JsResultObject Remove <T>(int[] arrayIds, string proName)
        {
            JsResultObject result = new JsResultObject();
            int            re     = 0;

            using (ISession ise = DataBiz.CreateSession())
            {
                try
                {
                    ITransaction itx = ise.BeginTransaction();

                    foreach (object id in arrayIds)
                    {
                        try
                        {
                            object temp = ise.Load(typeof(T), id);
                            ise.Delete(temp);
                            re++;
                            result.rowNum += 1;
                        }
                        catch (Exception ex) { }
                    }
                    itx.Commit();
                    result = ResultUtil.RemoveSuccess(re, proName);
                }
                catch (Exception ex)
                {
                    result = ResultUtil.RemoveError("", ex.InnerException.ToString());
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static JsResultObject Save(BaseModel obj, string proName)
        {
            JsResultObject result = new JsResultObject();

            using (ISession ise = DataBiz.CreateSession())
            {
                try
                {
                    ITransaction itx = ise.BeginTransaction();
                    ise.Save(obj);
                    itx.Commit();
                    result         = ResultUtil.SaveSuccess(1, proName);
                    result.rowNum += 1;
                }
                catch (Exception ex)
                {
                    result = ResultUtil.SaveError("", ex.InnerException.ToString());
                }
            }
            return(result);
        }
Esempio n. 3
0
        public static JsResultObject Delete(BaseModel model, string proName)
        {
            JsResultObject result = new JsResultObject();
            int            re     = 0;

            using (ISession ise = DataBiz.CreateSession())
            {
                try
                {
                    ITransaction itx = ise.BeginTransaction();
                    ise.Delete(model);
                    re++;
                    itx.Commit();
                    result         = ResultUtil.RemoveSuccess(re, proName);
                    result.rowNum += 1;
                }
                catch (Exception ex)
                {
                    result = ResultUtil.RemoveError("", ex.InnerException.ToString());
                }
            }
            return(result);
        }