コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Model.Sys_User m = new Model.Sys_User();
            m.CreateTime = DateTime.Now;
            m.Password   = "******";
            m.Status     = true;
            m.UpdateTime = DateTime.Now;
            m.UserName   = "******" + DateTime.Now.Ticks.ToString();
            m.UserRole   = "testrole";

            Model.ECom_Work work = new Model.ECom_Work();
            work.Address        = "zxc";
            work.City           = "zxc";
            work.Province       = "zxc";
            work.Classification = "sdfds";
            work.Contents       = "zxc";
            work.CreateTime     = DateTime.Now;
            work.District       = "zxc";
            work.ExpirationDate = DateTime.Now;
            work.HTMLUrl        = "zxc";
            work.Status         = true;
            work.Title          = "zxc";
            work.TitleColor     = "zxc";
            work.UpdateTime     = DateTime.Now;
            work.Province       = "sdf";
            work.UserName       = "******";
            work.WorkID         = Guid.NewGuid().ToString();
            work.WorkType       = "放活";

            Model.ECom_Work work1 = new Model.ECom_Work();
            work1.Address        = "zxc";
            work1.City           = "zxc";
            work1.Classification = "sdfds";
            work1.Contents       = "zxc";
            work1.CreateTime     = DateTime.Now;
            work1.District       = "zxc";
            work1.ExpirationDate = DateTime.Now;
            work1.HTMLUrl        = "zxc";
            work1.Status         = true;
            work1.Title          = "zxc";
            work1.TitleColor     = "zxc";
            work1.UpdateTime     = DateTime.Now;
            work1.UserName       = "******";
            work1.Province       = "sdf";
            work1.WorkID         = Guid.NewGuid().ToString();
            work1.WorkType       = "放活";
            m.Works = new List <Model.ECom_Work>()
            {
                work, work1
            };

            IRepository <Model.Sys_User> r = RepositoryFactory <Model.Sys_User> .CreateRepository("Model.Sys_User");

            if (r.Add(m))
            {
                MessageBox.Show("添加成功");
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            IRepository <Model.Sys_User> r;

            r = RepositoryFactory <Model.Sys_User> .CreateRepository("Model.Sys_User");

            NDolls.Data.DataConfig.AllowAssociation = true;
            Model.Sys_User m    = r.FindByPK("zxcayumi");
            String         json = NDolls.Data.Util.DataConvert <Model.Sys_User> .EntityToJson(m);

            MessageBox.Show(json);
        }
コード例 #3
0
        private void button8_Click(object sender, EventArgs e)
        {
            Model.Sys_User m = new Model.Sys_User();
            m.UserRole = "role";
            m.Status   = true;

            IRepository <Model.Sys_User> r = RepositoryFactory <Model.Sys_User> .CreateRepository("Model.Sys_User");

            List <Model.Sys_User> list = r.Find(m);

            dataGridView1.DataSource = list;
        }
コード例 #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            Model.Sys_User m = new Model.Sys_User();
            m.CreateTime = DateTime.Now;
            m.Password   = "******";
            m.Status     = true;
            m.UpdateTime = DateTime.Now;
            m.UserName   = "******";
            m.UserRole   = "update" + DateTime.Now.ToLongTimeString();

            MessageBox.Show(NDolls.Data.Util.EntityUtil.GetValueByField(m, "UserName").ToString());
        }
コード例 #5
0
        private void button9_Click(object sender, EventArgs e)
        {
            Model.Sys_User m = new Model.Sys_User();
            m.CreateTime = DateTime.Now;
            m.Password   = "******";
            m.Status     = true;
            m.UpdateTime = DateTime.Now;
            m.UserName   = "******";       //验证不允许为空
            m.UserRole   = "zDdk#11.com"; //"update" + DateTime.Now.ToLongTimeString();//验证为邮箱格式

            IRepository <Model.Sys_User> r = RepositoryFactory <Model.Sys_User> .CreateRepository("Model.Sys_User");

            String error = r.Validate(m);

            MessageBox.Show(error);
        }
コード例 #6
0
        private void button5_Click(object sender, EventArgs e)
        {
            Model.Sys_User m = new Model.Sys_User();
            m.CreateTime = DateTime.Now;
            m.Password   = "******";
            //m.Status = true;
            m.UpdateTime = DateTime.Now;
            m.UserName   = "******";
            m.UserRole   = "update" + DateTime.Now.ToLongTimeString();

            IRepository <Model.Sys_User> r = RepositoryFactory <Model.Sys_User> .CreateRepository("Model.Sys_User");

            if (r.Update(m, OptType.UpdateIgnoreNull))
            {
                MessageBox.Show("修改成功");
            }
        }
コード例 #7
0
        private void button27_Click_1(object sender, EventArgs e)
        {
            Model.Test_Table m1 = new Model.Test_Table();
            m1.key1 = "k001";
            m1.key2 = "k002";
            m1.memo = "测试下";

            Model.Test_Table m2 = new Model.Test_Table();
            m2.key1 = "k0011";
            m2.key2 = "k0022";
            m2.memo = "测试下2";

            Model.Sys_User m3 = new Model.Sys_User();
            m3.CreateTime = DateTime.Now;
            m3.Password   = "******";
            m3.Status     = true;
            m3.UpdateTime = DateTime.Now;
            m3.UserName   = "******" + DateTime.Now.Ticks.ToString();
            m3.UserRole   = "testrole";

            Model.ECom_Work work = new Model.ECom_Work();
            work.Address        = "zxc";
            work.City           = "zxc";
            work.Province       = "zxc";
            work.Classification = "sdfds";
            work.Contents       = "zxc";
            work.CreateTime     = DateTime.Now;
            work.District       = "zxc";
            work.ExpirationDate = DateTime.Now;
            work.HTMLUrl        = "zxc";
            work.Status         = true;
            work.Title          = "zxc";
            work.TitleColor     = "zxc";
            work.UpdateTime     = DateTime.Now;
            work.Province       = "sdf";
            work.UserName       = "******";
            work.WorkID         = Guid.NewGuid().ToString();
            work.WorkType       = "放活";

            Model.ECom_Work work1 = new Model.ECom_Work();
            work1.Address        = "zxc";
            work1.City           = "zxc";
            work1.Classification = "sdfds";
            work1.Contents       = "zxc";
            work1.CreateTime     = DateTime.Now;
            work1.District       = "zxc";
            work1.ExpirationDate = DateTime.Now;
            work1.HTMLUrl        = "zxc";
            work1.Status         = true;
            work1.Title          = "zxc";
            work1.TitleColor     = "zxc";
            work1.UpdateTime     = DateTime.Now;
            work1.UserName       = "******";
            work1.Province       = "sdf";
            work1.WorkID         = Guid.NewGuid().ToString();
            work1.WorkType       = "放活";
            m3.Works             = new List <Model.ECom_Work>()
            {
                work, work1
            };

            List <EntityBase> list = new List <EntityBase>();

            list.Add(m1);
            list.Add(m2);
            list.Add(m3);
            if (RepositoryBase <EntityBase> .BatchSave(list))
            {
                MessageBox.Show("保存成功");
            }
        }
コード例 #8
0
        private void btnTransaction_Click(object sender, EventArgs e)
        {
            Model.Test_Table m1 = new Model.Test_Table();
            m1.key1 = "k0011";
            m1.key2 = "k0021";
            m1.memo = "测试下";

            Model.Test_Table m2 = new Model.Test_Table();
            m2.key1 = "k00111";
            m2.key2 = "k00221";
            m2.memo = "测试下2";

            Model.Sys_User m3 = new Model.Sys_User();
            m3.CreateTime = DateTime.Now;
            m3.Password   = "******";
            m3.Status     = true;
            m3.UpdateTime = DateTime.Now;
            m3.UserName   = "******";// +DateTime.Now.Ticks.ToString();
            m3.UserRole   = "testrole111";

            Model.ECom_Work work = new Model.ECom_Work();
            work.Address        = "zxc";
            work.City           = "zxc";
            work.Province       = "zxc";
            work.Classification = "sdfds";
            work.Contents       = "zxc";
            work.CreateTime     = DateTime.Now;
            work.District       = "zxc";
            work.ExpirationDate = DateTime.Now;
            work.HTMLUrl        = "zxc";
            work.Status         = true;
            work.Title          = "zxc";
            work.TitleColor     = "zxc";
            work.UpdateTime     = DateTime.Now;
            work.Province       = "sdf";
            work.UserName       = "******";
            work.WorkID         = Guid.NewGuid().ToString();
            work.WorkType       = "放活";

            Model.ECom_Work work1 = new Model.ECom_Work();
            work1.Address        = "zxc";
            work1.City           = "zxc";
            work1.Classification = "sdfds";
            work1.Contents       = "zxc";
            work1.CreateTime     = DateTime.Now;
            work1.District       = "zxc";
            work1.ExpirationDate = DateTime.Now;
            work1.HTMLUrl        = "zxc";
            work1.Status         = true;
            work1.Title          = "zxc";
            work1.TitleColor     = "zxc";
            work1.UpdateTime     = DateTime.Now;
            work1.UserName       = "******";
            work1.Province       = "sdf";
            work1.WorkID         = Guid.NewGuid().ToString();
            work1.WorkType       = "放活";
            m3.Works             = new List <Model.ECom_Work>()
            {
                work, work1
            };

            DBTransaction tran = new DBTransaction();

            tran.TransactionOpen();

            IRepository <Model.Test_Table> r = RepositoryFactory <Model.Test_Table> .CreateRepository(tran);

            IRepository <Model.Sys_User> r1 = RepositoryFactory <Model.Sys_User> .CreateRepository(tran);

            try
            {
                r.AddOrUpdate(m1);
                r.AddOrUpdate(m2);
                r1.AddOrUpdate(m3);
                Model.Sys_User mu = new Model.Sys_User();
                mu.UserRole = "rrole";
                r1.UpdateByCondition(mu, new ConditionItem("UserName", "testtest", SearchType.Accurate));
                r1.DeleteByCondition(new ConditionItem("UserName", "test", SearchType.RightFuzzy));
                tran.TransactionCommit();
                MessageBox.Show("处理成功");
            }
            catch
            {
                tran.TransactionRollback();
                MessageBox.Show("处理失败");
            }
        }