| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- 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 System.Collections;
- using Core.Mes.Client.Comm.Tool;
- using Core.Mes.Client.Comm.Server;
- using com.steering.pss.plnsaleord.order.model;
- using Core.StlMes.Client.PlnSaleOrd.PopupWindow;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm;
- using Infragistics.Win.UltraWinEditors;
- using System.Globalization;
- namespace Core.StlMes.Client.PlnSaleOrd
- {
- public partial class FrmMatJgMImport : FrmBase
- {
- public FrmMatJgMImport()
- {
- this.IsLoadUserView = true;
- InitializeComponent();
- EntityHelper.ShowGridCaption<PlnSaleordSetEntity>(ultraGridStatus.DisplayLayout.Bands[0]);
- }
- private void FrmOrderStatusSet_Load(object sender, EventArgs e)
- {
- ultraDateTimeImportTime.DateTime = DateTime.Now;
- ultraDateTimeImportTimeTo.DateTime = DateTime.Now;
- ultraComboOrderStatusSet.SelectedIndex = 0;
- PlanComm.setGridActivation(ultraGridStatus.DisplayLayout.Bands[0], "CHC");
- PlanComm.setGridDigitalCol(ultraGridStatus.DisplayLayout.Bands[0], 5, 0, "NumSetStatus");
- DoQuery();
- }
- /// <summary>
- /// 重写基类toolBar方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- DoQuery();
- break;
- case "Import":
- DoImport();
- break;
- case "Modefiy":
- DoModefiy();
- break;
- case "ModefiyMonth":
- DoModefiyMonth();
- break;
- case "Delete":
- doDelete();
- DoQuery();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- ArrayList param = new ArrayList();
- if (checkBoxForReqORDER_NO.Checked)
- {
- param.Add(this.ctrlForQueryORDER_NO.Value.ToString());
- }
- else
- {
- param.Add("");
- }
- if (checkBoxIsRollMonth.Checked)
- {
- param.Add("0");
- param.Add("0");
- }
- else
- {
- param.Add("");
- param.Add("");
- }
- if (checkBoxIsNot.Checked)
- {
- param.Add("0");
- param.Add("0");
- }
- else
- {
- param.Add("");
- param.Add("");
- }
- param.Add(this.ultraDateTimeImportTime.DateTime.ToString("yyyy-MM-dd"));
- param.Add(this.ultraDateTimeImportTimeTo.DateTime.ToString("yyyy-MM-dd"));
- List<PlnSaleordSetEntity> listSorce = EntityHelper.GetData<PlnSaleordSetEntity>(
- "com.steering.pss.plnsaleord.order.CoreOrderStatusSet.queryOrderSetLog", new object[] { param }, this.ob);
- this.slmbindingSourcePlnSaleordSetEntity.DataSource = listSorce;
- }
- /// <summary>
- /// 导入
- /// </summary>
- private void DoImport()
- {
- try
- {
- OpenFileDialog dialog = new OpenFileDialog();
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- FrmImportSetOrder import = new FrmImportSetOrder(this.ob);
- import.ModelPatch = dialog.FileName;
- import.ShowDialog();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- DoQuery();
- }
- /// <summary>
- /// 同步状态
- /// </summary>
- private void DoModefiy()
- {
- try
- {
- ultraGridStatus.UpdateData();
- ArrayList list = new ArrayList();
- IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
- if (checkedRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何行!");
- return;
- }
- WaitFromOpen();
- foreach (UltraGridRow uRow in checkedRows)
- {
- PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
- entity.UpdateMan = UserInfo.GetUserName();
- entity.EndStatus = ultraComboOrderStatusSet.Value.ToString();
- entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
- entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
- list.Add(entity);
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet";
- ccp.MethodName = "updateOrderStatus";
- ccp.ServerParams = new object[] { list };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- WaitFromColse();
- if (ccp.ReturnCode != -1)
- {
- if (MessageUtil.ShowYesNoAndQuestion(ccp.ReturnInfo + "\n是否删除同步记录?") == DialogResult.Yes)
- {
- doDelete();
- }
- }
- else
- {
- MessageUtil.ShowTips("同步失败!\n" + ccp.ReturnInfo);
- }
- }
- catch (Exception ex)
- {
- WaitFromColse();
- if (!(ex is MESException))
- {
- MessageBox.Show(ex.Message);
- }
- }
- DoQuery();
- }
- /// <summary>
- /// 同步月份
- /// </summary>
- private void DoModefiyMonth()
- {
- try
- {
- int defailNum = 0;
- ultraGridStatus.UpdateData();
- string messageErr = "";
- ArrayList list = new ArrayList();
- IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
- if (checkedRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何行!");
- return;
- }
- WaitFromOpen();
- foreach (UltraGridRow uRow in checkedRows)
- {
- PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
- DateTime date = new DateTime();
- if (DateTime.TryParseExact(uRow.Cells["RollMonth"].Value.ToString(),
- "yyyy-MM", null, DateTimeStyles.None, out date))
- {
- entity.RollMonth = date.ToString("yyyy-MM");
- }
- else
- {
- messageErr = "月份格式有误!";
- defailNum++;
- continue;
- }
- entity.IfSetMonth = "1";
- entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
- entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
- list.Add(entity);
- }
- if (list.Count <= 0)
- {
- WaitFromColse();
- MessageUtil.ShowTips("0条同步成功," + defailNum + "条同步失败。" + messageErr);
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet";
- ccp.MethodName = "updateOrderStatusMonth";
- ccp.ServerParams = new object[] { list };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- WaitFromColse();
- if (ccp.ReturnCode != -1)
- {
- if (MessageUtil.ShowYesNoAndQuestion(list.Count + "条同步成功," + defailNum + "条同步失败。\n"
- + messageErr + "\n是否删除同步记录?") == DialogResult.Yes)
- {
- doDelete();
- }
- }
- else
- {
- MessageUtil.ShowTips("同步失败!");
- }
- }
- catch (Exception ex)
- {
- WaitFromColse();
- if (!(ex is MESException))
- {
- MessageBox.Show(ex.Message);
- }
- }
- DoQuery();
- }
- /// <summary>
- /// 同步生产分类
- /// </summary>
- //private void DoModefiyProSort()
- //{
- // try
- // {
- // ultraGridStatus.UpdateData();
- // ArrayList list = new ArrayList();
- // IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
- // if (checkedRows.Count() == 0)
- // {
- // MessageUtil.ShowTips("未勾选任何行!");
- // return;
- // }
- // WaitFromOpen();
- // foreach (UltraGridRow uRow in checkedRows)
- // {
- // PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
- // entity.ProduceSort = uRow.Cells["ProduceSort"].Value.ToString();
- // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
- // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
- // list.Add(entity);
- // }
- // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateProSort",
- // new object[] { list }, this.ob);
- // WaitFromColse();
- // if (succed > 0)
- // {
- // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
- // {
- // doDelete();
- // }
- // }
- // else
- // {
- // MessageUtil.ShowTips("同步失败!");
- // }
- // }
- // catch (Exception ex)
- // {
- // WaitFromColse();
- // if (ex is MESException)
- // {
- // }
- // else
- // {
- // MessageBox.Show(ex.Message);
- // }
- // }
- // DoQuery();
- //}
- /// <summary>
- /// 同步来源
- /// </summary>
- //private void DoModefiyOrderFrom()
- //{
- // try
- // {
- // ultraGridStatus.UpdateData();
- // ArrayList list = new ArrayList();
- // IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
- // if (checkedRows.Count() == 0)
- // {
- // MessageUtil.ShowTips("未勾选任何行!");
- // return;
- // }
- // WaitFromOpen();
- // foreach (UltraGridRow uRow in checkedRows)
- // {
- // PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
- // entity.Orderfrom = uRow.Cells["Orderfrom"].Value.ToString();
- // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
- // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
- // list.Add(entity);
- // }
- // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateOrderfrom",
- // new object[] { list }, this.ob);
- // WaitFromColse();
- // if (succed > 0)
- // {
- // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
- // {
- // doDelete();
- // }
- // }
- // else
- // {
- // MessageUtil.ShowTips("同步失败!");
- // }
- // }
- // catch (Exception ex)
- // {
- // WaitFromColse();
- // if (ex is MESException)
- // {
- // }
- // else
- // {
- // MessageBox.Show(ex.Message);
- // }
- // }
- // DoQuery();
- //}
- /// <summary>
- /// 删除
- /// </summary>
- private void doDelete()
- {
- try
- {
- ultraGridStatus.UpdateData();
- ArrayList list = new ArrayList();
- IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
- if (checkedRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何行!");
- return;
- }
- WaitFromOpen();
- foreach (UltraGridRow uRow in checkedRows)
- {
- PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
- entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
- entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
- list.Add(entity);
- }
- int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.deleteOrderStatus",
- new object[] { list }, this.ob);
- WaitFromColse();
- if (succed > 0)
- {
- MessageUtil.ShowTips("删除成功!");
- }
- else
- {
- MessageUtil.ShowTips("删除失败!");
- }
- }
- catch (Exception ex)
- {
- WaitFromColse();
- if (!(ex is MESException))
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- private void checkBoxForReqORDER_NO_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBoxForReqORDER_NO.Checked)
- {
- ctrlForQueryORDER_NO.Enabled = true;
- }
- else
- {
- ctrlForQueryORDER_NO.Enabled = false;
- }
- }
- private void ultraDateTimeImportTime_ValueChanged(object sender, EventArgs e)
- {
- ultraDateTimeImportTimeTo.MinDate = ultraDateTimeImportTime.DateTime.Date;
- }
- private void ultraDateTimeImportTimeTo_ValueChanged(object sender, EventArgs e)
- {
- ultraDateTimeImportTime.MaxDate = ultraDateTimeImportTimeTo.DateTime.AddDays(1).Date.AddSeconds(-1);
- }
- private void ultraGridStatus_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ultraGridStatus.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHC"].Value = true;
- }
- }
- }
- /// <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;
- }
- }
- }
|