Newer
Older
EMS_SZ / FrmAppUSERRESET.cs
root on 21 Mar 2016 3 KB first
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace Cyberpipe
{
    public partial class FrmAppUSERRESET : Office2007Form
    {
        int dbid;
        string username;
        string age;
        string sex;
        string phonenum;
        string password;
        string status;

        public FrmAppUSERRESET()
        {
            InitializeComponent();
            buttonX1.Text = "确定";
        }

        public FrmAppUSERRESET(int dbid, string username, string age, string password, string sex, string phonenum,string status)
        {
            InitializeComponent();
            buttonX1.Text = "保存";
            this.dbid = dbid;
            this.username = username;
            this.age = age;
            this.sex = sex;
            this.phonenum = phonenum;
            this.password = password;
            this.status = status;
        }

        private void FrmAppUSERRESET_Load(object sender, EventArgs e)
        {
            if (buttonX1.Text == "保存")
            {
                this.Text = "人员信息修改";
                textBoxusername.Text = username;
                textBoxage.Text = age;
                textBoxpassword.Text = password;
                textBoxsex.Text = sex;
                textBoxphonenum.Text = phonenum;
                textBoxisroot.Text = status;
            }
            else
            {
                this.Text = "增加人员";
                textBoxusername.Text = "";
                textBoxage.Text = "";
                textBoxpassword.Text = "";
                textBoxsex.Text = "";
                textBoxphonenum.Text = "";
                textBoxisroot.Text = "";
            }
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (buttonX1.Text == "保存")
            {
                string sql = "update casic_app_patroler set USERNAME ='" + textBoxusername.Text.Trim() + "',PASSWORD ='"
                        + textBoxpassword.Text.Trim() + "' ,AGE = '"
                        + textBoxage.Text.Trim() + "',SEX ='" + textBoxsex.Text.Trim() + "',PHONENUMBER ='"
                        + textBoxphonenum.Text.Trim() + "',STATUS = '" + textBoxisroot.Text.Trim() + "' where DBID =" + dbid.ToString();
                try
                {
                    OledbHelper.sqlExecuteNonQuery(sql);
                    {
                        MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示");
                }
            }
            if (buttonX1.Text == "确定")
            {
                string sql = "insert into casic_app_patroler (USERNAME,AGE,PASSWORD,SEX,PHONENUMBER,STATUS) values ('"
                        + textBoxusername.Text.Trim() + "','" + textBoxage.Text.Trim() + "','"
                        + textBoxpassword.Text.Trim() + "','" + textBoxsex.Text.Trim() + "','"
                        + textBoxphonenum.Text.Trim() + "','" + textBoxisroot.Text.Trim() + "')";
                try
                {
                    OledbHelper.sqlExecuteNonQuery(sql);
                    {
                        MessageBox.Show("人员增加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示");
                }
            }
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            this.Close();
        }



    }
}