| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Core.Mes.Client.Comm;
- using Core.Mes.Client.Comm.Server;
- using System.Collections;
- using Core.Mes.Client.Comm.Control;
- using System.Diagnostics;
- using System.IO;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Tool;
- using com.steering.pss.plnsaleord.order.model;
- namespace Core.StlMes.Client.PlnSaleOrd
- {
- public partial class FrmReqApplyInfo : FrmBase
- {
- public FrmReqApplyInfo()
- {
- this.IsLoadUserView = true;
- InitializeComponent();
- }
- public FrmReqApplyInfo(OpeBase openBase)
- {
- this.ob = ob;
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query":
- DoQuery();
- break;
- case "Confirm":
- DoConfirm();
- break;
- case "CancelConfirm":
- CancelConFirm();
- break;
- case "Export":
- DoExport();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void FrmReqApplyInfo_Load(object sender, EventArgs e)
- {
- this.ultraDateTimeApplyDateFrom.Value = DateTime.Now;
- this.ultraDateTimeApplyDateTo.Value = DateTime.Now;
- PlanComm.setGridActivation(this.ultraGridReqOrd.DisplayLayout.Bands[0], "CHC", "CONFIRM_WT");
- PlanComm.setGridDigitalCol(ultraGridReqOrd.DisplayLayout.Bands[0], 7, 3, "REP_QTY", "REQWEIGHT", "CONFIRM_WT");
- DoQuery();
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- try
- {
- ArrayList param = new ArrayList();
- string strOrderNo = ""; //合同号
- string strDateForm = "1000/01/01"; //交货结束日期从,默认最小日期
- string strDateTo = "9999/12/31"; //交货结束日期到,默认最大日期
- string strChecked = "";
- if (this.checkBoxOrderNo.Checked)
- {
- //合同号
- strOrderNo = this.ultraTextOrderNo.Text.Trim();
- }
- if (this.checkBoxApplyDate.Checked)
- {
- //申请日期
- strDateForm = this.ultraDateTimeApplyDateFrom.DateTime.ToString("yyyy/MM/dd");
- strDateTo = this.ultraDateTimeApplyDateTo.DateTime.ToString("yyyy/MM/dd");
- }
- if (checkBoxInCuldeAll.Checked)
- {
- strChecked = "1";
- }
- param.Add(strOrderNo);
- param.Add(strDateForm);
- param.Add(strDateTo);
- param.Add(strChecked);
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreReqRequest.getReqOrder",
- new object[] { param }, this.ob);
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- }
- catch (Exception ex)
- {
- if (ex is MESException)
- {
- }
- else
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- /// <summary>
- /// 确认补量申请
- /// </summary>
- private void DoConfirm()
- {
- try
- {
- ArrayList list = new ArrayList();
- ultraGridReqOrd.UpdateData();
- IQueryable<UltraGridRow> checkRows = ultraGridReqOrd.Rows.AsQueryable().Where("CHC = 'True'");
- if (checkRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何行!");
- return;
- }
- foreach (UltraGridRow uRow in checkRows)
- {
- double confirmWt = 0;
- PlnSaleorderRNumEntity rNumEntity = new PlnSaleorderRNumEntity();
- rNumEntity.PlanDealName = UserInfo.GetUserName();
- rNumEntity.RepQty = uRow.Cells["REP_QTY"].Value.ToString();
- rNumEntity.RNumId = uRow.Cells["R_NUM_ID"].Value.ToString();
- rNumEntity.Reqweight = uRow.Cells["REQWEIGHT"].Value.ToString();
- double.TryParse(uRow.Cells["CONFIRM_WT"].Value.ToString(), out confirmWt);
- rNumEntity.ConfirmWt = confirmWt.ToString();
- list.Add(rNumEntity);
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreReqRequest";
- ccp.MethodName = "setConfirm";
- ccp.ServerParams = new object[] { list };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips("确认成功!");
- }
- else
- {
- MessageUtil.ShowError("确认失败!" + ccp.ReturnInfo);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- DoQuery();
- }
- /// <summary>
- /// 取消确认
- /// </summary>
- private void CancelConFirm()
- {
- ArrayList list = new ArrayList();
- ultraGridReqOrd.UpdateData();
- IQueryable<UltraGridRow> checkRows = ultraGridReqOrd.Rows.AsQueryable().Where("CHC = 'True'");
- if (checkRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何行!");
- return;
- }
- foreach (UltraGridRow uRow in checkRows)
- {
- list.Add(uRow.Cells["R_NUM_ID"].Value.ToString());
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreReqRequest";
- ccp.MethodName = "canCelConfirm";
- ccp.ServerParams = new object[] { list };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp == null)
- {
- MessageUtil.ShowError("服务端处理失败!");
- return;
- }
- if (ccp.ReturnCode < 0)
- {
- MessageUtil.ShowError("操作失败!\n" + ccp.ReturnInfo);
- return;
- }
- if (ccp.ReturnObject != null)
- {
- MessageUtil.ShowTips(ccp.ReturnObject.ToString());
- DoQuery();
- }
- }
- /// <summary>
- /// 导出
- /// </summary>
- private void DoExport()
- {
- try
- {
- int rowCount = this.ultraGridReqOrd.Rows.Count;
- int colCount = this.ultraGridReqOrd.DisplayLayout.Bands[0].Columns.Count - 10;
- object[,] arr = new object[rowCount, colCount];
- for (int j = 0; j < rowCount; j++)
- {
- for (int i = 0; i < colCount; i++)
- {
- string output = ultraGridReqOrd.Rows[j].Cells[i].Value.ToString();
- if (ultraGridReqOrd.DisplayLayout.Bands[0].Columns[i].Key.Equals("GROUP_ROLL"))
- {
- //产线
- int plineCode = 0;
- output = output.Replace("机组", "");
- if (int.TryParse(output, out plineCode))
- {
- output = "'" + plineCode.ToString();
- }
- }
- if (ultraGridReqOrd.DisplayLayout.Bands[0].Columns[i].Key.Equals("STEELNAME"))
- {
- //钢级
- double grade = 0;
- if (double.TryParse(output, out grade))
- {
- output = "'" + output;
- }
- }
- if (ultraGridReqOrd.DisplayLayout.Bands[0].Columns[i].Key.Equals("ROLL_MONTH"))
- {
- //轧制月份
- DateTime dt = new DateTime();
- if (DateTime.TryParse(output, out dt))
- {
- output = "'" + dt.ToString("yyyyMM");
- }
- }
- arr[j, i] = output;
- }
- }
- string path = System.Windows.Forms.Application.StartupPath + "\\model";
- string tempExcel = path + "\\FrmSaleOrdmodel.xls";
- string outPutExcl = "补量合同" + DateTime.Now.ToString("yyyyMMdd");
- if (!System.IO.File.Exists(tempExcel))//检察模板是否存在
- {
- MessageBox.Show(this, "未找到报表模板!");
- return;
- }
- if (ultraGridReqOrd.Rows.Count == 0) return;
- if (outPutExcl.Length == 0) outPutExcl = "未命名";
- SaveFileDialog dlg = new SaveFileDialog();
- dlg.Title = "保存";
- dlg.OverwritePrompt = true;
- dlg.Filter = "Excel文件(*.xls)|*.xls";
- dlg.AddExtension = true;
- dlg.FileName = outPutExcl;
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- outPutExcl = dlg.FileName;
- WaitFromOpen();
- ExcelHelper excelport = new ExcelHelper(tempExcel, outPutExcl);
- if (excelport.ArrayToExcel(arr, 2, 1, "Sheet"))
- {
- WaitFromColse();
- if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- ProcessStartInfo p = new ProcessStartInfo(outPutExcl);
- p.WorkingDirectory = Path.GetDirectoryName(outPutExcl);
- Process.Start(p);
- }
- }
- else
- {
- WaitFromColse();
- MessageBox.Show("数据导出失败!");
- return;
- }
- }
- }
- catch (Exception ex)
- {
- WaitFromColse();
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 等待窗口
- /// </summary>
- private void WaitFromOpen()
- {
- this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
- if (Constant.WaitingForm == null)
- {
- Constant.WaitingForm = new WaitingForm();
- }
- Constant.WaitingForm.ShowToUser = true;
- Constant.WaitingForm.Show();
- Constant.WaitingForm.Update();
- }
- /// <summary>
- /// 关闭等待
- /// </summary>
- private void WaitFromColse()
- {
- this.Cursor = Cursors.Default;
- Constant.WaitingForm.ShowToUser = false;
- Constant.WaitingForm.Close();
- Constant.WaitingForm = null;
- }
- private void checkBoxApplyDate_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBoxApplyDate.Checked)
- {
- this.ultraDateTimeApplyDateFrom.Enabled = true;
- this.ultraDateTimeApplyDateTo.Enabled = true;
- }
- else
- {
- this.ultraDateTimeApplyDateFrom.Enabled = false;
- this.ultraDateTimeApplyDateTo.Enabled = false;
- }
- }
- private void checkBoxOrderNo_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBoxOrderNo.Checked)
- {
- this.ultraTextOrderNo.Enabled = true;
- }
- else
- {
- this.ultraTextOrderNo.Enabled = false;
- }
- }
- private void ultraDateTimeApplyDateFrom_ValueChanged(object sender, EventArgs e)
- {
- ultraDateTimeApplyDateTo.MinDate = ultraDateTimeApplyDateFrom.DateTime.Date;
- }
- private void ultraDateTimeApplyDateTo_ValueChanged(object sender, EventArgs e)
- {
- ultraDateTimeApplyDateFrom.MaxDate = ultraDateTimeApplyDateTo.DateTime.AddDays(1).Date.AddSeconds(-1);
- }
- private void ultraGridReqOrd_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ultraGridReqOrd.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHC"].Value = true;
- }
- }
- }
- }
- }
|