Example #1
0
        private void save_Click(object sender, EventArgs e)//保存更新
        {
            string V, pasword;

            try
            {
                if (Pas.Text != "")
                {
                    //pasword = db.Encrypt(Pas.Text);
                    pasword = Pas.Text;
                }
                else
                {
                    pasword = "";
                }

                if (IsValid.Checked)
                {
                    V = "1";
                }
                else
                {
                    V = "0";
                }

                utype = comboBox1.SelectedIndex.ToString();
                updateE(Account.Text, pasword, Position.Text, EName.Text, ECode.Text, V, FormEmployee.ID, utype);


                string str = "Delete from ManageLimit where DEmployeeID = " + FormEmployee.ID;
                db.GetPIVAsDB(str);

                if (LimitShow)
                {
                    Limitstr = f.getLimitStr();
                    f.Dispose();
                }
                if (Limitstr != "")
                {
                    string[] l = Limitstr.Split(',');
                    for (int i = 0; i < l.Length; i++)
                    {
                        str = "insert into ManageLimit values(" + FormEmployee.ID + ",'" + l[i] + "')";
                        db.SetPIVAsDB(str);
                    }
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void Add_Click(object sender, EventArgs e)//增加数据库员工信息,同时界面刷新
        {
            try
            {
                string Isvalid, pasword, type = "";
                if (Pas.Text != "")
                {
                    // pasword = db.Encrypt(Pas.Text);
                    pasword = Pas.Text;
                }
                else
                {
                    pasword = "";
                }

                if (IsValid.Checked)
                {
                    Isvalid = "1";
                }
                else
                {
                    Isvalid = "0";
                }
                switch (comboBox1.SelectedIndex)
                {
                case 0:
                    type = "0";
                    break;

                case 1:
                    type = "1";
                    break;

                case 2:
                    type = "2";
                    break;

                case 3:
                    type = "3";
                    break;
                }
                //db.Decrypt
                string str = "insert into DEmployee values('" + Account.Text + "','" + pasword + "','" + Position.Text + "','" + ECode.Text +
                             "','" + EName.Text + "','" + Isvalid + "'," + type + ")";

                FormEmployee form = (FormEmployee)this.Owner;
                db.SetPIVAsDB(str);
                form.refresh();

                if (LimitShow)
                {
                    Limitstr = f.getLimitStr();
                    f.Dispose();
                }
                str = "select DEmployeeID from DEmployee where AccountID = '" + Account.Text + "'";
                DataSet ds = db.GetPIVAsDB(str);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string eid = ds.Tables[0].Rows[0]["DEmployeeID"].ToString();
                    if (Limitstr != "")
                    {
                        string[] l = Limitstr.Split(',');
                        for (int i = 0; i < l.Length; i++)
                        {
                            str = "insert into ManageLimit values(" + eid + ",'" + l[i] + "')";
                            db.SetPIVAsDB(str);
                        }
                    }
                }


                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }