Ejemplo n.º 1
0
        public frmLineModify(LineDataBean line)
        {
            InitializeComponent();
            agent    = SQLAgent.GetInstance();
            cityList = agent.GetCityList();
            foreach (var city in cityList)
            {
                cmbDep.Items.Add(city.cityName);
                cmbArr.Items.Add(city.cityName);
                if (city.cityId.Equals(line.depCity.ToString()))
                {
                    cmbDep.Text = city.cityName;
                }
                if (city.cityId.Equals(line.arrCity.ToString()))
                {
                    cmbArr.Text = city.cityName;
                }
            }
            id = line.id;

            txtNum.Text   = line.trainNum;
            txtPrice.Text = line.price.ToString();
            dateArr.Value = line.arrDate;
            dateDep.Value = line.depDate;
        }
Ejemplo n.º 2
0
 public frmLineRUD(bool login, string user_id)
 {
     InitializeComponent();
     agent        = SQLAgent.GetInstance();
     isLogin      = login;
     this.user_id = user_id;
 }
Ejemplo n.º 3
0
        private void frmViewCity_Load(object sender, EventArgs e)
        {
            SQLAgent            agent    = SQLAgent.GetInstance();
            List <CityDataBean> cityList = agent.GetCityList();

            dataView.Columns.Add("city_id", "城市ID");
            dataView.Columns.Add("city_name", "城市名称");
            for (int i = 0; i < cityList.Count; i++)
            {
                dataView.Rows.Add(cityList[i].cityId, cityList[i].cityName);
            }
        }
Ejemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            SQLAgent agent = SQLAgent.GetInstance();

            if (!txtPass.Text.Equals(string.Empty) && !txtId.Text.Equals(string.Empty) &&
                !txtRName.Text.Equals(string.Empty) &&
                !txtTel.Text.Equals(string.Empty) && !txtUser.Text.Equals(string.Empty) &&
                cmbSex.Items.Contains(cmbSex.Text))
            {
                agent.AddUser(txtId.Text, txtRName.Text, cmbSex.SelectedIndex, txtTel.Text, txtUser.Text, txtPass.Text);
                MessageBox.Show("Registered", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Not enough information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text != string.Empty && txtPass.Text != string.Empty)
            {
                try
                {
                    var sqlAgent = SQLAgent.GetInstance();

                    sqlAgent.Connect(File.ReadAllText("server.inf"));
                    if (!sqlAgent.AdminLogin(txtUser.Text, txtPass.Text))
                    {
                        MessageBox.Show("User name or password incorrect", "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.Hide();
                    frmFunctions functions = new frmFunctions();
                    functions.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting server\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (ex is WebException)
                    {
                        frmServerConfigure frm = new frmServerConfigure();
                        this.Enabled    = false;
                        frm.FormClosed += (o, arg) =>
                        {
                            this.Enabled = true;
                        };
                        frm.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter both user name and password", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
 public frmLineRUD()
 {
     InitializeComponent();
     agent = SQLAgent.GetInstance();
 }
Ejemplo n.º 7
0
 public frmAddCity()
 {
     InitializeComponent();
     agent    = SQLAgent.GetInstance();
     cityList = new List <CityDataBean>();
 }