using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Core.StlMes.Client.SaleOrder.BLL; using CoreFS.CA06; using Core.Mes.Client.Comm.Tool; using CoreFS.SA06; using Infragistics.Win.UltraWinGrid; using Core.StlMes.Client.SaleComm; using Core.Mes.Client.Comm.Server; using System.IO; using System.Net; using Core.StlMes.Client.SaleOrder.Dialog; using Core.StlMes.Client.SaleOrder.ReviewForm; namespace Core.StlMes.Client.SaleOrder.Control { public partial class CraftOrdDesignCtrl : UserControl { private CraftOrdDesignBLL _craftOrdDesignBLL; private CraftOrdDesignEntity _queryCondition; private OpeBase ob = null; private bool _isPopup = false; public CraftOrdDesignCtrl(System.Windows.Forms.Control container, OpeBase ob, bool isPopup) { InitializeComponent(); this.ob = ob; _craftOrdDesignBLL = new CraftOrdDesignBLL(ob); this.Dock = DockStyle.Fill; container.Controls.Add(this); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); _isPopup = isPopup; if(isPopup == false) { ultraGrid1.DisplayLayout.Bands[0].Columns["CraftNo"].CellActivation = Activation.ActivateOnly; ultraGrid1.DisplayLayout.Bands[0].Columns["CraftNo"].CellAppearance = ultraGrid1.DisplayLayout.Bands[0].Columns["CraftSeq"].CellAppearance; ultraGrid1.DisplayLayout.Bands[0].Columns["CraftPath"].CellActivation = Activation.ActivateOnly; ultraGrid1.DisplayLayout.Bands[0].Columns["CraftPath"].CellAppearance = ultraGrid1.DisplayLayout.Bands[0].Columns["CraftSeq"].CellAppearance; craftImg.ButtonsRight.Clear(); } ultraGrid1.DisplayLayout.Bands[0].Columns["CraftPath"].EditorComponent = craftImg; } private void Relocate(CraftOrdDesignEntity craftOrdDesign) { Query(_queryCondition, _dataPurviewIds, _userId); if (craftOrdDesign == null) return; IQueryable queryableRows = ultraGrid1.Rows.AsQueryable().Where( a => a.GetValue("OrdLnPk") == craftOrdDesign.OrdLnPk && a.GetValue("CraftSeq") == craftOrdDesign.CraftSeq.ToString2()); if (queryableRows.Count() > 0) { queryableRows.First().Activate(); } } private string[] _dataPurviewIds; private string _userId; /// /// 查询工艺评审主表 /// /// public void Query(CraftOrdDesignEntity craftOrdDesign, string[] DataPurviewIds, string userId) { _dataPurviewIds = DataPurviewIds; _userId = userId; _queryCondition = craftOrdDesign; craftOrdDesignEntityBindingSource.DataSource = _craftOrdDesignBLL.Query(craftOrdDesign, DataPurviewIds, userId); foreach (UltraGridRow row in ultraGrid1.Rows) { GridEdite(row); } } /// /// 科室审核审核 /// //public void Audit(string reason) //{ // ultraGrid1.UpdateData(); // IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); // if (rows.Count() == 0) // { // MessageUtil.ShowWarning("请选择一行记录!"); // return; // } // List craftOrdDesignList = new List(); // foreach(UltraGridRow row in rows) // { // CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; // CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); // if (craftOrdDesignSts.Validflag != "3") // { // MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // //DataTable dtComMsc = GetComMscByOrdLnPk(craftOrdDesign.OrdLnPk, ob); // //if (dtComMsc.Rows.Count > 0 && dtComMsc.Rows[0]["UNIT_CODE_PROCESS"].ToString() != CoreUserInfo.UserInfo.GetDeptid() // // && CoreUserInfo.UserInfo.GetUserID() != "admin") // //{ // // MessageUtil.ShowWarning(string.Format("该工艺所属科室为{0},您没有权限!", dtComMsc.Rows[0]["UNIT_DESC_PROCESS"].ToString())); // // return; // //} // craftOrdDesignList.Add(new CraftOrdDesignEntity() // { // LockFlag = "1", // Validflag = "6", // AuditName = CoreUserInfo.UserInfo.GetUserName(), // OrdLnPk = craftOrdDesign.OrdLnPk, // CraftSeq = craftOrdDesign.CraftSeq, // Reason = reason // }); // } // _craftOrdDesignBLL.Audit(craftOrdDesignList); // MessageUtil.ShowTips("审核成功!"); // Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); //} /// /// 获取冶金规范的使用次数 /// /// /// public static DataTable GetComMscByOrdLnPk(string ordLnPk, OpeBase ob) { return ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getComMscByOrdLnPk", new object[] { ordLnPk }, ob); } /// /// 相关科室审核 /// //public void Audit1(string reason) //{ // ultraGrid1.UpdateData(); // IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); // if (rows.Count() == 0) // { // MessageUtil.ShowWarning("请选择一行记录!"); // return; // } // List craftOrdDesignList = new List(); // foreach (UltraGridRow row in rows) // { // CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; // CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); // if (craftOrdDesignSts.Validflag != "6") // { // MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // //DataTable dtComMsc = GetComMscByOrdLnPk(craftOrdDesign.OrdLnPk, ob); // //if (dtComMsc.Rows.Count > 0 && dtComMsc.Rows[0]["UNIT_CODE_PROCESS"].ToString() != CoreUserInfo.UserInfo.GetDeptid() // // && CoreUserInfo.UserInfo.GetUserID() != "admin") // //{ // // MessageUtil.ShowWarning(string.Format("该工艺所属科室为{0},您没有权限!", dtComMsc.Rows[0]["UNIT_DESC_PROCESS"].ToString())); // // return; // //} // craftOrdDesignList.Add(new CraftOrdDesignEntity() // { // LockFlag = "1", // Validflag = "4", // AuditName1 = CoreUserInfo.UserInfo.GetUserName(), // OrdLnPk = craftOrdDesign.OrdLnPk, // CraftSeq = craftOrdDesign.CraftSeq, // Reason = reason // }); // } // _craftOrdDesignBLL.Audit1(craftOrdDesignList); // MessageUtil.ShowTips("审核成功!"); // Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); //} /// /// 部门审批 /// //public void Approval(string reason) //{ // ultraGrid1.UpdateData(); // IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); // if (rows.Count() == 0) // { // MessageUtil.ShowWarning("请选择一行记录!"); // return; // } // List craftOrdDesignList = new List(); // foreach (UltraGridRow row in rows) // { // CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity(row.ListObject); // CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); // if (craftOrdDesignSts.Validflag != "4") // { // MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // string validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1"; // //只有技术中心科室的人需要批准操作,否则审批之后直接生效。 // DataTable dtComMsc = GetComMscByOrdLnPk(craftOrdDesign.OrdLnPk, ob); // if (dtComMsc.Rows[0]["DEPARTMENT_CODE"].ToString() == "002001007") // { // validflag = "7"; // } // craftOrdDesign.LockFlag = "1"; // craftOrdDesign.Validflag = validflag; // craftOrdDesign.ApprovalName = CoreUserInfo.UserInfo.GetUserName(); // craftOrdDesign.Reason = reason; // craftOrdDesignList.Add(craftOrdDesign); // //如果还需要批准操作,则不上传PDF // //string pdfName = craftOrdDesign.OrderNo + "-" + craftOrdDesign.OrderSeq + "-" + craftOrdDesign.CraftSeq.ToString().PadLeft(3, '0'); // //if (validflag != "7") // //{ // // _craftOrdDesignBLL.UpdateApproveName(craftOrdDesignList); // // if (!_craftOrdDesignBLL.CreatePdfToFtp(craftOrdDesign, pdfName)) // // { // // MessageUtil.ShowError("系统生成PDF失败,请稍后再试!"); // // return; // // } // //} // } // _craftOrdDesignBLL.Approval(craftOrdDesignList); // MessageUtil.ShowTips("审批成功!"); // Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); //} /// /// 批准 /// //public void Approval1(string reason) //{ // ultraGrid1.UpdateData(); // IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); // if (rows.Count() == 0) // { // MessageUtil.ShowWarning("请选择一行记录!"); // return; // } // List craftOrdDesignList = new List(); // foreach (UltraGridRow row in rows) // { // CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity(row.ListObject); // CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); // if (craftOrdDesignSts.Validflag != "7") // { // MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // craftOrdDesign.LockFlag = "1"; // craftOrdDesign.Validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1"; // craftOrdDesign.ApprovalName1 = CoreUserInfo.UserInfo.GetUserName(); // craftOrdDesign.Reason = reason; // craftOrdDesignList.Add(craftOrdDesign); // } // _craftOrdDesignBLL.UpdateApprove1Name(craftOrdDesignList); // //if (!CreatePdfToFtp(craftOrdDesignList)) // //{ // // MessageUtil.ShowError("系统生成PDF失败,请稍后再试!"); // // return; // //} // _craftOrdDesignBLL.Approval1(craftOrdDesignList); // MessageUtil.ShowTips("批准成功!"); // Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); //} /// /// 作废 /// //public void AuditOrApprovalFail(string type, string reason) //{ // ultraGrid1.UpdateData(); // IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); // if (rows.Count() == 0) // { // MessageUtil.ShowWarning("请选择一行记录!"); // return; // } // List craftOrdDesignList = new List(); // foreach (UltraGridRow row in rows) // { // CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; // CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); // if (type == "科室审核" && craftOrdDesignSts.Validflag != "3") // { // MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // if (type == "相关科室审核" && craftOrdDesignSts.Validflag != "6") // { // MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // if (type == "审批" && craftOrdDesignSts.Validflag != "4") // { // MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // if (type == "批准" && craftOrdDesignSts.Validflag != "7") // { // MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!"); // Relocate(craftOrdDesign); // return; // } // craftOrdDesignList.Add( new CraftOrdDesignEntity() // { // ApprovalName = CoreUserInfo.UserInfo.GetUserName(), // AuditName = CoreUserInfo.UserInfo.GetUserName(), // OrdLnPk = craftOrdDesign.OrdLnPk, // CraftSeq = craftOrdDesign.CraftSeq, // Reason = reason, // LockFlag = "1", // Validflag = "5" // }); // } // if(type == "科室审核") // { // _craftOrdDesignBLL.Audit(craftOrdDesignList); // } // else if(type == "相关科室审核") // { // _craftOrdDesignBLL.Audit1(craftOrdDesignList); // } // else if (type == "审批") // { // _craftOrdDesignBLL.Approval(craftOrdDesignList); // } // else if (type == "批准") // { // _craftOrdDesignBLL.Approval1(craftOrdDesignList); // } // MessageUtil.ShowTips(type + "成功!"); // Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); //} public void UnLock() { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一条记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认解锁工艺文件?") == DialogResult.No) return; List craftOrdDesignList = new List(); CraftOrdDesignEntity craftOrdDesign = null; foreach (UltraGridRow row in rows) { craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; craftOrdDesignList.Add(craftOrdDesign); } _craftOrdDesignBLL.UnLock(craftOrdDesignList); MessageUtil.ShowTips("解锁工艺文件成功!"); Relocate(craftOrdDesign); } public void Lock() { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一条记录!"); return; } foreach (UltraGridRow row in rows) { string ordLnPk = row.GetValue("OrdLnPk"); DataTable dtOrdLn = GetOrdLnState(ordLnPk); if (!ordLnPk.StartsWith("BL")) { if (dtOrdLn.Rows[0]["ISLOCK"].ToString() == "1") { MessageUtil.ShowWarning("当前合同行正在进行合同变更,不允许封锁工艺文件!"); row.Activate(); return; } if (decimal.Parse(dtOrdLn.Rows[0]["ORDER_LN_STATUS"].ToString()) < decimal.Parse("12020301")) { MessageUtil.ShowWarning("生效前的合同行,不允许封锁工艺文件!"); row.Activate(); return; } if (decimal.Parse(dtOrdLn.Rows[0]["ORDER_LN_STATUS"].ToString()) >= decimal.Parse("12020502")) { MessageUtil.ShowWarning("已开始生产后的合同行,不允许封锁工艺文件!"); row.Activate(); return; } } } if (MessageUtil.ShowYesNoAndQuestion("是否确认封锁工艺文件?") == DialogResult.No) return; List craftOrdDesignList = new List(); CraftOrdDesignEntity craftOrdDesign = null; foreach (UltraGridRow row in rows) { craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; craftOrdDesignList.Add(craftOrdDesign); } _craftOrdDesignBLL.Lock(craftOrdDesignList); MessageUtil.ShowTips("封锁工艺文件成功!"); Relocate(craftOrdDesign); } public void Save() { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择记录!"); return; } List craftOrdDesignList = new List(); CraftOrdDesignEntity craftOrdDesign = null; foreach (UltraGridRow row in rows) { craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; craftOrdDesignList.Add(craftOrdDesign); } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No) return; _craftOrdDesignBLL.SetMemo(craftOrdDesignList); MessageUtil.ShowTips("保存成功!"); Relocate(craftOrdDesign); } public void DeleteCraftFile() { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择记录!"); return; } List craftOrdDesignList = new List(); CraftOrdDesignEntity craftOrdDesign = null; PlaSaleOrdProcBLL plaSaleOrdProcBLL = new PlaSaleOrdProcBLL(ob); foreach (UltraGridRow row in rows) { craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; craftOrdDesignList.Add(craftOrdDesign); if (plaSaleOrdProcBLL.IsIssued(craftOrdDesign.CraftNo, craftOrdDesign.CraftNoV) > 0) { MessageUtil.ShowWarning("工艺文件号" + craftOrdDesign.CraftNo + "被已下发的合同使用,不能删除!"); return; } CraftOrdDesignEntity ordDesign2 = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (ordDesign2.CraftFileLv2D != "" || ordDesign2.CraftFileLv2E != "" || ordDesign2.CraftFileLv2F != "" || ordDesign2.CraftFileLv2G != "" || ordDesign2.CraftFileLv2H != "") { MessageUtil.ShowWarning("工艺文件号" + craftOrdDesign.CraftNo + "存在二级工艺文件,不能删除!"); return; } } if (MessageUtil.ShowYesNoAndQuestion("此删除不可恢复,是否确认永久删除?") == DialogResult.No) return; foreach (UltraGridRow row in rows) { bool delResult = FileHelper.Delete(craftOrdDesign.CraftPathOld); if (!delResult) { MessageUtil.ShowWarning("删除文件服务器中的文件失败,请重试!"); return; } } _craftOrdDesignBLL.DeleteCraftFile(craftOrdDesignList); MessageUtil.ShowTips("删除成功!"); Relocate(craftOrdDesign); } private DataTable GetOrdLnState(string ordLnPk) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getOrdLnState", new object[] { ordLnPk }, ob); return dt; } public bool UpdateCraftPath(bool isShowMsg) { if (ultraGrid1.ActiveRow == null) return false; ultraGrid1.UpdateData(); CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)ultraGrid1.ActiveRow.ListObject; CraftOrdDesignEntity craftParm = EntityHelper.CopyEntity(craftOrdDesign); if (craftOrdDesign.CraftPathOld == "") { MessageUtil.ShowWarning("请先上传工艺文件!"); return false; } DataTable dtCraftDesignAppoint = GetCraftDesignAppointByPk(craftOrdDesign.OrdLnPk); if (dtCraftDesignAppoint.Rows.Count > 0 && dtCraftDesignAppoint.Rows[0]["CRAFT_ID"].ToString() != CoreUserInfo.UserInfo.GetUserID() && CoreUserInfo.UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该合同行已指派给" + dtCraftDesignAppoint.Rows[0]["CRAFT_NAME"].ToString() + ",不能保存工艺文件号!"); return false; } if (craftOrdDesign.CraftNo.ToString() == "") { MessageUtil.ShowWarning("请输入工艺文件号!"); return false; } CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (isShowMsg && craftOrdDesignSts.Validflag != "2") { MessageUtil.ShowWarning("只有制定中的合同行才能保存工艺文件号!"); return false; } DataTable dtCraftDesignSts = GetCraftDesignSts(craftOrdDesign.OrdLnPk); if (isShowMsg) { if (dtCraftDesignSts.Rows.Count > 0) { if (dtCraftDesignSts.Rows[0]["DESIGN_STS"].ToString() != "S" || dtCraftDesignSts.Rows[0]["VALIDFLAG"].ToString() != "2") { MessageUtil.ShowWarning("只有设计状态通过的合同行才能生成工艺文件!"); return false; } } else { MessageUtil.ShowWarning("只有设计状态通过的合同行才能生成工艺文件!"); return false; } } //string isMutiUse = "0"; //DataTable craftFileCnt = GetCrafFileByCraftNo(craftOrdDesign.CraftNo, craftOrdDesign.CraftNoV); //if(craftFileCnt.Rows[0][0].ToString() == "0") //{ // if(MessageUtil.ShowYesNoAndQuestion("是否允许工艺文件多次使用?") == DialogResult.Yes) // { // isMutiUse = "1"; // } //} craftParm.UpdateName = CoreUserInfo.UserInfo.GetUserName(); craftParm.CreateName = CoreUserInfo.UserInfo.GetUserName(); craftParm.CraftSource = "人工上传"; craftParm.CraftPath = craftParm.CraftPathOld; _craftOrdDesignBLL.UpdateCraftPath(craftParm, "0", "0"); return true; } private DataTable GetCraftDesignSts(string ordLnPk) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getCraftDesignSts", new object[] { ordLnPk }, ob); return dt; } private DataTable GetCrafFileByCraftNo(string craftNo, string craftV) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getCrafFileByCraftNo", new object[] { craftNo, craftV }, ob); return dt; } /// /// 查询工艺指派记录 /// /// /// private DataTable GetCraftDesignAppointByPk(string ordLnPk) { DataTable dt = ServerHelper.GetData( "com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getCraftDesignAppointByPk", new object[] { ordLnPk }, ob); return dt; } private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)ultraGrid1.ActiveRow.ListObject; //craftOrdDesign.CraftSource = "人工上传"; //string filePath2 = "Qcm/Craft/" + craftOrdDesign.OrdLnPk + "/" + craftOrdDesign.CraftSeq; //string filePath = ultraGrid1.ActiveRow.GetValue("CraftPathOld"); ////filePath = filePath == "" ? filePath : Path.GetDirectoryName(filePath); //if (e.Button.Key.ToLower().Equals("select")) //{ // dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePath); // down.DeleteButton.Visible = _isPopup; // down.ShowDialog(); // if (down.CtrlFileDown1.List.Count == 0) // { // craftOrdDesign.CraftPath = ""; // ultraGrid1.ActiveRow.Cells["CraftPath"].Value = ""; // _craftOrdDesignBLL.UpdateCraftPath(craftOrdDesign, "0", "1"); // } //} //if (e.Button.Key.ToLower().Equals("choice")) //{ // dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePath); // down.CtrlFileDown1.FilePath = filePath; // if (down.CtrlFileDown1.List.Count > 0) // { // MessageUtil.ShowWarning("只能上传一份文件!"); // return; // } // string fileName = FlileUploadcomm.FlileUploadOnce(filePath2); // craftOrdDesign.CraftPath = filePath2 + "/" + fileName; // _craftOrdDesignBLL.UpdateCraftPath(craftOrdDesign, "0", "1"); // ultraGrid1.ActiveRow.Cells["CraftPath"].Value = fileName; // if (fileName != "") // { // down.DeleteButton.Visible = _isPopup; // down.Pic = filePath2; // down.ShowDialog(); // if (down.CtrlFileDown1.List.Count == 0) // { // craftOrdDesign.CraftPath = ""; // _craftOrdDesignBLL.UpdateCraftPath(craftOrdDesign, "0", "1"); // ultraGrid1.ActiveRow.Cells["CraftPath"].Value = ""; // } // } //} //Relocate(craftOrdDesign); ///// UltraGridRow row = ultraGrid1.ActiveRow; CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; string filePathOld = row.GetValue("CraftPathOld"); string filePathNew = "Qcm/Craft/" + craftOrdDesign.OrdLnPk + "/" + craftOrdDesign.CraftSeq + "/"; if (e.Button.Key.ToLower().Equals("select")) { dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld); down.DeleteButton.Visible = false; down.ShowDialog(); } else if (e.Button.Key.ToLower().Equals("choice")) { DataRow mscRow = _craftOrdDesignBLL.GetMscByOrdLnPk(craftOrdDesign.OrdLnPk); if (mscRow != null && mscRow["ALLOW_NK"].ToString() == "1") { MessageUtil.ShowWarning(mscRow["MSC"].ToString() + "的是否内控标志为'是',只能由系统生成工艺文件,不能上传工艺文件!"); return; } DataRow designRow = _craftOrdDesignBLL.GetCraftDesignSts(craftOrdDesign.OrdLnPk); if (designRow["DESIGN_STS"].ToString() != "S") { MessageUtil.ShowWarning("只有设计状态通过的合同行,才能上传工艺文件!"); return; } PlaSaleOrdProcBLL plaSaleOrdProcBLL = new PlaSaleOrdProcBLL(ob); if (!craftOrdDesign.OrdLnPk.StartsWith("BL")) { DataTable dtOrdLn = GetOrdLnState(craftOrdDesign.OrdLnPk); if (dtOrdLn.Rows[0]["ISLOCK"].ToString() == "1") { MessageUtil.ShowWarning("当前合同行正在进行合同变更,不允许上传工艺文件!"); return; } } int plaCnt = plaSaleOrdProcBLL.QueryCount(craftOrdDesign.CraftNo, craftOrdDesign.CraftNoV); dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld); down.CtrlFileDown1.FilePath = filePathOld; //if (plaCnt == down.CtrlFileDown1.List.Count > 0) //{ // MessageUtil.ShowWarning("只能上传一份文件!"); // return; //} List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = false; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { string fileName = file.FileName; string filena = System.IO.Path.GetFileName(fileName); string craftNo = filena.Remove(filena.LastIndexOf('.')); if (!craftNo.ToUpper().Contains("SJ") && !craftNo.ToUpper().Contains("KZ")) { MessageUtil.ShowWarning("工艺文件号必须包含SJ或者KZ!"); return; } //if (GetCraftFileCraftNoCnt(craftNo) > 0) //{ // MessageUtil.ShowWarning("该工艺文件号已被录入为多次使用的工艺文件,不能再录入为单次使用的工艺文件!"); // return; //} string strCraftNoV = _craftOrdDesignBLL.GetCraftMaxCraftNoV(craftNo); int craftNoCnt = _craftOrdDesignBLL.GetCraftCraftNoCnt(craftNo); //int craftNoRefCnt = _craftOrdDesignBLL.GetRefCraftCraftNoCnt( // craftNo, craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString()); if (plaCnt > 0 && craftOrdDesign.CraftNo != "") { //row.Cells["CraftNoV"].Value = strCraftNoV; //if (MessageUtil.ShowYesNoAndQuestion("系统已存在该工艺文件号,是否确认升级版本到"+ strCraftNoV +"?") == DialogResult.No) //{ // Relocate(craftOrdDesign); // return; //} MessageUtil.ShowWarning("该工艺文件号已被计划使用!"); return; } if (craftOrdDesign.CraftNo != "" && craftNo != craftOrdDesign.CraftNo) { MessageUtil.ShowWarning("上传的工艺文件名与需要替换的工艺文件名不一致,不能上传!"); return; } if (craftOrdDesign.CraftNo == "" && craftNoCnt > 0) { MessageUtil.ShowWarning("系统已存在该工艺文件号!"); return; } if (craftOrdDesign.CraftNo != "") { if (Core.Mes.Client.Comm.Server.FileHelper.Delete(craftOrdDesign.CraftPathOld) == false) { MessageUtil.ShowWarning("上传失败,请重试!"); return; } } //if (craftOrdDesign.CraftNo != "" && craftNoRefCnt > 0) //{ // MessageUtil.ShowWarning("该合同号"); //} //if (craftOrdDesign.CraftNo != "") //{ // filena = craftOrdDesign.CraftNo + "." + System.IO.Path.GetFileName(craftOrdDesign.CraftPathOld).Split('.')[1]; //} bean = new FileBean(); bean.setFileName(filena); bean.setPathName(filePathNew); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { row.Cells["CraftNo"].Value = row.Cells["CraftNo"].Value.ToString() == "" ? craftNo : row.Cells["CraftNo"].Value.ToString(); row.Cells["CraftPath"].Value = filena; row.Cells["CraftPathOld"].Value = filePathNew + filena; row.Cells["CreateName"].Value = CoreUserInfo.UserInfo.GetUserName(); if (UpdateCraftPath(false)) { //工艺变更 //frmCraftReviewTechnology.PlnCraftChange(craftOrdDesign.OrdLnPk, false, false, ob); MessageBox.Show("上传成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); var validRow = ultraGrid1.Rows.Where(a=>a.GetValue("Validflag") == "1").FirstOrDefault(); DataTable dt = _craftOrdDesignBLL.GetPreviousCraftLv2(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString()); if (dt.Rows.Count != 0 && MessageUtil.ShowYesNoAndQuestion( "是否复制上一条记录的二级工艺文件?") == DialogResult.Yes) { _craftOrdDesignBLL.CopyCraftFileLv2(craftOrdDesign.OrdLnPk, dt.Rows[0]["CRAFT_SEQ"].ToString(), craftOrdDesign.CraftSeq.ToString()); } } else { MessageBox.Show("上传失败,请重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } } else { MessageBox.Show("上传失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } } } ultraGrid1.UpdateData(); ultraGrid1.Refresh(); Relocate(craftOrdDesign); } private int GetCraftFileCraftNoCnt(string craftNo) { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftOrdDesignDAL.getCraftFileCraftNoCnt", new object[] { craftNo }, ob); return int.Parse(dt.Rows[0][0].ToString()); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); GridEdite(e.Cell.Row); } private void GridEdite(UltraGridRow row) { if (row.GetValue("CHK") == "True") { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.AllowEdit; } } } else { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.Key == "CHK") continue; if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.ActivateOnly; } } } ultraGrid1.UpdateData(); } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { CraftOrdDesignEntity craftOrdDesign = _craftOrdDesignBLL.QueryByPk(new CraftOrdDesignEntity() { OrdLnPk = ultraGrid1.ActiveRow.GetValue("OrdLnPk"), CraftSeq = decimal.Parse(ultraGrid1.ActiveRow.GetValue("CraftSeq")) }); //if (craftOrdDesign.Validflag != "1") //{ // MessageUtil.ShowWarning("只有生效状态才能选择二级工艺文件!"); // return; //} string msc = ultraGrid1.ActiveRow.GetValue("Msc"); switch (ultraGrid1.ActiveCell.Column.Key) { case "CraftFileLv2DDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "D", "轧制", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2EDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "E", "镦拔扩", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2FDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "F", "热处理", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2GDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "G", "加工", craftOrdDesign.CraftNo, msc); break; case "CraftFileLv2HDesc": ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "H", "接箍加工", craftOrdDesign.CraftNo, msc); break; } } private void ChoiceCraftFileLv2(string designKey, string processCode, string processDesc, string craftNo, string msc) { int cnt = _craftOrdDesignBLL.GetCntByDesignKeyProcess(designKey, processCode); if (cnt == 0) { MessageUtil.ShowWarning("一级工艺文件不包含" + processDesc + "工序!"); return; } string craftFileLv2Pks = ultraGrid1.GetActiveRowValue("CraftFileLv2" + processCode); FrmCraftFileLv2 frmCraftFileLv2 = new FrmCraftFileLv2(designKey, processCode, craftFileLv2Pks, craftNo, "1", ob, msc, false, "", "", "", ""); if (frmCraftFileLv2.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("CraftFileLv2" + processCode, frmCraftFileLv2.CraftFileLv2Pks); ultraGrid1.ActiveRow.SetValue("CraftFileLv2" + processCode + "Desc", frmCraftFileLv2.CraftFileLv2Nos); } } private void ultraTextEditor3_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { Core.StlMes.Client.Qcm.PopupTextBox popupText = new Core.StlMes.Client.Qcm.PopupTextBox(ultraGrid1.ActiveCell.Value.ToString(), 2000); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraGrid1.ActiveCell.Value = popupText.TextInfo.Trim(); ultraGrid1.ActiveRow.Update(); } } private void ultraTextEditor2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { Core.StlMes.Client.Qcm.PopupTextBox popupText = new Core.StlMes.Client.Qcm.PopupTextBox(ultraGrid1.ActiveCell.Value.ToString(), 2000); popupText.TxtInfo.ReadOnly = true; if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraGrid1.ActiveCell.Value = popupText.TextInfo.Trim(); ultraGrid1.ActiveRow.Update(); } } } }