| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.SaleOrder.Dialog
- {
- public partial class FrmInPutMpsNo : FrmBase
- {
- public FrmInPutMpsNo()
- {
- InitializeComponent();
- }
- private string ordPk;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="_ob">OB对象</param>
- /// <param name="_ordPk">合同主键</param>
- public FrmInPutMpsNo(OpeBase _ob, string _ordPk)
- {
- InitializeComponent();
- this.ob = _ob;
- this.ordPk = _ordPk;
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Query":
- InitGridData();
- break;
- case "Save":
- Save();
- break;
- case "AddMps":
- AddMps();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void AddMps()
- {
- gdMpsNo.UpdateData();
- UltraGridRow ugr = gdMpsNo.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择一行合同行!");
- return;
- }
- FrmStableMps fsm = new FrmStableMps(this.ob);
- fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
- fsm.WindowState = FormWindowState.Maximized;
- fsm.ShowDialog();
- }
- private void FrmInPutMpsNo_Load(object sender, EventArgs e)
- {
- InitGridData();
- }
- private void InitGridData()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreInPutMpsNo.queryMpsLine", new object[] { ordPk }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void Save()
- {
- gdMpsNo.UpdateData();
- ArrayList parm = new ArrayList();
- foreach (UltraGridRow ugr in gdMpsNo.Rows)
- {
- string inputMpsNo = ugr.Cells["MPS_NO_INPUT"].Value.ToString();
- string mpsFile = ugr.Cells["MPS_FILE"].Value.ToString();
- if (inputMpsNo == "")
- {
- MessageUtil.ShowWarning("请输入确认后的MPS编号!");
- ugr.Activate();
- return;
- }
- if (mpsFile == "")
- {
- MessageUtil.ShowWarning("请上传MPS文本文件!");
- ugr.Activate();
- return;
- }
- string ordLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
- ArrayList list = new ArrayList();
- list.Add(inputMpsNo);
- //list.Add(mpsFile);
- list.Add(ordLnPk);
- parm.Add(list);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定保存输入的MPS编号") == DialogResult.No) return;
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.saveMpsLine", new object[] { parm }, this.ob);
- if (count > 0)
- {
- MessageUtil.ShowTips("确认后的MPS编号保存成功!");
- this.Close();
- }
- }
- /// <summary>
- /// GRID按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MpsFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (e.Button.Key.Equals("upload")) // 上传
- {
- UltraGridRow row = gdMpsNo.ActiveRow;
- if (row == null)
- return;
- string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
- string reStr = FlileUpload("Mps/" + ordLnPk);
- if (reStr == "F")
- {
- MessageUtil.ShowWarning("上传失败,尝试重新上传!");
- return;
- }
- else if (reStr == "N")
- {
- return;
- }
- row.Cells["MPS_FILE"].Value = reStr;
- row.Cells["MPS_NO_FILE"].Value = "最近上传的MPS文本 " + reStr;
- if (updateOrderLineMps(reStr, ordLnPk))
- {
- MessageUtil.ShowTips("上传成功!");
- }
- else
- {
- MessageUtil.ShowWarning("上传失败,尝试重新上传!");
- }
- }
- else if (e.Button.Key.Equals("view")) //预览
- {
- UltraGridRow row = gdMpsNo.ActiveRow;
- if (row == null)
- return;
- string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
- string filePath = "Mps/" + ordLnPk;
- //引用的地址
- string dbFilePath = "";
- bool isNull = false;
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreInPutMpsNo.selectMpsAddr", new object[] { ordLnPk }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- dbFilePath = dt.Rows[0][0].ToString();
- }
- else
- {
- isNull = true;
- }
- //引用地址存在 优先显示引用地址的文件
- string fpath = filePath;
- if (dbFilePath != filePath && isNull == false)
- fpath = dbFilePath;
- dlgOrderAskDown down = new dlgOrderAskDown(this.ob, fpath);
- down.ShowDialog();
- if (down.CtrlFileDown1.List.Count == 0)
- {
- if (dbFilePath == filePath)
- updateOrderLineMps("", ordLnPk);
- row.Cells["MPS_FILE"].Value = "";
- row.Cells["MPS_NO_FILE"].Value = "无MPS文件";
- }
- }
- }
- private bool updateOrderLineMps(string mpsFile, string ordLnPk)
- {
- //更新合同行地址文件信息
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.updateMpsLine", new object[] { mpsFile, ordLnPk }, this.ob);
- if (count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public static string FlileUpload(string sFileName)
- {
- List<FileBean> list = new List<FileBean>();
- FileBean bean = new FileBean();
- OpenFileDialog file = new OpenFileDialog();
- file.Multiselect = false; // file.Multiselect = true 改为 file.Multiselect = false
- DialogResult drStat;
- drStat = file.ShowDialog();
- string fileList = "";
- if (drStat == DialogResult.OK)
- {
- foreach (string fileName in file.FileNames)
- {
- bean = new FileBean();
- string filena = System.IO.Path.GetFileName(fileName);
- bean.setFileName(filena);
- bean.setPathName(sFileName);
- bean.setFile(FileHelper.FileToArray(fileName));
- list.Add(bean);
- fileList = filena;
- }
- bool isSuccess = false;
- isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- return fileList;
- }
- else
- {
- return "F";
- }
- }
- else
- return "N"; //未选择文件
- }
- private void stableMps_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (e.Button.Key.Equals("select"))
- {
- gdMpsNo.UpdateData();
- UltraGridRow ugr = gdMpsNo.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择一行合同行!");
- return;
- }
- FrmStableMps fsm = new FrmStableMps(this.ob);
- fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
- fsm.WindowState = FormWindowState.Maximized;
- fsm.WdType = "2";
- fsm.frmClosedRefresh += fsm_frmClosedRefresh;
- fsm.ShowDialog();
- }
- }
- void fsm_frmClosedRefresh()
- {
- InitGridData();
- }
- }
- }
|