private void buttonXOK_Click(object sender, EventArgs e) { ClientType ct = new ClientType(); ClientTypeManager ctm = new ClientTypeManager(); ClientTypeForm ctf = (ClientTypeForm)this.Owner; switch (formStatic) { case "增": ct.CT_Name = XYEEncoding.strCodeHex(textBoxXName.Text.Trim()); ct.CT_Remark = XYEEncoding.strCodeHex(richTextBoxExRe.Text); ct.CT_Code = XYEEncoding.strCodeHex(BuildCode.ModuleCode("CL")); ct.CT_Enable = 1; int insertResult = 0; try { insertResult = ctm.Add(ct); } catch (Exception ex) { MessageBox.Show("系统异常:" + ex.Message); exceptionFlag = false; } if (insertResult > 0 && exceptionFlag) { ctf.loadData(); MessageBox.Show("添加成功!"); } else { MessageBox.Show("添加失败,请尝试重新添加"); } break; case "改": ct.CT_Name = XYEEncoding.strCodeHex(textBoxXName.Text.Trim()); ct.CT_Remark = XYEEncoding.strCodeHex(richTextBoxExRe.Text); ct.CT_Enable = 1; bool updateResult = false; try { updateResult = ctm.Update(ct); } catch (Exception ex) { MessageBox.Show("系统异常:" + ex.Message); exceptionFlag = false; } if (updateResult && exceptionFlag) { ctf.loadData(); MessageBox.Show("更新成功!"); } else { MessageBox.Show("更新失败,请尝试重新添加"); } break; case "": MessageBox.Show("初始化异常,请重新操作"); break; } if (!exceptionFlag) { this.Close(); } }