Example #1
0
        private void BtnModifyUser_Click(object sender, EventArgs e)
        {
            try
            {
                string resmsg;
                if (lvUserList.SelectedItems.Count == 0l)
                {
                    throw new Exception("请选择要修改的用户");
                }
                string SelectUserDataAccount = lvUserList.FocusedItem.SubItems[0].Text;

                CommonData.UserMsgData data = userMsgList.Find(
                    delegate(CommonData.UserMsgData outdata)
                {
                    return(outdata.Account == SelectUserDataAccount);
                }
                    );
                //CommonData.UserMsgData userdata = new CommonData.UserMsgData
                //{
                //    Account = lvUserList.FocusedItem.SubItems[0].Text,
                //    UserName = lvUserList.FocusedItem.SubItems[1].Text,
                //    CreateDateTime = DateTime.Parse(lvUserList.FocusedItem.SubItems[2].Text),
                //    FailureDateTime = DateTime.Parse(lvUserList.FocusedItem.SubItems[3].Text),
                //    UpdateDateTime = DateTime.Parse(lvUserList.FocusedItem.SubItems[4].Text),
                //    UserTel = lvUserList.FocusedItem.SubItems[5].Text,
                //    UserPermission = int.Parse(lvUserList.FocusedItem.SubItems[6].Text),
                //    IsOnline = bool.Parse(lvUserList.FocusedItem.SubItems[7].Text),
                //    StateCode = bool.Parse(lvUserList.FocusedItem.SubItems[8].Text)
                //};
                ManageUserForm manageUserForm = new ManageUserForm(2)
                {
                    userdata = data
                };
                DialogResult res = manageUserForm.ShowDialog();
                if (res == DialogResult.OK)
                {
                    data = manageUserForm.userdata;
                    int ret = ReturnData.DoSetUserInfo(data, out resmsg);
                    if (ret != 0)
                    {
                        throw new Exception(resmsg);
                    }
                    DisplayUserMsg();
                    MessageBox.Show("修改成功");
                }
                //manageUserForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex);
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 private void BtnAddUser_Click(object sender, EventArgs e)
 {
     try
     {
         string         resmsg;
         ManageUserForm manageUserForm = new ManageUserForm(1);
         DialogResult   res            = manageUserForm.ShowDialog();
         if (res == DialogResult.OK)
         {
             userMsgList.Add(manageUserForm.userdata);
             if (ReturnData.DoCreateUserInfo(manageUserForm.userdata, out resmsg) != 0)
             {
                 throw new Exception(resmsg);
             }
             DisplayUserMsg();
             MessageBox.Show("添加成功");
         }
     }
     catch (Exception ex)
     {
         Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex);
         MessageBox.Show(ex.Message);
     }
 }