using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; //using Core.Mes.ClientFrameWork; using Core.LgMes.Client.LgDeviceManager; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmToolStuffBaseInfo : Form { //private string szOut = ""; int intToolName = -1; //材料类型 int intQResult = -1; //工具类型 public FrmToolStuffBaseInfo() { InitializeComponent(); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Close": this.Close(); break; case "New": this.InsertNewRow(); GetData(); break; case "Update": this.UpdateRow(); GetData(); break; case "Del": this.DeleteRow(); GetData(); break; } } /// /// 修改 /// private void UpdateRow() { if (this.ulgridModel.ActiveRow != null) { string strSql = "update DEV_Item_Type_Info set "+ " ItemTypeID = '"+cboToolName.Text.ToString()+"' ,"+ " ParaID = '"+cboToolID.Text.ToString() +"' ,"+ " ToolType='"+comboBox1.Text.ToString()+"' ,"+ " Memo = '"+txtMemo.Text.ToString() + "' where " + "ItemTypeName='"+cboParaID.Text.ToString()+"' and "+ " Factory='" + cboOperation.Text.ToString() + "'"; object result = null;// ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "ExecuteSQL", new object[] { strSql }, out szOut); if ((int)result == -1) { MessageBox.Show("修改失败!", "提示"); } else { MessageBox.Show("制造厂家是主键不能修改,其它值修改成功!", "提示"); } } else { MessageBox.Show("请选择要修改的记录!", "提示"); } } /// /// 删除 /// private void DeleteRow() { if (this.ulgridModel.ActiveRow != null) { string strSql = "delete DEV_Item_Type_Info where " + "ItemTypeName='" + ulgridModel.ActiveRow.Cells["材料类型名称"].Value.ToString() + "' and " + " Factory='" + ulgridModel.ActiveRow.Cells["制造厂家"].Value.ToString() + "' "; object result = null;// ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "ExecuteSQL", new object[] { strSql }, out szOut); if ((int)result == -1) { MessageBox.Show("删除失败!", "提示"); } else { MessageBox.Show("删除成功!", "提示"); cboParaID.Text = ""; //材料类型名称 comboBox1.Text = ""; //工具类型 cboToolID.Text = ""; //参数类型编号 cboOperation.Text = ""; //制造厂家 cboToolName.Text = ""; //材料类型编号 txtMemo.Text = ""; //备注 } } else { MessageBox.Show("请选择要删除的记录!", "提示"); } } /// /// 新增 /// private void InsertNewRow() { if (cboParaID.Text.Trim().Length > 0 && cboOperation.Text.Trim().Length > 0) { //string szOut = ""; string strsql = "select ItemTypeName from DEV_Item_Type_Info where ItemTypeName = '" + cboParaID.Text.ToString() + "' and Factory = '" + cboOperation.Text.ToString() + "' "; //bool IsTure = "";// (bool)ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "ValidateData", new object[] { strsql }, out szOut); //if (IsTure) //{ // MessageBox.Show("材料类型名称为:" + cboParaID.Text.ToString() + "\n 制造厂家为:" + cboOperation.Text.ToString() + "\n已存在!", "新增失败"); //} //else //{ // string strSql = "insert into DEV_Item_Type_Info(ItemTypeID,ItemTypeName,Factory,ParaID,ToolType,Memo) " + // " values ('" + cboToolName.Text.ToString() + "','" + // cboParaID.Text.ToString() + "','" + // cboOperation.Text.ToString() + "','" + // cboToolID.Text.ToString() + "','" + // comboBox1.Text.ToString() + "','" + // txtMemo.Text.ToString() + "'" + // ")"; // object result = null;// ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "ExecuteSQL", new object[] { strSql }, out szOut); // if ((int)result == -1) // { // MessageBox.Show("新增失败!", "提示"); // } // else // { // MessageBox.Show("新增成功!", "提示"); // } //} } else { MessageBox.Show("材料类型名称和制造厂家不能为空!", "提示"); } } private void ulgridModel_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { } private void FrmToolStuffBaseInfo_Load(object sender, EventArgs e) { intToolName = -1; //材料类型 intQResult = -1; //工具类型 GetData(); } private void GetData() { GetCLLX(); GetGJLX(); cboQToolName.SelectedIndex=intToolName; cboQResult.SelectedIndex =intQResult ; QueryData(); } /// /// 查询数据 /// private void QueryData() { try { string szError = "",strWhere = ""; if (chkToolName.Checked) { strWhere += " and ItemTypeName = '" + cboQToolName.Text.ToString() + "' "; } if (chkApprove.Checked) { strWhere += " and ToolType = '" + cboQResult.Text.ToString() + "' "; } DataSet ds = null;// (DataSet)ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "QueryToolBaseData", new object[] { strWhere }, out szError); if (szError == "") { ulgridModel.DataSource = ds; ulgridModel.DataBind(); //Core.LgMes.Client.LgDeviceManager.FrmCLRepairDetail fcc = new FrmCLRepairDetail(); //fcc.SetColumnWidth(ds, ulgridModel,this.label2); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 绑定工具类型 /// private void GetGJLX() { try { //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage(); //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager"; //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager"; //par.ServerName = "LgDeviceManager"; //par.args = new object[] { "8001", "" }; //par.MethodName = "GetComboBoxData"; //string StrOut = ""; DataSet ds = null;// (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut); this.cboQResult.DataSource = ds.Tables[0]; this.cboQResult.DisplayMember = "基础名称"; comboBox1.DataSource = ds.Tables[0]; this.comboBox1.DisplayMember = "基础名称"; } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 绑定材料类型 /// private void GetCLLX() { try { string szError = ""; DataSet ds = null;// (DataSet)ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "GetBaseCLLX", new object[] { }, out szError); if (szError == "") { this.cboQToolName.DataSource = ds.Tables[0]; this.cboQToolName.DisplayMember = "材料类型"; this.cboParaID.DataSource = ds.Tables[0]; this.cboParaID.DisplayMember = "材料类型"; } } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void chkToolName_CheckedChanged(object sender, EventArgs e) { if (chkToolName.Checked) { cboQToolName.Enabled = true; } else { cboQToolName.Enabled = false; } QueryData(); } private void chkApprove_CheckedChanged(object sender, EventArgs e) { if (chkApprove.Checked) { cboQResult.Enabled = true; } else { cboQResult.Enabled = false; } QueryData(); } private void cboQToolName_SelectionChangeCommitted(object sender, EventArgs e) { //QueryData(); } private void cboQResult_SelectionChangeCommitted(object sender, EventArgs e) { //QueryData(); } private void ulgridModel_Click(object sender, EventArgs e) { if (ulgridModel.ActiveRow != null) { cboParaID.Text = ulgridModel.ActiveRow.Cells["材料类型名称"].Value.ToString(); //材料类型名称 intToolName = cboParaID.SelectedIndex; comboBox1.Text = ulgridModel.ActiveRow.Cells["工具类型"].Value.ToString(); //工具类型 cboToolID.Text = ulgridModel.ActiveRow.Cells["参数类型编号"].Value.ToString(); //参数类型编号 cboOperation.Text = ulgridModel.ActiveRow.Cells["制造厂家"].Value.ToString(); //制造厂家 cboToolName.Text = ulgridModel.ActiveRow.Cells["材料类型编号"].Value.ToString(); //材料类型编号 txtMemo.Text = ulgridModel.ActiveRow.Cells["备注"].Value.ToString(); //备注 } else { cboParaID.Text = ""; //材料类型名称 comboBox1.Text = ""; //工具类型 cboToolID.Text = ""; //参数类型编号 cboOperation.Text = ""; //制造厂家 cboToolName.Text = ""; //材料类型编号 txtMemo.Text = ""; //备注 } } private void chkToolName_CheckedChanged_1(object sender, EventArgs e) { if (chkToolName.Checked) { cboQToolName.Enabled = true; } else { cboQToolName.Enabled = false; } QueryData(); } private void chkApprove_CheckedChanged_1(object sender, EventArgs e) { if (chkApprove.Checked) { cboQResult.Enabled = true; } else { cboQResult.Enabled = false; } QueryData(); } private void cboQToolName_SelectionChangeCommitted_1(object sender, EventArgs e) { QueryData(); } private void cboQResult_SelectionChangeCommitted_1(object sender, EventArgs e) { QueryData(); } private void cboQToolName_DropDownClosed(object sender, EventArgs e) { intToolName = cboQToolName.SelectedIndex; QueryData(); } private void cboQResult_DropDownClosed(object sender, EventArgs e) { intQResult = cboQResult.SelectedIndex; QueryData(); } } }