| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- 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.Server;
- using Core.Mes.Client.Comm.Control;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Format;
- using System.Collections;
- using Core.Mes.Client.Comm.Tool;
- namespace Core.StlMes.Client.SaleOrder.Dialog
- {
- public partial class frmOrderPriceDetails : FrmBase
- {
- /// <summary>
- /// 合同号
- /// </summary>
- private String ordPk;
- public String OrdPk
- {
- get { return ordPk; }
- set { ordPk = value; }
- }
- private OpeBase ob;
- public OpeBase Ob
- {
- get { return ob; }
- set { ob = value; }
- }
- public frmOrderPriceDetails()
- {
- InitializeComponent();
- }
- private void frmOrderPriceDetails_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<SlmOrderLineEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- setColumnsReadOnly();
- DoQuery();
- }
- private void setColumnsReadOnly()
- {
- foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns)
- {
- if (!ugc.Key.Equals("CHC"))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Save":
- DoSave();
- break;
- case "Cancel":
- DoCancel();
- break;
- case "Commit":
- DoCommit();
- break;
- case "Close":
- this.Close();
- break;
- default:
- break;
- }
- }
- private void DoQuery()
- {
- if (ordPk.Length == 0)
- {
- return;
- }
- List<SlmOrderLineEntity> listSource = EntityHelper.GetData<SlmOrderLineEntity>(
- "com.steering.pss.sale.order.CoreOrderPriceDetails.getOrdLineByOrdPk", new object[] { ordPk }, ob);
- slmOrderLineEntityBindingSource.DataSource = listSource;
- }
- private void DoSave()
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> ultraGrid1CheckedRows = ultraGrid1.Rows.AsQueryable().Where(" CHC = 'True'");
- if (ultraGrid1CheckedRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择合同行");
- return;
- }
- String priceBase = textBox1.Text.Trim();
- if (priceBase.Length == 0)
- {
- MessageUtil.ShowWarning("请填写定价内容");
- return;
- }
- String jsPrice = txtJsPrice.Value == null ? "" : txtJsPrice.Value.ToString().Trim();
- String ccPrice = txtCcPrice.Value == null ? "" : txtCcPrice.Value.ToString().Trim();
- String dzPrice = txtDzfPrice.Value == null ? "" : txtDzfPrice.Value.ToString().Trim();
- String yfPrice = txtYfPrice.Value == null ? "" : txtYfPrice.Value.ToString().Trim();
- if (jsPrice.Equals("") || ccPrice.Equals(""))
- {
- MessageUtil.ShowWarning("请填写出厂价/结算价");
- return;
- }
- //合同头状态
- if (MessageUtil.ShowYesNoAndQuestion("是否保存定价信息") == DialogResult.No)
- {
- return;
- }
- String[] statuses = getOrderHeadStatus(ordPk);
- if (statuses == null)
- {
- MessageUtil.ShowWarning("合同状态异常,不能维护定价");
- return;
- }
- String status = statuses[0];
- ArrayList list = new ArrayList() { "12020212", "12020213", "12020221", "12020223", "12020231", "12020241" };
- if (list.Contains(status))
- {
- ArrayList listStr = new ArrayList();
- String ordLnPk = "";
- foreach (UltraGridRow ugr in ultraGrid1CheckedRows)
- {
- SlmOrderLineEntity orderLineEntity = (SlmOrderLineEntity)ugr.ListObject;
- orderLineEntity.TrsPrice = yfPrice;
- orderLineEntity.BlaPrice = jsPrice;
- orderLineEntity.OutPrice = ccPrice;
- orderLineEntity.PakPrice = dzPrice;
- ordLnPk = orderLineEntity.OrdLnPk.ToString();
- orderLineEntity.OrderAddDesc = "";
- orderLineEntity.OrderSpecialDesc = "";
- string strJSON = JSONFormat.Format(orderLineEntity);
- listStr.Add(strJSON);
- }
- string saleOrg = ClsBaseInfo.GetSaleOrg(UserInfo.GetDeptid());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderPriceDetails";
- ccp.MethodName = "savePrice";
- ccp.ServerParams = new object[] { listStr, ordPk, priceBase, UserInfo.GetUserName(), saleOrg };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1)
- {
- return;
- }
- MessageUtil.ShowTips("保存成功!");
- DoQuery();
- activeRow(ultraGrid1, ordLnPk);
- }
- else
- {
- MessageUtil.ShowWarning("合同已审批,不能定价维护");
- return;
- }
- }
- private void DoCancel()
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> ultraGrid1CheckedRows = ultraGrid1.Rows.AsQueryable().Where(" CHC = 'True'");
- if (MessageUtil.ShowYesNoAndQuestion("是否撤销对此合同定价维护!") == DialogResult.No)
- {
- return;
- }
- String[] statuses = getOrderHeadStatus(ordPk);
- if (statuses == null)
- {
- MessageUtil.ShowWarning("合同状态异常,不能撤销合同定价");
- return;
- }
- String status = statuses[0];
- {
- if (status.Equals("12020220"))
- {
- MessageUtil.ShowWarning("合同已经审批,不能撤销合同定价");
- return;
- }
- }
- ArrayList listStr = new ArrayList();
- String ordLnPk = "";
- foreach (UltraGridRow ugr in ultraGrid1CheckedRows)
- {
- SlmOrderLineEntity orderLineEntity = (SlmOrderLineEntity)ugr.ListObject;
- orderLineEntity.TrsPrice = txtYfPrice.Value.ToString().Trim();
- orderLineEntity.BlaPrice = txtJsPrice.Value.ToString().Trim();
- orderLineEntity.OutPrice = txtCcPrice.Value.ToString().Trim();
- orderLineEntity.PakPrice = txtDzfPrice.Value.ToString().Trim();
- ordLnPk = orderLineEntity.OrdLnPk.ToString();
- orderLineEntity.OrderAddDesc = "";
- orderLineEntity.OrderSpecialDesc = "";
- string strJSON = JSONFormat.Format(orderLineEntity);
- listStr.Add(strJSON);
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderPriceDetails";
- ccp.MethodName = "cancelPriceNo";
- ccp.ServerParams = new object[] { listStr, ordPk };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1)
- {
- return;
- }
- MessageUtil.ShowTips("撤销成功!");
- DoQuery();
- activeRow(ultraGrid1, ordLnPk);
- }
- private void DoCommit()
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否提交") == DialogResult.No)
- {
- return;
- }
- if (!checkPriceComplete(ordPk))
- {
- MessageUtil.ShowWarning("定价信息没有维护完整,不能提交");
- return;
- }
- this.Close();
- }
- /// <summary>
- /// 查询合同头状态/定价编号 2015/06/18
- /// </summary>
- /// <param name="ordPk">合同头号</param>
- /// <returns></returns>
- private String[] getOrderHeadStatus(String ordPk)
- {
- String[] status = null;
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CopyOrderApproval.getOrdPkStatus", new Object[] { ordPk }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- status = new String[2];
- status[0] = dt.Rows[0][0].ToString();
- status[1] = dt.Rows[0][1].ToString();
- }
- return status;
- }
- /// <summary>
- /// 查询定价内容
- /// </summary>
- /// <param name="priceNo"></param>
- /// <returns></returns>
- private String getPriceBase()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderPriceDetails.getPriceBase", new Object[] { ordPk }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- return dt.Rows[0][0].ToString();
- }
- else
- {
- return "";
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr != null)
- {
- String priceBase = getPriceBase();
- textBox1.Text = priceBase;
- txtYfPrice.Value = ugr.Cells["TrsPrice"].Value;
- txtJsPrice.Value = ugr.Cells["BlaPrice"].Value;
- txtCcPrice.Value = ugr.Cells["OutPrice"].Value;
- txtDzfPrice.Value = ugr.Cells["PakPrice"].Value;
- }
- }
- private void frmOrderPriceDetails_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (!checkPriceComplete(ordPk))
- {
- if (MessageUtil.ShowYesNoAndQuestion("合同定价维护不完整,是否退出") == DialogResult.No)
- {
- e.Cancel = true;
- }
- }
- }
- /// <summary>
- /// 验证合同头是否存在订价编号
- /// </summary>
- /// <param name="ordPk"></param>
- /// <returns></returns>
- private Boolean checkPriceComplete(String ordPk)
- {
- if (ordPk.Length == 0)
- {
- return false;
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderPriceDetails.getOrdHeadPriceNo", new Object[] { ordPk }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- String str = dt.Rows[0][0].ToString();
- if (str.Length > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- private void activeRow(UltraGrid ug, String value)
- {
- foreach (UltraGridRow ugr in ug.Rows)
- {
- if (ugr.Cells["OrdLnPk"].Value.ToString().Equals(value))
- {
- ugr.Activate();
- }
- }
- }
- }
- }
|