using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA03; using CoreFS.CA04; using CoreFS.CA06; using System.Collections; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using System; namespace Core.StlMes.Client.Lims.Data.Mat { public partial class FrmBaseMatStdManage : FrmBase { public FrmBaseMatStdManage() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; } private void FrmBaseMatStdManage_Load(object sender, EventArgs e) { InitColumns(); } private void InitColumns() { string[] arrColumnsBase = new string[] { "STD_TYPE_CODE", "STD_TYPE", "STANDARDS_ID", "STANDARDS_NO", "STANDARDS_CODE", "STANDARDS_DESC", "VERSION_NO", "STD_FALG", "START_TIME", "VALID_TIME", "REMARK", "FILE_POSITION", "VALIDFLAG", "VALIDFLAG_DESC", "CREATE_NAME", "CREATE_TIME", "UPDATE_NAME", "UPDATE_TIME" }; string[] arrCaptionBase = new string[] { "标准类型", "标准类型", "标准ID", "标准组号", "标准代码", "标准名称", "版本号", "状态", "生效日期", "有效日期", "备注", "文件位置", "是否有效", "是否有效", "创建人", "创建时间", "修改人", "修改时间" }; PublicMat.InitColumns(arrColumnsBase, arrCaptionBase, dataTable1, ultraGrid1, new string[] { "STD_TYPE_CODE", "VALIDFLAG" }, false, null); BindComBoxData(); } private void BindComBoxData() { try { DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseSelectItems.GetBaseData", new Object[] { "4092" }, ob); if (dt == null || dt.Rows.Count == 0) { return; } ultraQuerySTD_TYPE.DataSource = dt; ultraQuerySTD_TYPE.ValueMember = "BASECODE"; ultraQuerySTD_TYPE.DisplayMember = "BASENAME"; ultraSTD_TYPE.DataSource = dt; ultraSTD_TYPE.ValueMember = "BASECODE"; ultraSTD_TYPE.DisplayMember = "BASENAME"; } catch (Exception ex) { MessageUtil.ShowError(ex.Message); } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { //新增修改删除退出 switch (ToolbarKey) { case "Query": QueryMatStdManageBase(); break; //case "Refresh": // BindStdSteelData(); // break; case "Add": AddMatStdManageBase(); break; case "Update": UpdateMatStdManageBase(); break; case "Delete": DeleteMatStdManageBase(); break; case "Recover": if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "0") { MessageUtil.ShowWarning("请选择一条需要恢复且状态为无效的记录!"); return; } ChangeMatStdManageBase("恢复", "1"); break; case "Cancel": if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "1") { MessageUtil.ShowWarning("请选择一条需要作废且状态为有效的记录!"); return; } ChangeMatStdManageBase("作废", "0"); break; case "Clear": if (MessageUtil.ShowYesNoAndQuestion("是否确认清空?") == DialogResult.Yes) { ClearMatStdManageBase(); } break; case "Close": if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes) { this.Close(); } break; } } private void QueryMatStdManageBase() { try { ArrayList arrayList = new ArrayList(); if (chkVALIDFLAG.Checked) { arrayList.Add(""); arrayList.Add(""); arrayList.Add(""); } else { arrayList.Add("1"); arrayList.Add("1"); arrayList.Add("1"); } if (UserInfo.ParentDepartment == "供应部") { //供应部只维护临时协议标准 arrayList.Add("409205");//临时协议标准 arrayList.Add("409205");//临时协议标准 arrayList.Add("409205");//临时协议标准 } else { if (chKSTD_TYPE.Checked && ultraQuerySTD_TYPE.Value != null) { arrayList.Add(ultraQuerySTD_TYPE.Value.ToString()); arrayList.Add(ultraQuerySTD_TYPE.Value.ToString()); arrayList.Add(ultraQuerySTD_TYPE.Value.ToString()); } else { arrayList.Add(""); arrayList.Add(""); arrayList.Add(""); } } if (chkSTANDARDS_CODE.Checked && ultraQuerySTANDARDS_CODE.Value != null) { arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString()); arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString()); arrayList.Add(ultraQuerySTANDARDS_CODE.Value.ToString()); } else { arrayList.Add(""); arrayList.Add(""); arrayList.Add(""); } DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseMatStdManage.QueryMatStdManageBase", new Object[] { arrayList }, ob); if (dt == null || dt.Rows.Count == 0) { ClearMatStdManageBase(); dataTable1.Rows.Clear(); MessageUtil.ShowTips("没有维护标准基础数据!"); return; } GridHelper.CopyDataToDatatable(dt, dataTable1, true);//把dt复制给dataTable1 GridHelper.RefreshAndAutoSize(ultraGrid1); } catch (Exception e) { MessageUtil.ShowWarning(e.Message); return; } } private void AddMatStdManageBase() { try { if (ultraSTD_TYPE.Text.Trim() == "") { MessageUtil.ShowWarning("标准类型不能为空!"); return; } if (txtSTANDARDS_CODE.Text.Trim() == "") { MessageUtil.ShowWarning("标准代码不能为空!"); return; } if (ultraSTD_FALG.Text == "换版" && ultraGrid1.ActiveRow == null) { MessageUtil.ShowWarning("换版的标准新增必选点击选择上一个版本!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.Yes) { string strSTANDARDS_CODE = txtSTANDARDS_CODE.Text; ArrayList arrayList = new ArrayList(); arrayList.Add(ultraSTD_TYPE.Value.ToString()); arrayList.Add(ultraSTD_TYPE.Text.Trim()); if (ultraSTD_FALG.Text == "换版") { arrayList.Add(ultraGrid1.ActiveRow.Cells["STANDARDS_NO"].Text.Trim());//标准组号 arrayList.Add(ultraGrid1.ActiveRow.Cells["STANDARDS_NO"].Text.Trim()); } else { arrayList.Add(""); arrayList.Add(""); } arrayList.Add(txtSTANDARDS_CODE.Text.Trim()); arrayList.Add(txtSTANDARDS_DESC.Text.Trim()); arrayList.Add(txtVERSION_NO.Text.Trim()); arrayList.Add(ultraSTD_FALG.Text.Trim()); arrayList.Add(START_TIME.Text.Trim()); arrayList.Add(VALID_TIME.Text.Trim()); arrayList.Add(txtREMARK.Text.Trim()); arrayList.Add(UserInfo.GetUserName()); PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.AddMatStdManageBase", new Object[] { strSTANDARDS_CODE, arrayList }, this.ob); QueryMatStdManageBase(); PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_CODE", strSTANDARDS_CODE);//定位保存的行 MessageUtil.ShowTips("新增成功!"); } } catch (Exception e) { MessageUtil.ShowWarning(e.Message); return; } } private void UpdateMatStdManageBase() { try { if (ultraGrid1.ActiveRow == null) { MessageUtil.ShowWarning("请选择一条需要修改的记录!"); return; } if (ultraSTD_TYPE.Text.Trim() == "") { MessageUtil.ShowWarning("标准类型不能为空!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.Yes) { string strSTANDARDS_ID = txtSTANDARDS_ID.Text; ArrayList arrayList = new ArrayList(); arrayList.Add(ultraSTD_TYPE.Value.ToString()); arrayList.Add(ultraSTD_TYPE.Text.Trim()); arrayList.Add(txtSTANDARDS_CODE.Text.Trim()); arrayList.Add(txtSTANDARDS_DESC.Text.Trim()); arrayList.Add(txtVERSION_NO.Text.Trim()); arrayList.Add(ultraSTD_FALG.Text.Trim()); arrayList.Add(START_TIME.Text.Trim()); arrayList.Add(VALID_TIME.Text.Trim()); arrayList.Add(txtREMARK.Text.Trim()); arrayList.Add(UserInfo.GetUserName()); arrayList.Add(strSTANDARDS_ID); PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.UpdateMatStdManageBase", new Object[] { txtSTANDARDS_CODE.Text.Trim(), strSTANDARDS_ID, arrayList }, this.ob); QueryMatStdManageBase(); PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strSTANDARDS_ID);//定位保存的行 MessageUtil.ShowTips("修改成功!"); } } catch (Exception e) { MessageUtil.ShowWarning(e.Message); return; } } private void DeleteMatStdManageBase() { try { if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Text.Trim() != "1") { MessageUtil.ShowWarning("请选择一条需要删除且状态为有效的记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.Yes) { string strSTANDARDS_ID = txtSTANDARDS_ID.Text; ArrayList arrayList = new ArrayList(); arrayList.Add(strSTANDARDS_ID); PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.DeleteMatStdManageBase", new Object[] { arrayList }, this.ob); QueryMatStdManageBase(); MessageUtil.ShowTips("删除成功!"); } } catch (Exception e) { MessageUtil.ShowWarning(e.Message); return; } } private void ChangeMatStdManageBase(string strOper, string flag) { try { if (MessageUtil.ShowYesNoAndQuestion("是否确认" + strOper + "?") == DialogResult.Yes) { string strSTANDARDS_ID = txtSTANDARDS_ID.Text; ArrayList arrayList = new ArrayList(); arrayList.Add(flag); arrayList.Add(strSTANDARDS_ID); PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatStdManage.ChangeMatStdManageBase", new Object[] { arrayList }, this.ob); QueryMatStdManageBase(); MessageUtil.ShowTips(strOper + "成功!"); } } catch (Exception e) { MessageUtil.ShowWarning(e.Message); return; } } private void ClearMatStdManageBase() { ultraSTD_TYPE.Text = ""; txtSTANDARDS_ID.Text = ""; txtSTANDARDS_CODE.Text = ""; txtVERSION_NO.Text = ""; txtSTANDARDS_DESC.Text = ""; START_TIME.Value = DateTime.Now; VALID_TIME.Value = DateTime.Now; ultraSTD_FALG.Text = ""; txtFILE_POSITION.Text = ""; txtREMARK.Text = ""; } private void View_Click(object sender, EventArgs e) { UltraGridRow ur = ultraGrid1.ActiveRow; if (ur == null) { MessageUtil.ShowWarning("请选择一条需要查看上传文件的记录!"); return; } if (txtFILE_POSITION.Text == "") { MessageUtil.ShowWarning("请先上传再查看!"); return; } string strTableName = "BASE_MAT_STD_MANAGE"; string strId = ur.Cells["STANDARDS_ID"].Text.Trim(); string path = "Lims/data/base/" + this.Name + "/" + ur.Cells["STANDARDS_ID"].Text.Trim() + "/"; if (PublicMat.ViewFilePosition(this.ob, path) == false) { PublicMat.UpdateFilePosition(strTableName, "", "STANDARDS_ID", strId, this.ob);//更改数据库存储路径 QueryMatStdManageBase(); PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strId);//定位保存的行 } } private void Upload_Click(object sender, EventArgs e) { //if (txtCER_BOOK.Text != "") //{ // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!"); // return; //} UltraGridRow ur = ultraGrid1.ActiveRow; if (ur == null) { MessageUtil.ShowWarning("请选择一条需要上传文件的记录!"); return; } string strTableName = "BASE_MAT_STD_MANAGE"; string strId = ur.Cells["STANDARDS_ID"].Text.Trim(); string path = "Lims/data/base/" + this.Name + "/" + strId + "/"; if (PublicMat.UploadFilePosition(this.ob, path)) { PublicMat.UpdateFilePosition(strTableName, path, "STANDARDS_ID", strId, this.ob);//更改数据库存储路径 QueryMatStdManageBase(); PublicMat.ActiveOperateRow(ultraGrid1, "STANDARDS_ID", strId); } } private void chKSTD_TYPE_CheckedChanged(object sender, EventArgs e) { ultraQuerySTD_TYPE.Enabled = chKSTD_TYPE.Checked; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { setValue(); } private void setValue() { ultraSTD_TYPE.Text = ultraGrid1.ActiveRow.Cells["STD_TYPE"].Text.Trim(); txtSTANDARDS_ID.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_ID"].Text.Trim(); txtSTANDARDS_CODE.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_CODE"].Text.Trim(); txtVERSION_NO.Text = ultraGrid1.ActiveRow.Cells["VERSION_NO"].Text.Trim(); txtSTANDARDS_DESC.Text = ultraGrid1.ActiveRow.Cells["STANDARDS_DESC"].Text.Trim(); START_TIME.Text = ultraGrid1.ActiveRow.Cells["START_TIME"].Text.Trim(); VALID_TIME.Text = ultraGrid1.ActiveRow.Cells["VALID_TIME"].Text.Trim(); ultraSTD_FALG.Text = ultraGrid1.ActiveRow.Cells["STD_FALG"].Text.Trim(); txtFILE_POSITION.Text = ultraGrid1.ActiveRow.Cells["FILE_POSITION"].Text.Trim(); txtREMARK.Text = ultraGrid1.ActiveRow.Cells["REMARK"].Text.Trim(); } private void chkSTANDARDS_CODE_CheckedChanged(object sender, EventArgs e) { ultraQuerySTANDARDS_CODE.Enabled = chkSTANDARDS_CODE.Checked; } } }