Ejemplo n.º 1
0
 public void Test1()
 {
     StaticRecorder.ConnectionOpendTimes = 0;
     DbEntry.UsingTransaction(delegate {
     });
     Assert.AreEqual(0, StaticRecorder.ConnectionOpendTimes);
 }
Ejemplo n.º 2
0
 public static bool UpdatePeople(int peopleId, string name, bool sex, DateTime birthday, DateTime arriveDate, string identityNo, string phoneNo, string address, string tempApplication, int comeReason, string tip)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             People people          = People.FindById(peopleId);
             people.Name            = name;
             people.Sex             = sex;
             people.Birthday        = birthday;
             people.ArriveDate      = arriveDate;
             people.IdentityNo      = identityNo;
             people.PhoneNo         = phoneNo;
             people.Address         = address;
             people.TempApplication = tempApplication;
             people.ComeReason      = comeReason;
             people.Tip             = tip;
             people.Save();
         });
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public static int AddPeopleForImport(string name, bool sex, DateTime birthday, DateTime arriveDate, string identityNo, string phoneNo, string address, string tempApplication, int comeReason, string tip)
        {
            int id = 0;

            try
            {
                DbEntry.UsingTransaction(delegate
                {
                    People people          = new People();
                    people.Name            = name;
                    people.Sex             = sex;
                    people.Birthday        = birthday;
                    people.ArriveDate      = arriveDate;
                    people.IdentityNo      = identityNo;
                    people.PhoneNo         = phoneNo;
                    people.Address         = address;
                    people.TempApplication = tempApplication;
                    people.ComeReason      = comeReason;
                    people.Tip             = tip;
                    people.IsDelete        = false;
                    people.Save();
                    id = people.Id;
                });
            }
            catch { return(0); }
            return(id);
        }
Ejemplo n.º 4
0
 public static bool UpdateCommunication(int communicationId, string exchange, string type, string name, bool sex, DateTime birthday, string company, string address, string phoneNo, double ballot, bool isReelect, string servant, string phoneNoOfS, string background, string situation)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             Communication com = Communication.FindById(communicationId);
             com.Exchange      = exchange;
             com.Type          = type;
             com.Name          = name;
             com.Sex           = sex;
             com.Birthday      = birthday;
             com.Company       = company;
             com.Address       = address;
             com.PhoneNo       = phoneNo;
             com.Ballot        = ballot;
             com.IsReelect     = isReelect;
             com.Servant       = servant;
             com.PhoneNoOfS    = phoneNoOfS;
             com.Background    = background;
             com.Situation     = situation;
             com.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
Ejemplo n.º 5
0
        public override string Create()
        {
            var obj = new Article();

            var categoryid = long.Parse(Bind("article[category]"));
            var category   = Category.FindById(categoryid);

            obj.Category = category;
            GetColumns(obj);
            obj.CheckNull();

            obj.User = this.GetLoginUser();
            var hit = new Statistic();

            hit.Save();
            obj.Statistic = hit;

            DbEntry.UsingTransaction(delegate
            {
                CommonHelper.ProcessTagNew(obj, Bind("article[tags]"));
                obj.Save();
            });

            Flash.Notice = "Article was successfully created";
            return(UrlTo <ArticleController>());
        }
Ejemplo n.º 6
0
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            Condition c = null;

            foreach (string s in roleNames)
            {
                c |= CK.K["Name"] == s;
            }
            Condition cu = null;

            foreach (string s in usernames)
            {
                cu |= CK.K["UserName"] == s;
            }
            DbEntry.UsingTransaction(delegate
            {
                List <DbEntryMembershipUser> ls = DbEntryMembershipUser.Find(cu);
                foreach (DbEntryRole r in DbEntryRole.Find(c))
                {
                    foreach (DbEntryMembershipUser u in ls)
                    {
                        r.Users.Add(u);
                    }
                    r.Save();
                }
            });
        }
Ejemplo n.º 7
0
 public override void Delete()
 {
     try
     {
         SM_SALEORDER saleorderobj = this.gGrid1.GetCurSelect <SM_SALEORDER>();
         if (saleorderobj == null)
         {
             return;
         }
         string  orderid = G.Core.GConvert.ToString(saleorderobj.ORDERID);
         string  sql     = string.Format("select * from SM_POCKET where ORDERID='{0}'", orderid);
         DataSet ds      = DbEntry.Provider.ExecuteDataset(sql);
         if (ds.Tables[0].Rows.Count > 0)
         {
             MessageBox.Show("该订单已装箱不能删除!");
             return;
         }
         DialogResult dr = MessageBox.Show("是否删除单据!", "提示", MessageBoxButtons.YesNo);
         if (dr == DialogResult.Yes)
         {
             DbEntry.UsingTransaction(delegate
             {
                 string csql = string.Format("exec SMProc_SaleOrderDelete '{0}','{1}'", orderid, G.AppInfo.GGlobal.User.USERDM);
                 DbEntry.Provider.ExecuteNonQuery(csql);
             });
             this.RefreshData();
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Ejemplo n.º 8
0
 public void Test5()
 {
     Assert.Throws <SQLiteException>(() => {
         DbEntry.UsingTransaction(
             () => DbEntry.Provider.ExecuteNonQuery("PRAGMA foreign_keys = ON;INSERT INTO [PCs] ([Name],[Person_Id]) VALUES ('should be failed', 6);"));
     }, SQLiteExceptionMessage);
 }
Ejemplo n.º 9
0
 public static bool AddChildren(int mariageId, string name, bool sex, DateTime birthday, string address, string tip)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             Children chi   = new Children();
             chi.Mariage_Id = mariageId;
             chi.Name       = name;
             chi.Sex        = sex;
             //if(birthday != new DateTime(1900,1,1))
             //{
             //    chi.Birthday = birthday;
             //}
             //else
             //{
             //    chi.Birthday = null;
             //}
             chi.Birthday = birthday;
             chi.Address  = address;
             chi.Tip      = tip;
             chi.IsDelete = false;
             chi.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
Ejemplo n.º 10
0
 public static bool AddEnterpriseForNew(int id, string name, string domicile, string referee, string contacts, string phoneNo, string email, string type, string investorOfTW, string investorOfH, string scope, string product)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             Enterprise ent   = Enterprise.FindById(id);
             ent.Name         = name;
             ent.Domicile     = domicile;
             ent.Referee      = referee;
             ent.Contacts     = contacts;
             ent.PhoneNo      = phoneNo;
             ent.Email        = email;
             ent.Type         = type;
             ent.InvestorOfTW = investorOfTW;
             ent.InvestorOfH  = investorOfH;
             ent.Scope        = scope;
             ent.Product      = product;
             ent.IsDelete     = false;
             ent.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
Ejemplo n.º 11
0
        public static bool UpdatePermission(long roleId, string[] permissionIds)
        {
            try
            {
                DbEntry.UsingTransaction(delegate
                {
                    DbEntry.Provider.ExecuteNonQuery(
                        string.Format("DELETE FROM dbo.Permission_Role WHERE Role_Id = '{0}'", roleId));

                    if (permissionIds.Length > 0)
                    {
                        string sql = "INSERT INTO dbo.Permission_Role(Role_Id, Permission_Id) ";
                        List <string> insertValue = new List <string>();
                        foreach (var permissionId in permissionIds)
                        {
                            insertValue.Add(string.Format("SELECT '{0}', '{1}'", roleId, permissionId));
                        }
                        sql += string.Join(" UNION ", insertValue);
                        DbEntry.Provider.ExecuteNonQuery(sql);
                    }
                });
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 12
0
        public override void DropColumns(ModelContext ctx, params string[] columns)
        {
            var n  = ctx.Info.From.MainTableName;
            var tn = QuoteForTableName(n);
            var cs = ctx.Provider.GetDbColumnInfoList(n);

            foreach (var column in columns)
            {
                var c = cs.First(p => p.ColumnName == column);
                cs.Remove(c);
            }
            var sb = new StringBuilder();

            foreach (var c in cs)
            {
                sb.Append(QuoteForColumnName(c.ColumnName));
                sb.Append(",");
            }
            sb.Length--;
            DbEntry.UsingTransaction(() =>
            {
                ctx.Provider.ExecuteNonQuery(string.Format("ALTER TABLE {0} RENAME TO __drop__temp__;", tn));
                ctx.Operator.Create();
                ctx.Provider.ExecuteNonQuery(string.Format("INSERT INTO {0} SELECT {1} FROM __drop__temp__;", tn, sb));
                ctx.Provider.ExecuteNonQuery("DROP TABLE __drop__temp__;");
            });
        }
Ejemplo n.º 13
0
 public void Save(DM_ITEMSPLIT itemsplit, DM_ITEM itemA, DM_ITEM itemB, DM_ITEM itemC, DM_ITEM itemD)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             if (itemsplit.ItemCodeA == "" && itemsplit.Id > 0)
             {
                 this.ExecuteDelete(itemsplit);
             }
             else
             {
                 this.ExecuteUpdate(itemsplit);
                 if (itemA != null)
                 {
                     DbEntry.Save(itemA);
                     //itemA.Save();
                 }
                 if (itemB != null)
                 {
                     DbEntry.Save(itemB);
                 }
                 if (itemC != null)
                 {
                     DbEntry.Save(itemC);
                 }
                 if (itemD != null)
                 {
                     DbEntry.Save(itemD);
                 }
             }
         });
     }
     catch (Exception e) { throw e; }
 }
Ejemplo n.º 14
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            c = "";
            string orderids = G.Core.GConvert.ToString(TXT_ORDERIDS.Text);

            if (orderids != "")
            {
                try
                {
                    string[] name = orderids.Split(',');
                    foreach (string s in name)
                    {
                        string orderid = G.Core.Common.Usually.GetPadingNO("SO", s, 10);
                        c += "'" + orderid + "',";
                    }
                    c = c.Substring(0, c.Length - 1).Replace("'", "''");

                    DbEntry.UsingTransaction(delegate
                    {
                        string csql = string.Format("EXEC Pro_GetData '{0}','{1}'", "getxskpdata", c);
                        ds          = DbEntry.Provider.ExecuteDataset(csql);
                    });
                    gGrid1.DataSource = ds.Tables[0];
                    //gGrid1.AllowEditing = true;
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }
        }
Ejemplo n.º 15
0
 public static bool UpdateChildren(int childrenId, string name, bool sex, DateTime birthday, string address, string tip)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             Children chi = Children.FindById(childrenId);
             chi.Name     = name;
             chi.Sex      = sex;
             //if (birthday != new DateTime(1900, 1, 1))
             //{
             //    chi.Birthday = birthday;
             //}
             //else
             //{
             //    chi.Birthday = null;
             //}
             chi.Birthday = birthday;
             chi.Address  = address;
             chi.Tip      = tip;
             chi.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
Ejemplo n.º 16
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            Condition c = null;

            foreach (string s in roleNames)
            {
                c |= CK.K["Name"] == s;
            }
            var uns = new List <string>(usernames);

            DbEntry.UsingTransaction(delegate
            {
                foreach (DbEntryRole r in DbEntryRole.Find(c))
                {
                    for (int i = r.Users.Count - 1; i >= 0; i--)
                    {
                        if (uns.Contains(r.Users[i].UserName))
                        {
                            r.Users.RemoveAt(i);
                        }
                    }
                    r.Save();
                }
            });
        }
Ejemplo n.º 17
0
 public void Red(ND_USER user, SM_XSKP obj)
 {
     if (obj.STATUS == "A" && !G.Core.GConvert.ToBool(obj.ISRED) && !G.Core.GConvert.ToBool(obj.ISREVERSE))
     {
         DbEntry.UsingTransaction(delegate
         {
             SM_XSKP redobj = G.Core.Common.EnityClone.Clone <SM_XSKP>(obj);
             redobj.ISRED   = true;
             redobj.STATUS  = "C";
             redobj.Id      = 0;
             redobj.SUMQTY  = redobj.SUMQTY * -1;
             redobj.SUMVAT  = redobj.SUMVAT * -1;
             redobj.SUMVOT  = redobj.SUMVOT * -1;
             redobj.SUMTAX  = redobj.SUMTAX * -1;
             foreach (SM_XSKPDTL xd in redobj.XSKPDTL)
             {
                 xd.Id       = 0;
                 xd.ATMONEY  = xd.ATMONEY * -1;
                 xd.OTMONEY  = xd.OTMONEY * -1;
                 xd.QTY      = xd.QTY * -1;
                 xd.TAXMONEY = xd.TAXMONEY * -1;
             }
             redobj.Save();
             obj.ISREVERSE = true;
             obj.STATUS    = "C";
             obj.Save();
         });
     }
 }
Ejemplo n.º 18
0
 public void Audit(ND_USER user, int id)
 {
     DbEntry.UsingTransaction(delegate
     {
         string csql = string.Format("exec SMProc_ApproveShipVoucher {0},'{1}' ", id, user.USERDM);
         DbEntry.Provider.ExecuteNonQuery(csql);
     });
 }
Ejemplo n.º 19
0
 public void AssistAllDown(ND_USER user, string orderid)
 {
     DbEntry.UsingTransaction(delegate
     {
         string csql = string.Format("exec SMProc_AssistAllDown '{0}','{1}' ", orderid, user.USERDM);
         DbEntry.Provider.ExecuteNonQuery(csql);
     });
 }
Ejemplo n.º 20
0
 public void TestTransactionOnlyException()
 {
     DbEntry.UsingTransaction(
         () =>
     {
         throw new ApplicationException("Todo");
     });
 }
Ejemplo n.º 21
0
        public void Test2()
        {
            StaticRecorder.ConnectionOpendTimes = 0;
            var ctx = new DataProvider("SQLite");

            DbEntry.UsingTransaction(() => ctx.ExecuteNonQuery("select * from test"));
            Assert.AreEqual(1, StaticRecorder.ConnectionOpendTimes);
        }
Ejemplo n.º 22
0
 public void ClearBomtemp(ND_USER user, string orderid)
 {
     DbEntry.UsingTransaction(delegate
     {
         string csql = string.Format("exec SMProc_ClearBomTemp '{0}','{1}' ", orderid, user.USERDM);
         DbEntry.Provider.ExecuteNonQuery(csql);
     });
 }
Ejemplo n.º 23
0
 private void InsertSaleOrderStatus()
 {
     DbEntry.UsingTransaction(delegate
     {
         string csql = string.Format("UPDATE SM_SALEORDERSTATUS SET PRINTTAG=1 where ORDERID='{0}' ", orderid);
         DbEntry.Provider.ExecuteNonQuery(csql);
     });
 }
Ejemplo n.º 24
0
 public void PlanFin(ND_USER user, string orderid)
 {
     DbEntry.UsingTransaction(delegate
     {
         string sql = string.Format("update SM_SALEORDERSTATUS set ORDSTATUS=2 where OrderID='{0}'", orderid);
         DbEntry.Provider.ExecuteNonQuery(sql);
     });
 }
Ejemplo n.º 25
0
 public void XD(ND_USER user, string id)
 {
     DbEntry.UsingTransaction(delegate
     {
         string csql = string.Format("exec SMProc_MergePrePurOrder '{0}','{1}' ", id, user.USERDM);
         DbEntry.Provider.ExecuteNonQuery(csql);
     });
 }
Ejemplo n.º 26
0
 public void Test4()
 {
     DbEntry.UsingTransaction(
         () =>
     {
         DbEntry.Provider.ExecuteNonQuery("PRAGMA foreign_keys = ON;");
         DbEntry.Provider.ExecuteNonQuery("INSERT INTO [PCs] ([Name],[Person_Id]) VALUES ('should be failed', 6);");
     });
 }
Ejemplo n.º 27
0
 public void TestTransactionOnlyException()
 {
     Assert.Throws <ApplicationException>(() => {
         DbEntry.UsingTransaction(
             () => {
             throw new ApplicationException("Todo");
         });
     }, "Todo");
 }
Ejemplo n.º 28
0
        public override int Delete(IDbObject obj)
        {
            int ret = 0;

            DbEntry.UsingTransaction(delegate {
                ret += ProcessRelation(obj);
                ret += base.Delete(obj);
            });
            return(ret);
        }
Ejemplo n.º 29
0
 public static void DeleteUserModule(long id, long mmId)
 {
     DbEntry.UsingTransaction(delegate
     {
         MainOptr mo   = MainOptr.FindById(id);
         MainModule ma = MainModule.FindById(mmId);
         mo.Modules.Remove(ma);
         mo.Save();
     });
 }
Ejemplo n.º 30
0
 //获取该checkbox的Id
 //删除MaianMudule_MainAction
 public static void DeleteModuleAction(long id, string txt)
 {
     DbEntry.UsingTransaction(delegate
     {
         MainModule mm = MainModule.FindById(id);
         MainAction ma = MainAction.FindOne(CK.K["ChineseName"] == txt);
         mm.Actions.Remove(ma);
         mm.Save();
     });
 }