Ejemplo n.º 1
0
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (cbx_SSex.SelectedIndex == -1)
            {
                MessageBox.Show("学生信息未填写完成!", "无法添加学生信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string strSID    = tbx_SId.Text,
                   strSNAME  = tbx_SName.Text,
                   strSSEX   = cbx_SSex.SelectedItem.ToString(),
                   strSBIRTH = dtime_SBirth.Value.ToShortDateString(),
                   strSHOME  = tbx_Home.Text;

            if (strSID == "" || strSNAME == "" || strSSEX == "" || strSBIRTH == "" || strSHOME == "")
            {
                MessageBox.Show("学生信息未填写完成!", "无法添加学生信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (m_pIsAdd)
            {
                if (SqlUtils.AddStudent(strSID, strSNAME, strSSEX, strSBIRTH, strSHOME))
                {
                    string id = SqlUtils.GetIdFromSId(strSID);
                    AeUtils.AddStudent(m_pPoint, id, strSID, strSNAME, strSSEX, strSBIRTH, strSHOME);
                    MessageBox.Show(String.Format("学生【{0}】添加成功", strSNAME));
                    UpdataDatabaseView();
                    this.Close();
                }
            }
            else
            {
                if (SqlUtils.EditStudent(m_pId, strSID, strSNAME, strSSEX, strSBIRTH, strSHOME))
                {
                    AeUtils.EditStudent(this.m_pPoint, m_pId, strSID, strSNAME, strSSEX, strSBIRTH, strSHOME);
                    MessageBox.Show(String.Format("学生【Id:{0}】信息修改成功", m_pId));
                    UpdataDatabaseView();
                    this.Close();
                }
            }
        }