Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            EntityAdmin entity = new EntityAdmin();
            var         tt     = getEntity(entity);

            entity.username = this.txtUserName.Text;
            entity.userpwd  = this.txtUserPwd.Text;
            entity.id       = tt.id;

            using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
            {
                //判断用户名密码是否为空
                if ((entity.username != "") && (entity.userpwd != ""))
                {
                    if (client.UpdateUser(entity) == true)
                    {
                        BindGridConrtl();
                        empty();
                        MessageBox.Show("成功");
                    }
                    else
                    {
                        MessageBox.Show("失败");
                    }
                    // }
                    // else { MessageBox.Show("用户已存在,请重新输入"); }
                }

                else
                {
                    MessageBox.Show("请输入用户名或密码");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
            {
                DialogResult dr = MessageBox.Show("是否删除!", "提示!", MessageBoxButtons.OKCancel);

                if (dr == DialogResult.OK)
                {
                    // var id = getId();
                    //EntityAdmin entity = new EntityAdmin();

                    //  client.mutiDel(id);

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

                    list = getId();
                    for (int i = 0; i < list.Count; i++)
                    {
                        client.DeleteUser(list[i]);
                    }
                    BindGridConrtl();
                    MessageBox.Show("删除成功");
                    this.txtUserName.Text = "";
                    this.txtUserPwd.Text  = "";
                }
                else if (dr == DialogResult.Cancel)
                {
                }
            }
        }
Пример #3
0
 static void Main(string[] args)
 {
     using (ServiceReference1.CalculatorServiceClient proxy = new ServiceReference1.CalculatorServiceClient())
     {
         Console.WriteLine("x+y={0}", proxy.Add(1, 2));
     }
 }
Пример #4
0
 /// <summary>
 /// gridConrtl绑定数据
 /// </summary>
 public void BindGridConrtl()
 {
     using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
     {
         var _result = client.GetUsers();
         user.GetList(_result);
         this.gridControl1.DataSource = user.GetList(_result);
     }
 }
Пример #5
0
        static void Main(string[] args)
        {
            Uri             uri     = new Uri("http://localhost:9876/calculatorservice");
            var             header  = AddressHeader.CreateAddressHeader("UserName", "http://localhost:9876", "jqin");
            EndpointAddress address = new EndpointAddress(uri, header);

            using (var client = new ServiceReference1.CalculatorServiceClient(new WSHttpBinding(), address))
            {
                double result = client.Add(1D, 2D);
                Console.WriteLine(result);
                Console.ReadKey();
            }
        }
Пример #6
0
        /// <summary>
        /// 模糊查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSelect_Click(object sender, EventArgs e)
        {
            EntityAdmin entity = new EntityAdmin();

            entity.username = this.txtUserName.Text;
            entity.userpwd  = this.txtUserPwd.Text;
            using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
            {
                DataSet            _result = client.ByUserPwdAndUserName(entity);
                List <EntityAdmin> list    = user.GetList(_result);
                this.gridControl1.DataSource = list;
            }
        }
Пример #7
0
        /// <summary>
        /// 选中每行时文本框显示当前行的数据
        /// </summary>
        public void ShowNamePwd()
        {
            //int id=Convert.ToInt32(GetSelectID("id"));
            //int id = int.Parse(GetSelectID("id"));//获取选中Id
            EntityAdmin entity = new EntityAdmin();
            var         tt     = getEntity(entity);

            using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
            {
                this.txtUserName.Text = tt.username;
                this.txtUserPwd.Text  = tt.userpwd;
            }
        }
Пример #8
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public void Save()
        {
            EntityAdmin entity   = new EntityAdmin();
            var         username = this.txtUserName.Text;
            var         userpwd  = this.txtUserPwd.Text;

            entity.username = username;
            entity.userpwd  = userpwd;
            using (ServiceReference1.CalculatorServiceClient client = new ServiceReference1.CalculatorServiceClient())
            {
                //判断用户名密码是否为空
                if ((username != "") && (userpwd != ""))
                {
                    //判断用户名是否存在
                    DataSet ds = client.ByUserNameUser(entity);
                    if (ds.Tables[0].Rows.Count <= 0)
                    {
                        //添加用户
                        if (client.SaveUser(entity) == true)
                        {
                            BindGridConrtl();
                            MessageBox.Show("添加成功");
                        }
                        else
                        {
                            MessageBox.Show("添加失败");
                        }
                    }
                    else
                    {
                        MessageBox.Show("用户已存在,请重新输入");
                    }
                }

                else
                {
                    MessageBox.Show("请输入用户名或密码");
                }
            }
        }