| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- using com.steering.pss.sale.order.model;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.SaleOrder.Dialog;
- 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.OrderForm
- {
- public partial class FrmOrderAuthentication : FrmBase
- {
- public FrmOrderAuthentication()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- /// <summary>
- /// 可以编辑的列
- /// </summary>
- List<string> editList = new List<string>();
- private void FrmOrderAuthentication_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<SlmOrderAuthenticationEntity>(gdOrderInfo.DisplayLayout.Bands[0]);
- editList.AddRange(new string[] { "CUSTMSIGNDATE", "CUSTMDELVRYDATE", "SCHAPPROVENO",
- "ORDAPPROVENO", "MEMO", "CUSTMORDERNO" });
- dtpEnd.Value = DateTime.Now;
- dtpStart.Value = DateTime.Now.AddMonths(-2);
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- QueryAuthedOrd();
- break;
- case "ReturnTime":
- ReturnTime();
- break;
- case "Save":
- SaveWriteData();
- break;
- case "GetData":
- getOrdData();
- break;
- case "Update":
- UpdateDataBase();
- break;
- case "Close":
- this.Close();
- break;
- case "Export":
- GridHelper.ulGridToExcel(gdOrderInfo, "认证合同");
- break;
- case "Print":
- gdOrderInfo.UpdateData();
- UltraGridRow row = gdOrderInfo.ActiveRow;
- if (row == null) return;
- string strOrderLinePk = row.Cells["ORDLNPK"].Value.ToString();
- string url ="";
- url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepSalesStockOutOrder.cpt&__bypagesize__=false&ORD_LN_PK=" + strOrderLinePk + "";
- FrmRepExcel fre = new FrmRepExcel(this.ob, url);
- fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fre.Text = "天津钢管集团股份有限公司产品出库单";
- fre.ShowDialog();
- break;
- }
- }
- /// <summary>
- /// 获取合同数据至合同认证表
- /// </summary>
- private void getOrdData()
- {
- WaitingForm2 wf = new WaitingForm2();
- wf.Msg = "数据处理中,请稍等。。。";
- wf.Show();
- wf.Update();
- try
- {
- CoreClientParam ccp = new CoreClientParam();
- ccp.IfShowErrMsg = false;
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderAuthentication";
- ccp.MethodName = "getOrdData";
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnCode == -1)
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo);
- wf.Close();
- return;
- }
- wf.Close();
- QueryAuthedOrd();
- }
- }
- finally
- {
- wf.ShowToUser = false;
- wf.Close();
- }
- }
- /// <summary>
- /// 查询数据
- /// </summary>
- private void QueryAuthedOrd()
- {
- WaitingForm2 wf = new WaitingForm2();
- wf.Msg = "数据查询中,请稍等。。。";
- wf.Show();
- wf.Update();
- try
- {
- string ordNo = "";
- string strArea = "";
- string timeStart = "";
- string timeEnd = "";
- if (chkOrderNo.Checked)
- ordNo = txtOrderNo.Text.Trim();
- if (chkArea.Checked)
- strArea = this.txtArea.Text.Trim();
- if (chkTime.Checked)
- {
- if (dtpEnd.Value < dtpStart.Value)
- {
- MessageUtil.ShowWarning("开始时间不能大于结束时间!");
- return;
- }
- timeStart = dtpStart.Value.ToString("yyyy-MM-dd") + " 00:00:01";
- timeEnd = dtpEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
- }
- List<SlmOrderAuthenticationEntity> list = EntityHelper.GetData<SlmOrderAuthenticationEntity>(
- "com.steering.pss.sale.order.CoreOrderAuthentication.queryAuthedOrd", new object[] { ordNo, strArea, timeStart, timeEnd, timeType.Value.ToString() }, this.ob);
- slmOrderAuthenticationBS1.DataSource = list;
- wf.Close();
- foreach (UltraGridRow urg in gdOrderInfo.Rows)
- {
- if (urg.Cells["OrderFile"].Text.Equals("有合同文本"))
- {
- urg.Cells["OrderFile"].Appearance.ForeColor = Color.Red;
- }
- if (urg.Cells["UserorderFile"].Text.Equals("有合同文本"))
- {
- urg.Cells["UserorderFile"].Appearance.ForeColor = Color.Red;
- }
- }
- }
- finally
- {
- wf.ShowToUser = false;
- wf.Close();
- }
- }
- /// <summary>
- /// 后台更新数据 (将多个数据表的数据搬到 SLM_ORDER_AUTHENTICATION 表中 )
- /// </summary>
- private void UpdateDataBase()
- {
- gdOrderInfo.UpdateData();
- UltraGridRow[] row = gdOrderInfo.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
- if (row.Length <= 0)
- {
- MessageUtil.ShowWarning("请选择需要更新的合同号!");
- return;
- }
-
- List<string> ordArr = new List<string>();
- for (int i = 0; i < row.Length; i++)
- {
- if (!ordArr.Contains(row[i].Cells["OrderNo"].Value.ToString())
- && !string.IsNullOrEmpty(row[i].Cells["OrderNo"].Value.ToString())
- && !row[i].IsFilteredOut)
- {
- ordArr.Add(row[i].Cells["OrderNo"].Value.ToString());
- }
- }
- string[] strResult = ordArr.ToArray();
- if (strResult.Length > 10000)
- {
- MessageUtil.ShowWarning("鉴于系统数据量过大,合同号的个数不能超过300个!");
- return;
- }
- WaitingForm2 wf = new WaitingForm2();
- wf.Msg = "正在更新数据中,请稍等。。。";
- wf.Show();
- wf.Update();
- try
- {
- CoreClientParam ccp = new CoreClientParam();
- ccp.IfShowErrMsg = false;
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderAuthentication";
- ccp.MethodName = "updateData";
- ccp.ServerParams = new object[] { strResult };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnCode == -1)
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo);
- wf.Close();
- return;
- }
- wf.Close();
- QueryAuthedOrd();
- }
- }
- finally
- {
- wf.ShowToUser = false;
- wf.Close();
- }
- }
- private void gdOrderInfo_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow uRow = gdOrderInfo.ActiveRow;
- if (uRow != null)
- {
- if (uRow.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- for (int i = 0; i < editList.Count; i++)
- {
- uRow.Cells[editList[i]].Activation = Activation.AllowEdit;
- }
- }
- else
- {
- for (int i = 0; i < editList.Count; i++)
- {
- uRow.Cells[editList[i]].Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void gdOrderInfo_CellChange(object sender, CellEventArgs e)
- {
- if (!e.Cell.Column.Key.ToUpper().Equals("CUSTMSIGNDATE") &&
- !e.Cell.Column.Key.ToUpper().Equals("CUSTMDELVRYDATE"))
- gdOrderInfo.UpdateData();
- if (e.Cell.Column.Key.Equals("CHK"))
- {
- if (e.Cell.Value.ToString().ToUpper() == "TRUE")
- {
- for (int i = 0; i < editList.Count; i++)
- {
- e.Cell.Row.Cells[editList[i]].Activation = Activation.AllowEdit;
- }
- }
- else
- {
- for (int i = 0; i < editList.Count; i++)
- {
- e.Cell.Row.Cells[editList[i]].Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void gdOrderInfo_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in gdOrderInfo.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHK"].Value = true;
- }
- }
- }
- private void ReturnTime()
- {
- gdOrderInfo.UpdateData();
- UltraGridRow[] row = gdOrderInfo.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
- if (row.Length <= 0)
- {
- MessageUtil.ShowWarning("请选择您要确认合同返回的合同!");
- return;
- }
- List<string> ordArr = new List<string>();
- for (int i = 0; i < row.Length; i++)
- {
- if (!row[i].IsFilteredOut)
- {
- ordArr.Add(row[i].Cells["ORDLNPK"].Value.ToString());
- }
- }
- string[] parm = ordArr.ToArray();
- //int flag = 0;
- //foreach (var uRow in row)
- //{
- // if (uRow.Cells["ISRETURN"].Value.ToString() == "已返回")
- // flag += 1;
- //}
- //string str = "";
- //if (flag > 0)
- //{
- // str = "存在已经确认返回的合同,是否覆盖其返回时间?";
- //}
- //else
- //{
- // str = "是否确认合同返回?";
- //}
- if (MessageUtil.ShowYesNoAndQuestion("是否确认合同返回?") == DialogResult.No) return;
- CoreClientParam ccp = new CoreClientParam();
- ccp.IfShowErrMsg = false;
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderAuthentication";
- ccp.MethodName = "returnTime";
- ccp.ServerParams = new object[] { parm, UserInfo.GetUserName() };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnCode == -1)
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo);
- return;
- }
- MessageUtil.ShowTips("确认合同返回成功!");
- QueryAuthedOrd();
- }
- }
- /// <summary>
- /// 保存数据
- /// </summary>
- private void SaveWriteData()
- {
- gdOrderInfo.UpdateData();
- UltraGridRow[] row = gdOrderInfo.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
- if (row.Length <= 0)
- {
- MessageUtil.ShowWarning("请选择需要保存的数据!");
- return;
- }
- ArrayList parm = new ArrayList();
- foreach (var uRow in row)
- {
- SlmOrderAuthenticationEntity soa = (SlmOrderAuthenticationEntity)uRow.ListObject;
- if (soa.CustmSignDate != "")
- {
- if (StringUtil.IsNotDateTime(soa.CustmSignDate))
- {
- MessageUtil.ShowWarning("请输入客户合同签订日期!");
- return;
- }
- soa.CustmSignDate = Convert.ToDateTime(soa.CustmSignDate).ToString("yyyy-MM-dd");
- }
- if (soa.CustmDelvryDate != "")
- {
- if (StringUtil.IsNotDateTime(soa.CustmDelvryDate))
- {
- MessageUtil.ShowWarning("请输入客户合同交货日期!");
- return;
- }
- soa.CustmDelvryDate = Convert.ToDateTime(soa.CustmDelvryDate).ToString("yyyy-MM-dd");
- }
- /*if (soa.SchApproveNo == "")
- {
- MessageUtil.ShowWarning("请输入排产审批单号!");
- return;
- }
- if (soa.OrdApproveNo == "")
- {
- MessageUtil.ShowWarning("请输入合同审批单号!");
- return;
- }*/
- parm.Add(soa);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否保存数据?") == DialogResult.No) return;
- CoreClientParam ccp = new CoreClientParam();
- ccp.IfShowErrMsg = false;
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderAuthentication";
- ccp.MethodName = "saveWrite";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnCode == -1)
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo);
- return;
- }
- MessageUtil.ShowTips("保存成功!");
- QueryAuthedOrd();
- }
- }
- private void gdOrderInfo_CellDataError(object sender, CellDataErrorEventArgs e)
- {
- e.RaiseErrorEvent = false;
- e.StayInEditMode = true;
- }
- private void chkOrderNo_CheckedChanged(object sender, EventArgs e)
- {
- if (chkOrderNo.Checked)
- {
- txtOrderNo.ReadOnly = false;
- }
- else
- {
- txtOrderNo.ReadOnly = true;
- }
- }
- private void txtOrderNo_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == 13)
- this.QueryAuthedOrd();
- }
- private void chkTime_CheckedChanged(object sender, EventArgs e)
- {
- if (!chkTime.Checked)
- {
- dtpStart.Enabled = false;
- dtpEnd.Enabled = false;
- }
- else
- {
- dtpStart.Enabled = true;
- dtpEnd.Enabled = true;
- }
- }
- private void txtOrderNo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (e.Button.Key.Equals("select"))
- {
- FrmOrdNoSelect fos = new FrmOrdNoSelect(this.ob);
- fos.ShowDialog();
- if (fos.DialogResult != DialogResult.OK)
- return;
- txtOrderNo.Tag = fos.OrdArr;
- }
- }
- private void OrdFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (e.Button.Key.Equals("upload")) // 上传
- {
- UltraGridRow row = gdOrderInfo.ActiveRow;
- if (row == null)
- return;
- string ordPk = row.Cells["ORDPK"].Value.ToString();
- string reStr = FlileUpload("ORDFILE/" + ordPk);
- if (reStr == "F")
- {
- MessageUtil.ShowWarning("上传失败,尝试重新上传!");
- return;
- }
- else if (reStr == "N")
- {
- return;
- }
- //将合同所在的文件名称存入数据库
- if (updateOrderLineOrdFile(ordPk, "ORDFILE/" + ordPk))
- {
- MessageUtil.ShowTips("上传成功!");
- updateGridOrdFile(ordPk, "1");
- }
- }
- else if (e.Button.Key.Equals("view")) //预览
- {
- UltraGridRow row = gdOrderInfo.ActiveRow;
- if (row == null)
- return;
- string ordPk = row.Cells["ORDPK"].Value.ToString();
- string filePath = "ORDFILE/" + ordPk;
- dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePath);
- down.ShowDialog();
- if (down.CtrlFileDown1.List.Count == 0)
- {
- updateOrderLineOrdFile(ordPk, "");
- updateGridOrdFile(ordPk, "2");
- }
- }
- }
- /// <summary>
- /// 更新界面合同文本字段
- /// </summary>
- /// <param name="ordPk"></param>
- /// <param name="flag"></param>
- private void updateGridOrdFile(string ordPk, string flag)
- {
- UltraGridRow[] row = gdOrderInfo.Rows.AsQueryable().Where(a => a.Cells["ORDPK"].Value.ToString() == ordPk).ToArray();
- if (flag == "1")
- {
- for (int i = 0; i < row.Length; i++)
- {
- row[i].Cells["ORDERFILE"].Value = "有合同文本";
- }
- }
- else if (flag == "2")
- {
- for (int i = 0; i < row.Length; i++)
- {
- row[i].Cells["ORDERFILE"].Value = "无合同文本";
- }
- }
- }
- /// <summary>
- /// 更新界面合同文本字段
- /// </summary>
- /// <param name="ordPk"></param>
- /// <param name="flag"></param>
- private void updateGridUserOrdFile(string ordPk, string flag)
- {
- UltraGridRow[] row = gdOrderInfo.Rows.AsQueryable().Where(a => a.Cells["ORDPK"].Value.ToString() == ordPk).ToArray();
- if (flag == "1")
- {
- for (int i = 0; i < row.Length; i++)
- {
- row[i].Cells["USERORDERFILE"].Value = "有合同文本";
- }
- }
- else if (flag == "2")
- {
- for (int i = 0; i < row.Length; i++)
- {
- row[i].Cells["USERORDERFILE"].Value = "无合同文本";
- }
- }
- }
- /// <summary>
- /// 更新系统合同文本字段
- /// </summary>
- /// <param name="ordPk"></param>
- /// <param name="ordFile"></param>
- /// <returns>true 上传成功 false 上传失败</returns>
- private bool updateOrderLineOrdFile(string ordPk, string ordFile)
- {
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderAuthentication.updateOrdFile", new object[] { ordPk, ordFile }, this.ob);
- if (count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 更新系统合同文本字段
- /// </summary>
- /// <param name="ordPk"></param>
- /// <param name="ordFile"></param>
- /// <returns>true 上传成功 false 上传失败</returns>
- private bool updateOrderLineUserOrdFile(string ordPk, string ordFile)
- {
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderAuthentication.updateUserOrdFile", new object[] { ordPk, ordFile }, this.ob);
- if (count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 上传文件 返回文件名称列表
- /// </summary>
- /// <param name="sFileName"></param>
- /// <returns></returns>
- 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 chkArea_CheckedChanged(object sender, EventArgs e)
- {
- txtArea.ReadOnly = !this.chkArea.Checked;
- }
- private void UserordFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (e.Button.Key.Equals("upload")) // 上传
- {
- UltraGridRow row = gdOrderInfo.ActiveRow;
- if (row == null)
- return;
- string ordPk = row.Cells["ORDPK"].Value.ToString();
- string reStr = FlileUpload("USERORDFILE/" + ordPk);
- if (reStr == "F")
- {
- MessageUtil.ShowWarning("上传失败,尝试重新上传!");
- return;
- }
- else if (reStr == "N")
- {
- return;
- }
- //将合同所在的文件名称存入数据库
- if (updateOrderLineUserOrdFile(ordPk, "USERORDFILE/" + ordPk))
- {
- MessageUtil.ShowTips("上传成功!");
- updateGridUserOrdFile(ordPk, "1");
- }
- }
- else if (e.Button.Key.Equals("view")) //预览
- {
- UltraGridRow row = gdOrderInfo.ActiveRow;
- if (row == null)
- return;
- string ordPk = row.Cells["ORDPK"].Value.ToString();
- string filePath = "USERORDFILE/" + ordPk;
- dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePath);
- down.ShowDialog();
- if (down.CtrlFileDown1.List.Count == 0)
- {
- updateOrderLineUserOrdFile(ordPk, "");
- updateGridUserOrdFile(ordPk, "2");
- }
- }
- }
- }
- }
|