Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Database db = new Database();

            db.init();

            foreach (Control ct in this.Controls)
            {
                if (ct is TextBox)
                {
                    if (((TextBox)ct).Text.Trim().Length < 1)
                    {
                        MessageBox.Show("不能为空!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            try
            {
                var st = new Entities.Students();
                st.CARD   = txtCard.Text;
                st.NAME   = txtName.Text;
                st.CLASS  = txtCLASS.Text;
                st.SNO    = txtSNO.Text;
                st.ENABLE = chkEnable.Checked;
                int i = DBO.AddStudent(st);
                MessageBox.Show(String.Format("{0}个信息已被添加!", i), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception e1)
            {
                DBO.Err(e1);
                MessageBox.Show(e1.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        public static int AddStudent(Entities.Students st)
        {
            Database db = new Database();

            db.init();
            String sql = String.Format("insert into `Users`(ucard,uxh,uname,uclass,uena) values({0})", st.getSQLString1());

            return(db.Insert(sql));
        }
Exemple #3
0
        public static int UpdateStudent(Entities.Students stOLd, Entities.Students stNew)
        {
            Database db = new Database();

            db.init();
            String sql = String.Format("update `Users` set {0} where id={1}", stNew.getSQLString2(), stOLd.ID);

            return(db.Update(sql));
        }
        private void Managing_Load(object sender, EventArgs e)
        {
            oldST = DBO.getStudent(this.Tag.ToString());

            txtCard.Text  = oldST.CARD;
            txtCLASS.Text = oldST.CLASS;

            txtName.Text      = oldST.NAME;
            txtSNO.Text       = oldST.SNO;
            chkEnable.Checked = oldST.ENABLE;
            newST             = new Entities.Students();
            try
            {
                HardDeviceManaging.rec = this;
            }
            catch (Exception ex)
            {
                DBO.Err(ex);
                MessageBox.Show(ex.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }