public async Task <BasPosMsg> UserAdd()
        {
            BasPosMsg ret = new BasPosMsg();

            try
            {
                await Task.Run(() =>
                {
                    // 添加
                    var user = new UserX
                    {
                        Name   = "djkgf",
                        Enable = true
                    };
                    var book = new Book
                    {
                        Name = "jsf1"
                    };

                    user.Insert();
                    book.Insert();
                    ret.Code = "200";
                    ret.Msg  = "success";
                });
            }
            catch (Exception e)
            {
                ret.Code = "500";
                ret.Msg  = e.Message;
            }

            return(ret);
        }
Example #2
0
        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            if (this.IsHandleCreated)
            {
                System.Diagnostics.Trace.WriteLine("navBarItem1_LinkClicked");
                System.Diagnostics.Debug.WriteLine("navBarItem1_LinkClicked");

                // 添加
                var newUser = new UserX
                {
                    Name   = System.Guid.NewGuid().ToString(),
                    Enable = true,
                };
                newUser.Insert();
                // 自增字段user.ID已经取得值
                XTrace.WriteLine("用户ID:{0}", newUser.ID);
                if (bindingSourceMain.DataSource != null)
                {
                    bindingSourceMain.Add(newUser);
                    ////MessageBox.Show(bindingSourceMain.DataSource.GetType().ToString());
                    if ((bindingSourceMain.DataSource as BindingSource).DataSource is IList <UserX> )
                    {
                        IList <UserX> listUser = (bindingSourceMain.DataSource as BindingSource).DataSource as List <UserX>;
                    }
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            XTrace.UseConsole();

            var user = new UserX()
            {
                Name   = "ding",
                Enable = true
            };

            user.Insert();
            XTrace.WriteLine($"用户id{user.ID}");

            //var user2=UserX.Find(UserX._.Name=="ding");

            //user2.Logins++;
            //user2.LastLogin=DateTime.Now;
            //user2.Update();

            Console.ReadKey();
        }