| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- 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 Pur.Entity;
- using Core.Mes.Client.Comm.Control;
- using Pur.Entity.ck;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Server;
- using Pur.PublicTools;
- namespace Pur.ck
- {
- public partial class ExcDeliveryHandle : FrmPmsBase
- {
- public ExcDeliveryHandle()
- {
- InitializeComponent();
- }
- private void ExcDeliveryHandle_Load(object sender, EventArgs e)
- {
- ck_Ctime.Checked = true;
- txt_CreateTimeS.Value = DateTime.Now.AddMonths(-1);
- txt_CreateTimeS.Enabled = true;
- txt_CreateTimeE.Value = Convert.ToDateTime(DateTime.Now.ToShortDateString()).AddHours(23).AddMinutes(59);
- txt_CreateTimeE.Enabled = true;
- txt_status.SelectedIndex = 1;//默认待处置状态
- GridHelper.SetExcludeColumnsActive(GridSubM.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(GridHandledSubM.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(GridReturnedSubM.DisplayLayout.Bands[0], new string[] { });
- PublicPur.InitCellEdit(new UltraGrid[] { GridHandle }, new string[] { "CHK","remark2","AGAINQTY", "RETURNEDQTY", "HANDLEDQTY" });
- PublicPur.InitCellPositionRight(new UltraGrid[] { GridHandle }, new string[] { "AGAINQTY", "RETURNEDQTY", "HANDLEDQTY" });
- PublicPur.InitColumnShowLength(new UltraGrid[] { GridHandle }, 0, new string[] { "AGAINQTY", "RETURNEDQTY", "HANDLEDQTY" }, 3, false);
- Get_ExcSubM();
- }
- #region toolbar工具栏
- /// <summary>
- /// 菜单栏
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- Get_ExcSubM();
- break;
- case "Confirm":
- Con_ExcSubM();
- break;
- case "Cancel":
- cancel_ExcSubM();
- break;
- case "doPrintDelivery":
- doPrintDelivery();
- break;
- case "doPrintReturn":
- doPrintReturn();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void Get_ExcSubM()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- subM.Clear();
- handledSubM.Clear();
- returnSubM.Clear();
- Hashtable map = new Hashtable();
- map.Add("deliverySubId", txt_deliverySubId.Text.Trim());
- map.Add("orderId", txt_OrderId.Text.Trim());
- map.Add("suppName", txt_suppName.Text.Trim());
- map.Add("invPhysicName", QInphysicNoJL.Text.Trim());
- map.Add("deliveryLocation", QLocationNoJL.Text.Trim());
- if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeS.Text))
- {
- map.Add("createTimeBegin", Convert.ToDateTime(txt_CreateTimeS.Value));
- }
- if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeE.Text))
- {
- map.Add("createTimeEnd", Convert.ToDateTime(txt_CreateTimeE.Value));
- }
- if (txt_status.SelectedIndex != -1)
- {
- map.Add("statusHandle", txt_status.Value.ToString().Trim());//all:全部 wait:待处理 did:已处理
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
- GridHelper.CopyDataToDatatable(dt, DTSubM, true);
- GridHelper.RefreshAndAutoSize(GridSubM);
- }
- catch(Exception ex)
- {
- MessageUtil.ShowTips("查询送货单主表数据失败:"+ex.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 处理结果提交
- /// </summary>
- private void Con_ExcSubM()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- List<ExcDeliveryException> list = new List<ExcDeliveryException>();
- //校验数据
- GridHandle.UpdateData();
- foreach (UltraGridRow row in GridHandle.Rows)
- {
- if (Convert.ToBoolean(row.GetCellValue("CHK")))
- {
- ///"AGAINQTY", "RETURNEDQTY", "HANDLEDQTY"
- String strSubSqe = row.GetCellValue("deliverySubLineSqe").ToString().Trim();
- String strId = row.GetCellValue("id").ToString().Trim();
- //校验异常单
- if (!testExceptionC(strId, 1))
- {
- return;
- }
- double dbAGAINQTY = 0;//补货量
- double dbRETURNEDQTY = 0;//退货量
- double dbHANDLEDQTY = 0;//让步量
- double dbAllQty = 0;
- double dbQty = 0;
- Double.TryParse(row.GetCellValue("qty").ToString().Trim(), out dbQty);
- Double.TryParse(row.GetCellValue("AGAINQTY").ToString().Trim(), out dbAGAINQTY);
- Double.TryParse(row.GetCellValue("RETURNEDQTY").ToString().Trim(), out dbRETURNEDQTY);
- Double.TryParse(row.GetCellValue("HANDLEDQTY").ToString().Trim(), out dbHANDLEDQTY);
- dbAGAINQTY =Math.Round(dbAGAINQTY,3);//补货量
- dbRETURNEDQTY =Math.Round(dbRETURNEDQTY,3);//退货量
- dbHANDLEDQTY = Math.Round(dbHANDLEDQTY,3);//让步量
- dbQty = Math.Round(dbQty, 3);//待处置量
- dbAllQty = dbAGAINQTY + dbRETURNEDQTY + dbHANDLEDQTY;
- if (dbAllQty > dbQty)
- {
- MessageUtil.ShowTips("送货单行:" + strSubSqe + "的异常单:" + strId + "的处置量总和不能大于待处置量:" + dbQty);
- row.Activate();
- return;
- }
- if (dbAGAINQTY <= 0 && dbRETURNEDQTY <= 0 && dbHANDLEDQTY <= 0)
- {
- MessageUtil.ShowTips("送货单行:" + strSubSqe + "的异常单:" + strId + "的处置量总需大于0");
- row.Activate();
- return;
- }
- ExcDeliveryException hand = new ExcDeliveryException();
- hand.Id = strId;
- hand.DeliverySubLineSqe = strSubSqe;
- hand.HandledQty = dbHANDLEDQTY;
- hand.ReturnedQty = dbRETURNEDQTY;
- hand.AgainQty = dbAGAINQTY;
- hand.HandleName = UserInfo.GetUserName();
- hand.HandleUserid = UserInfo.GetUserID();
- hand.HandleTime = DateTime.Now;
- hand.Remark = row.GetCellValue("remark2").ToString().Trim();
- hand.DeleteUserid = UserInfo.GetDeptid();
- hand.DeleteName = UserInfo.GetDepartment();
- list.Add(hand);
- }
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("请选择异常单进行处理");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定提交处置包括送货单行:" +list[0].DeliverySubLineSqe+"在内的共"+list.Count+"条异常单处理结果?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "doHandle", new object[] { list });
- if (crt.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功:" + crt.Resultmsg);
- if(GridSubM.ActiveRow!=null)
- {
- String strDeliverySubId = GridSubM.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
- if (!String.IsNullOrEmpty(strDeliverySubId))
- {
- doQuerySubLine(strDeliverySubId);
- }
- }
- }
- else
- {
- //操作失败
- MessageUtil.ShowTips("操作失败:" + crt.Resultmsg);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
-
- }
- /// <summary>
- /// 取消处理
- /// </summary>
- private void cancel_ExcSubM()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- List<ExcDeliveryException> list = new List<ExcDeliveryException>();
- //校验数据
- GridHandle.UpdateData();
- foreach (UltraGridRow row in GridHandle.Rows)
- {
- if (Convert.ToBoolean(row.GetCellValue("CHK")))
- {
- String strId = row.GetCellValue("id").ToString().Trim();
- String strSubSqe = row.GetCellValue("deliverySubLineSqe").ToString().Trim();
- //校验异常单
- if (!testExceptionC(strId, 2))
- {
- return;
- }
- ExcDeliveryException hand = new ExcDeliveryException();
- hand.DeliverySubLineSqe = strSubSqe;
- hand.Id = strId;
- hand.DeleteName = UserInfo.GetUserName();
- hand.DeleteUserid = UserInfo.GetUserID();
- hand.DeleteTime = DateTime.Now;
- list.Add(hand);
- }
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("请选择异常单进行处理");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定撤销处置包括送货单行:" + list[0].DeliverySubLineSqe + "在内的共" + list.Count + "条异常单处理结果?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "docancel_Handle", new object[] { list });
- if (crt.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功:" + crt.Resultmsg);
- if (GridSubM.ActiveRow != null)
- {
- String strDeliverySubId = GridSubM.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
- if (!String.IsNullOrEmpty(strDeliverySubId))
- {
- doQuerySubLine(strDeliverySubId);
- }
- }
- }
- else
- {
- //操作失败
- MessageUtil.ShowTips("操作失败:" + crt.Resultmsg);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 打印检化验委托单
- /// </summary>
- private void doPrintDelivery()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- if (GridHandledSubM.ActiveRow == null && !GridHandledSubM.ActiveRow.HasChild())
- {
- MessageUtil.ShowTips("请选择让步接收送货单行进行操作!");
- return;
- }
- String strDeliverySubId = GridHandledSubM.ActiveRow.GetCellValue("deliverySubId").ToString().Trim();
- if (String.IsNullOrEmpty(strDeliverySubId))
- {
- MessageUtil.ShowTips("送货单号为空");
- }
- string strurl = "";
- DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1223" }, this.ob);
- DataRow[] drArr = dt.Select("validflag='1'");
- if (drArr.Length != 1)
- {
- MessageUtil.ShowTips("基础数据维护错误:报表系统需维护有效的Ip且只能维护一个有效ip!");
- return;
- }
- String TipsEnv = drArr[0]["baseName"].ToString();
- String strUrlPort = "http://172.54.10.42:8080";//报表系统IP
- String[] str = strUrlPort.Split(':');
- String strUrl = str[0] + ":" + str[1];
- if (ob.MainUrl.StartsWith(strUrl))
- {
- //测试环境
- if (TipsEnv == "2")
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepDeliverySubBillDev.cpt&op=view" + "&subId=" + strDeliverySubId;
- }
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepDeliverySubBill.cpt&op=view" + "&subId=" + strDeliverySubId;
- }
- }
- else
- {
- //测试环境
- if (TipsEnv == "2")
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepDeliverySubBillDev.cpt&op=view" + "&subId=" + strDeliverySubId;
- }
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepDeliverySubBill.cpt&op=view" + "&subId=" + strDeliverySubId;
- }
- }
- //if (ob.MainUrl.StartsWith("http://127.0.0.1"))
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurOrderDev.cpt&op=view" + "&cmbOrder=" + orderNo;
- //}
- //else
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurOrder.cpt&op=view" + "&cmbOrder=" + orderNo;
- //}
- FrmRepExcel fBug = new FrmRepExcel(ob, strurl);
- fBug.AutoSize = true;
- fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fBug.WindowState = FormWindowState.Maximized;
- fBug.Text = "TPCO送货单";
- fBug.Show();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 打印退货单
- /// </summary>
- private void doPrintReturn()
- {
- //
- MessageUtil.ShowTips("开发中");
- throw new NotImplementedException();
- }
- #endregion
- #region 界面事件
- private void GridSubM_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- DTHandle.Clear();
- handledSubM.Clear();
- returnSubM.Clear();
- String strDeliverySubId = GridSubM.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
- if (!String.IsNullOrEmpty(strDeliverySubId))
- {
- doQuerySubLine(strDeliverySubId);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载异常单数据异常:"+ex.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void GridHandle_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- handledSubM.Clear();
- returnSubM.Clear();
- String strId = GridHandle.ActiveRow.GetCellValue("id").ToString().Trim();
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("异常单号为空,或请刷新界面重试");
- return;
- }
- ExcDeliveryException hand = this.execute<ExcDeliveryException>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "findById", new object[] { strId });
- if (hand == null)
- {
- MessageUtil.ShowTips("未发现异常单:" + strId + "信息记录,可能已被删除,或请刷新界面重试");
- return;
- }
- if (hand.Validflag != "1")
- {
- MessageUtil.ShowTips("异常单:" + strId + "信息记录可能已被删除,或请刷新界面重试");
- return;
- }
- //加载让步接收单:
- if (!String.IsNullOrEmpty(hand.HandleSubId))
- {
- Hashtable map = new Hashtable();
- map.Add("deliverySubId", hand.HandleSubId);
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
- GridHelper.CopyDataToDatatable(dt, DTHandleSubM, true);
- GridHelper.RefreshAndAutoSize(GridHandledSubM);
- }
- //加载退货单
- if (!String.IsNullOrEmpty(hand.ReturnedSubId))
- {
- ExcDeliveryReturn er = new ExcDeliveryReturn();
- er.ReturnId = hand.ReturnedSubId;
- er.Validflag = "1";
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryReturnService", "doQuery_Return", new object[] { er });
- GridHelper.CopyDataToDatatable(dt2, DTReturnSubM, true);
- GridHelper.RefreshAndAutoSize(GridReturnedSubM);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载处置单据异常:"+ex.Message);
- }
- }
- private void GridReturnedSubM_AfterRowActivate(object sender, EventArgs e)
- {
-
- try
- {
- DTReturnSubD.Clear();
- String strReturnId = GridReturnedSubM.ActiveRow.GetCellValue("RETURNID").ToString();
- if (!String.IsNullOrEmpty(strReturnId))
- {
- ExcDeliveryReturnC erc = new ExcDeliveryReturnC();
- erc.ReturnId = strReturnId;
- erc.Validflag = "1";
- DataTable dt3 = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryReturnCService", "find", new object[] { erc, 0, 0 });
- GridHelper.CopyDataToDatatable(dt3, DTReturnSubD, true);
- GridHelper.RefreshAndAutoSize(GridReturnedSubD);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载退货单行失败:" + ex.Message);
- }
- }
- private void GridHandledSubM_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- DTHandleSubD.Clear();
- UltraGridRow uge = GridHandledSubM.ActiveRow;
- String strDeliverySubId = uge.GetCellValue("deliverySubId").ToString().Trim();
- if (!String.IsNullOrEmpty(strDeliverySubId))
- {
- ExcDeliverySubC EdSc = new ExcDeliverySubC();
- EdSc.DeliverySubId = strDeliverySubId;
- EdSc.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
- GridHelper.CopyDataToDatatable(dt, DTHandleSubD, true);
- GridHelper.RefreshAndAutoSize(GridHandledSubD);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载让步接收单行失败:" + ex.Message);
- }
-
- }
- private void GridHandle_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["status"].Value.ToString().Equals("已作废"))
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- else if (e.Row.Cells["status"].Value.ToString().Equals("已处置"))
- {
- e.Row.Appearance.ForeColor = Color.Gray;
- }
- else
- {
- e.Row.Appearance.ForeColor = Color.Black;
- }
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 查询异常单信息
- /// </summary>
- /// <param name="strDeliverySubId"></param>
- private void doQuerySubLine(String strDeliverySubId)
- {
- if (String.IsNullOrEmpty(strDeliverySubId))
- {
- MessageUtil.ShowTips("送货单号为空");
- }
- ExcDeliveryException hand = new ExcDeliveryException();
- hand.DeliverySubId = strDeliverySubId;
- hand.Validflag = "1";
- if(txt_status.SelectedIndex!=-1)
- {
- //all:全部 wait:待处理 did:已处理
- String strStatus=txt_status.Value.ToString().Trim();
- if(strStatus=="wait")
- {
- hand.Status="1";
- }
- else if(strStatus=="did")
- {
- hand.Status="2";
- }
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "doQuery_Exceptions", new object[] { hand });
- GridHelper.CopyDataToDatatable(dt, DTHandle, true);
- GridHelper.RefreshAndAutoSize(GridHandle);
- }
- /// <summary>
- /// 校验异常单
- /// </summary>
- /// <param name="strDeliverySubLineSqe"></param>
- /// <returns></returns>
- private bool testExceptionC(string strId, int i)
- {
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("异常单号为空,或请刷新界面重试");
- return false;
- }
- ExcDeliveryException hand = this.execute<ExcDeliveryException>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "findById", new object[] { strId });
- if (hand == null)
- {
- MessageUtil.ShowTips("未发现异常单:" + strId + "信息记录,可能已被删除,或请刷新界面重试");
- return false;
- }
- if (hand.Validflag != "1")
- {
- MessageUtil.ShowTips("异常单:" + strId + "信息记录可能已被删除,或请刷新界面重试");
- return false;
- }
- if (i == 1)
- {
- if (hand.Status != "1")
- {
- MessageUtil.ShowTips("异常单:" + strId + "已处置,或请刷新界面重试");
- return false;
- }
- }
- else if (i == 2)
- {
- if (hand.Status != "2")
- {
- MessageUtil.ShowTips("异常单:" + strId + "不在已处置状态,或请刷新界面重试");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("参数异常");
- return false;
- }
- return true;
- }
- #endregion
-
- }
- }
|