using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Common; namespace Core.LZMes.Client.UIF { public partial class UIF041030 : CoreFS.CA06.FrmBase { public UIF041030() { InitializeComponent(); } #region "ComboBox Event" private void cmb_GrpType_ValueChanged(object sender, EventArgs e) { try { if (cmb_GrpType.Value.ToString() == "厚度") { this.ugrd_Group.DataMember = "TBF02_ROLL_THK_GRP"; label6.Text = "厚度组"; this.txt_Mini.Mask = "9.999"; this.txt_Maxi.Mask = "9.999"; this.label1.Visible = true; this.cmb_Type.Visible = true; this.cmb_GrpType.Value = "厚度"; } else { this.ugrd_Group.DataMember = "TBF02_ROLL_WTH_GRP"; label6.Text = "宽度组"; this.txt_Mini.Mask = "9999"; this.txt_Maxi.Mask = "9999"; this.label1.Visible = false; this.cmb_Type.Visible = false; } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } #endregion #region "ToolBar Event" public override void ToolBar_Click(object sender, string ToolbarKey) { try { switch (ToolbarKey) { case "Query": Query_GrpInfo(); break; case "Add": Add_GrpInfo(); break; case "Edit": Edit_GrpInfo(); break; case "Delete": Del_GrpInfo(); break; case "Exit": this.Close(); break; } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Query_GrpInfo() { try { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIF.UIF04.UIF041030"; ccp.MethodName = "Query_Group_Info"; ccp.ServerParams = new object[] { "",this.cmb_GrpType.Value.ToString() }; CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal); if (obj.ReturnInfo.Length == 0) { if (this.cmb_GrpType.Value.ToString() == "厚度") { this.dataSet1.Tables["TBF02_ROLL_THK_GRP"].Clear(); System.Data.DataTable tab0 = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["TBF02_ROLL_THK_GRP"]); tab0.TableName = "TBF02_ROLL_THK_GRP"; this.dataSet1.Tables["TBF02_ROLL_THK_GRP"].Merge(tab0); this.dataSet1.AcceptChanges(); } else { this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"].Clear(); System.Data.DataTable tab0 = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"]); tab0.TableName = "TBF02_ROLL_WTH_GRP"; this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"].Merge(tab0); this.dataSet1.AcceptChanges(); } } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Add_GrpInfo() { try { if (!CheckValue()) return; string sql = ""; if (this.cmb_GrpType.Value.ToString() == "厚度") { if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_THK_GRP","ADD")) return; sql = "INSERT INTO TBF02_ROLL_THK_GRP(PLT,THK_GRP_CD,MINI,MAXI,REG_DTIME,REG_ID,MOD_DTIME,MOD_ID,TYPE_) " + "VALUES('C'," + "'" + this.txt_GrpName.Text.Trim().ToUpper() + "'," + FixDBManager.CheckNullStr(this.txt_Mini.Text) + "," + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + "," + "TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," + "'" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "'," + "NULL," + "NULL," + "'" + this.cmb_Type.Value.ToString() + "'" + ")"; } else { if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_WTH_GRP","ADD")) return; sql = "INSERT INTO TBF02_ROLL_WTH_GRP(PLT,WTH_GRP_CD,MINI,MAXI,REG_DTIME,REG_ID,MOD_DTIME,MOD_ID) " + "VALUES('C'," + "'" + this.txt_GrpName.Text.Trim().ToUpper() + "'," + FixDBManager.CheckNullStr(this.txt_Mini.Text) + "," + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + "," + "TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," + "'" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "'," + "NULL," + "NULL" + ")"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIF.UIF04.UIF041030"; ccp.MethodName = "Add_Group_Info"; ccp.ServerParams = new object[] { sql }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if(ccp.ReturnInfo.Length==0) Query_GrpInfo(); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Edit_GrpInfo() { try { if (this.ugrd_Group.ActiveRow == null) { MessageBox.Show("请选择您要修改的记录行"); return; } if (!CheckValue()) return; string sql = ""; if (this.cmb_GrpType.Value.ToString() == "厚度") { if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_THK_GRP","EDIT")) return; sql = "UPDATE TBF02_ROLL_THK_GRP SET THK_GRP_CD='" + this.txt_GrpName.Text.Trim().ToUpper() + "'," + "MINI=" + FixDBManager.CheckNullStr(this.txt_Mini.Text) + "," + "MAXI=" + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + "," + "MOD_DTIME=TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," + "MOD_ID='" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "'," + "TYPE_='" + this.cmb_Type.Value.ToString() + "' " + "WHERE PLT='C' AND THK_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'"; } else { if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_WTH_GRP","EDIT")) return; sql = "UPDATE TBF02_ROLL_WTH_GRP SET WTH_GRP_CD='" + this.txt_GrpName.Text.Trim().ToUpper() + "'," + "MINI=" + FixDBManager.CheckNullStr(this.txt_Mini.Text) + "," + "MAXI=" + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + "," + "MOD_DTIME=TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," + "MOD_ID='" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "' " + "WHERE PLT='C' AND WTH_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIF.UIF04.UIF041030"; ccp.MethodName = "Edit_Group_Info"; ccp.ServerParams = new object[] { sql }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if(ccp.ReturnInfo.Length==0) Query_GrpInfo(); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Del_GrpInfo() { try { if (this.ugrd_Group.ActiveRow == null) { MessageBox.Show("请选择您要删除的记录行"); return; } string sql = ""; if (this.cmb_GrpType.Value.ToString() == "厚度") { sql = "DELETE FROM TBF02_ROLL_THK_GRP WHERE PLT='C' AND THK_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'"; } else { sql = "DELETE FROM TBF02_ROLL_WTH_GRP WHERE PLT='C' AND WTH_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIF.UIF04.UIF041030"; ccp.MethodName = "Delete_Group_Info"; ccp.ServerParams = new object[] { sql }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if(ccp.ReturnInfo.Length==0) Query_GrpInfo(); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private bool CheckValue() { if (this.txt_GrpName.Text.Trim().Length == 0) { MessageBox.Show("请您确认组名"); return false; } if (this.txt_Mini.Text.Trim().Length == 0) { MessageBox.Show("请您确认下限值"); return false; } if (this.txt_Mini.Text.Trim().Length == 0) { MessageBox.Show("请您确认上限值"); return false; } if (this.cmb_GrpType.Value.ToString() == "厚度") { if (this.cmb_Type.Text.Trim().Length == 0) { MessageBox.Show("请您确认厚度组的区分"); return false; } } return true; } private bool CheckValueConstraints(string Mini,string Maxi,string TableName,string type) { string Condition = " AND ((MINI<=" + Mini + " AND " + Mini + "'" + Common.FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'"; else Condition = Condition + " AND WTH_GRP_CD<>'" + Common.FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIF.UIF04.UIF041030"; ccp.MethodName = "Query_Group_Info"; ccp.ServerParams = new object[] { Condition, this.cmb_GrpType.Value.ToString() }; CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal); if (obj.ReturnInfo.Length == 0) { System.Data.DataTable tab = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables[TableName]); if (tab.Rows.Count> 0) { MessageBox.Show("维护数据与已存在数据有交集,请检查"); return false; } } return true; } #endregion #region "Init" private void UIF041030_Load(object sender, EventArgs e) { try { this.cmb_GrpType.DisplayLayout.Bands[0].Columns[0].Band.ColHeadersVisible = false; this.cmb_GrpType.DisplayLayout.Bands[0].Columns[0].Width = this.cmb_GrpType.Width; this.cmb_Type.DisplayLayout.Bands[0].Columns[0].Band.ColHeadersVisible = false; this.cmb_Type.DisplayLayout.Bands[0].Columns[0].Width = this.cmb_Type.Width; cmb_GrpType.Value = "厚度"; } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } #endregion #region "Grid Event" private void ugrd_Group_AfterRowActivate(object sender, EventArgs e) { try { if (this.ugrd_Group.ActiveRow != null) { if (this.cmb_GrpType.Text == "厚度") { this.txt_GrpName.Text = this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value.ToString(); this.cmb_Type.Value = this.ugrd_Group.ActiveRow.Cells["TYPE_"].Value.ToString(); } else { this.txt_GrpName.Text = this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value.ToString(); } this.txt_Mini.Text = this.ugrd_Group.ActiveRow.Cells["MINI"].Value.ToString(); this.txt_Maxi.Text = this.ugrd_Group.ActiveRow.Cells["MAXI"].Value.ToString(); } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } #endregion } }