예제 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtDeptName.Text != "" && txtPhoneNum.Text != "" && txtUserName.Text != "")
     {
         MessageUserClass  dao = new MessageUserClass();
         MessageUserEntity ety = (MessageUserEntity)GlobalFunction.ControlsToEntity(panel1.Controls, typeof(MessageUserEntity));
         if (ety.Phonenum.Substring(0, 2) != "86")
         {
             ety.Phonenum = "86" + ety.Phonenum;
         }
         if (messageuserid == "")
         {
             dao.Insert(ety, null);
         }
         else
         {
             ety.Messageuserid = messageuserid;
             dao.Update(ety, null);
         }
         LoadData();
         GlobalFunction.ClearControls(panel1.Controls);
         messageuserid = "";
     }
     else
     {
         MessageBox.Show("不能空保存!");
     }
 }
예제 #2
0
        private void btnDao_Click(object sender, EventArgs e)
        {
            MessageUserClass dao = new MessageUserClass();
            DataTable        dt  = dao.SearchForDeptName().Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MessageUserEntity ety = new MessageUserEntity();
                ety.Deptname = dt.Rows[i][0].ToString();
                ety.Username = dt.Rows[i][0].ToString();
                ety.Phonenum = "86123";
                dao.Insert(ety, null);
            }
        }