using Lskj.Business.Impl; using Lskj.Control; using Lskj.Core; using Lskj.Model; using Lskj.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.PubGroupSettings { public partial class FrmMain : BaseForm { public DynamicGroupSettings Model; // 动态链接库对象 public FrmMain() { InitializeComponent(); } private void FrmMain_Load(object sender, EventArgs e) { try { // 设置默认值 this.txtGroupName.Text = ""; this.txtMaxColumns.Text = ""; this.chkRemarkOwnRow.Checked = true; this.cmbLayout.SelectedIndex = 0; // 先列后行 } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 确定按钮点击事件 /// private void btnOK_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(Model.ModuleCode)) { MessageUtil.Show("未传入模块好", "提示"); return; } if (string.IsNullOrWhiteSpace(Model.FieldId)) { MessageUtil.Show("未传入字段ID", "提示"); return; } // 获取输入值 string groupName = this.txtGroupName.Text.Trim(); string maxColumnsText = this.txtMaxColumns.Text.Trim(); bool remarkOwnRow = this.chkRemarkOwnRow.Checked; string layout = this.cmbLayout.SelectedItem != null ? this.cmbLayout.SelectedItem.ToString() : "先列后行"; // 简单校验 if (string.IsNullOrEmpty(groupName)) { MessageUtil.Show("分组名称不能为空!", "提示"); this.txtGroupName.Focus(); return; } int maxColumns = 0; if (!int.TryParse(maxColumnsText, out maxColumns) || maxColumns <= 0) { MessageUtil.Show("最大列数必须为正整数!", "提示"); this.txtMaxColumns.Focus(); return; } // 备注独占一行(勾上是1,不勾是0) int RemarksExclusive = this.chkRemarkOwnRow.Checked ? 1 : 0; // 先列后行为1,先行后列为2 int Operateway = this.cmbLayout.SelectedIndex == 0 ? 1 : 2; string tipMsg = string.Empty; int result = SetTings(Model.ModuleCode, Model.FieldId, groupName, maxColumnsText, RemarksExclusive, Operateway, out tipMsg); switch (result) { case 1: // 修改成功 MessageUtil.Show("修改成功"); this.DialogResult = DialogResult.OK; this.Close(); break; default: MessageUtil.Show("修改失败:" + tipMsg); break; } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 取消按钮点击事件 /// private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } /// /// 设置分组 /// public static int SetTings(string ModuleCode, string FieldId,string groupName, string maxColumnsText,int RemarksExclusive,int Operateway, out string tipMsg) { try { string sqlValue = string.Format("update p_systemwordbooktab set rpname='{0}' where id in ({1})", groupName, FieldId); int jg = SqlHelper.ExecuteNonQuery(sqlValue); SqlParameter pMsg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 4000) : new SqlParameter("@msg", SqlDbType.VarChar, 2000); pMsg.Direction = ParameterDirection.Output; SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); returnValue.Direction = ParameterDirection.ReturnValue; SqlParameter[] param = { new SqlParameter("@modid",SqlDbType.VarChar), new SqlParameter("@rpname",SqlDbType.VarChar), new SqlParameter("@ListID",SqlDbType.Int), new SqlParameter("@bakid",SqlDbType.Int), new SqlParameter("@Operateway",SqlDbType.Int), pMsg, returnValue }; param[0].Value = ModuleCode; param[1].Value = groupName; param[2].Value = maxColumnsText; param[3].Value = RemarksExclusive; param[4].Value = Operateway; int result = MainImpl.ExecProcedure("P_systemwordbookTools", param); tipMsg = pMsg.Value.ToString(); int rValue = Convert.ToInt32(returnValue.Value); return rValue; } catch (Exception ex) { tipMsg = ex.Message; } return -1; } } }