| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338 |
- 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 Core.Mes.Client.Comm;
- using Pur.Entity.configureEntity;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using Pur.Entity.pur_orderEntiy;
- using Pur.configure;
- using Pur.Pop_upWindow;
- using Pur.require_plan;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Infragistics.Win.UltraWinEditors;
- using Pur.balance;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win;
- using CoreFS.SA06;
- using Bpm;
- namespace Pur.order
- {
- public partial class FrmOrderM : FrmPmsBase
- {
- // 合同头区域使用变量
- string init_OrderTitleCode = "";//合同头编码
- string init_Supp_Code = "";//供应商编码
- string init_Mode_Id = "";//合同模板
- // 交货行区域使用变量
- string init_MaxOrderCDQty = "0";//合同行最大可编制量
- string init_OrderCDUom = "";//单位
- // 合同行区域使用变量
- string init_itemUomId = "";//物料单位换算ID
- string init_itemStandardsId = "";//采购标准ID
- string init_itemAttrId = "";//物料属性编码
- string init_itemUnique = "";//物料唯一码
- string init_deliveryLocationCode = "";//地点编码
- //构造函数
- public FrmOrderM()
- {
- InitializeComponent();
- }
- //load
- private void FrmOrderM_Load(object sender, EventArgs e)//load
- {
- //初始化
- Init();
- }
- #region toolbar工具栏
- /// <summary>
- /// toolbar菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)// toolbar菜单
- {
- switch (ToolbarKey)
- {
- case "Query":
- GetPUR_ORDER_M();
- break;
- case "Add":
- AddPUR_ORDER_M();
- break;
- case "Update":
- UpdPUR_ORDER_M();
- break;
- case "Delete":
- DelPUR_ORDER_M();
- break;
- case "Submittal":
- SubPUR_ORDER_M();
- break;
- case "Revocation":
- RevPUR_ORDER_M();
- break;
- case "getBalance":
- getBalance();
- break;
- case "getReport":
- getReportHT("0");
- break;
- case "getReportNoSign":
- getReportHT("1");
- break;
- case "getReportJY":
- getReportJY();
- break;
- case "Process":
- Process();
- break;
- case "FinishedAuditOutline":
- FinishedAuditOutline();
- break;
- }
- }
- private void FinishedAuditOutline()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- OrderM Odm = new OrderM();
- Odm.OrderId = strOrderId;
- Odm.OperatorUserId = UserInfo.GetUserID();
- if (MessageBox.Show("确认该合同[" + strOrderId + "]线下已经完成审批?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "finishedAuditOutline", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败:" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", strOrderId);
- }
- #endregion
- #region toolbar事件
- /// <summary>
- /// 生成结算单
- /// </summary>
- private void getBalance()// 生成结算单
- {
- ultraGrid1.UpdateData();
- string strSuppCode = "";
- string strSuppName="";
- int sumSuppCode = 0;
- ArrayList al = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if ((Boolean)ultraGrid1.Rows[i].Cells["Check"].Value)
- {
- sumSuppCode++;
- if (sumSuppCode > 1)
- {
- if (strSuppCode != ultraGrid1.Rows[i].Cells["SUPPCODE"].Value.ToString())
- {
- MessageUtil.ShowTips("选择的合同不为同一个供应商,请重新选择");
- return;
- }
- }
- al.Add(ultraGrid1.Rows[i].Cells["OrderId"].Value.ToString());
- strSuppCode = ultraGrid1.Rows[i].Cells["SUPPCODE"].Value.ToString();
- strSuppName=ultraGrid1.Rows[i].Cells["SUPPNAME"].Value.ToString();
- }
- }
- if (sumSuppCode == 0)
- {
- MessageUtil.ShowTips("请选择合同");
- return;
- }
- frmConfirmBalance frm = new frmConfirmBalance(this.ob, al, strSuppName, strSuppCode);
- frm.ShowDialog();
- }
- /// <summary>
- /// 撤销提报
- /// </summary>
- private void RevPUR_ORDER_M()// 撤销提报
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strOrderId))
- {
- MessageUtil.ShowTips("该合同头编号为空!");
- return;
- }
- //验证合同头是否可以撤销提报
- if (testOrderMStatus(strOrderId, 4) == false)
- {
- return;
- }
- OrderM Odm = new OrderM();
- Odm.OrderId = strOrderId;
- Odm.Status = "1";
- Odm.OperatorUserId = UserInfo.GetUserID();
- if (MessageBox.Show("确定撤销提报合同【" + uge.Cells["OrderId"].Value.ToString() + "】?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "Submittal_OrderM", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("撤销提报失败:" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", strOrderId);
- }
- /// <summary>
- /// 提报
- /// </summary>
- private void SubPUR_ORDER_M()// 提报
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strOrderId))
- {
- MessageUtil.ShowTips("该合同头编号为空!");
- return;
- }
- //验证合同头是否可以提报
- if (testOrderMStatus(strOrderId,3) == false)
- {
- return;
- }
- OrderM Odm = new OrderM();
- Odm.OrderId = strOrderId;
- Odm.Status = "2";
- Odm.OperatorUserId = UserInfo.GetUserID();
- if (MessageBox.Show("确定提报合同【" + strOrderId + "】?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "Submittal_OrderM", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("提交失败:" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("提交成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", strOrderId);
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void DelPUR_ORDER_M()// 删除
- {
- try
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strOrderId))
- {
- MessageUtil.ShowTips("该合同头编号为空!");
- return;
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[0].Text || ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[3].Text)
- {
- //验证合同头是否可以增删改
- if (testOrderMStatus(strOrderId, 2) == false)
- {
- return;
- }
- OrderM Odm = new OrderM();
- Odm.Validflag = "0";
- Odm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- Odm.DeleteUserid = CoreUserInfo.UserInfo.GetUserID();
- Odm.DeleteTime = DateTime.Now;
- Odm.OrderId = strOrderId;
- if (MessageBox.Show("确定删除合同[" + uge.Cells["OrderId"].Value.ToString() + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "cancelOrderM", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- GetPUR_ORDER_M();
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)
- {
- UltraGridRow uRe = ultraGrid2.ActiveRow;
- if (uRe == null)
- {
- MessageUtil.ShowTips("请选择需要操作的合同行!");
- return;
- }
- String strOrderLineSqe = uRe.Cells["OrderLineSqe"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strOrderLineSqe))
- {
- MessageUtil.ShowTips("数据异常,该合同行无合同行号!");
- return;
- }
- if (testOrderCStatus(strOrderLineSqe, 1) == false)
- {
- return;
- }
- OrderC odC = new OrderC();
- odC.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- odC.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- odC.DeleteTime = DateTime.Now;
- odC.Validflag = "0";
- odC.OrderLineSqe = strOrderLineSqe;
- //this.execute("com.hnshituo.pur.order.service.OrderCService", "update", new object[] { odC });
- // OrderM Omg = new OrderM();
- // Omg.OrderId = uge.Cells["OrderId"].Value.ToString();
- // Omg.WithAmtTax = (uge.Cells["WithAmtTax"].Value == null || String.IsNullOrEmpty(uge.Cells["WithAmtTax"].Value.ToString().Trim()) ? 0 : Convert.ToDouble(uge.Cells["WithAmtTax"].Value.ToString())) - (uRe.Cells["WithAmtTax"].Value == null || String.IsNullOrEmpty(uRe.Cells["WithAmtTax"].Value.ToString().Trim()) ? 0 : Convert.ToDouble(uRe.Cells["WithAmtTax"].Value.ToString()));
- // Omg.WithoutTaxAmt = (uge.Cells["WithoutTaxAmt"].Value == null || String.IsNullOrEmpty(uge.Cells["WithoutTaxAmt"].Value.ToString().Trim()) ? 0 : Convert.ToDouble(uge.Cells["WithoutTaxAmt"].Value.ToString())) - (uRe.Cells["WithoutTaxAmt"].Value == null || String.IsNullOrEmpty(uRe.Cells["WithoutTaxAmt"].Value.ToString().Trim()) ? 0 : Convert.ToDouble(uRe.Cells["WithoutTaxAmt"].Value.ToString()));
- // this.execute("com.hnshituo.pur.order.service.OrderMService", "update", new object[] { Omg });
- //if (ultraGrid4.Rows.Count() > 0)
- //{
- // MessageUtil.ShowTips("该合同行[" + odC.OrderLineSqe + "]已关联交货行,不允许删除");
- // return;
- //}
- if (MessageBox.Show("确定作废合同行[" + odC.OrderLineSqe + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCService", "update_MC", new object[] { odC, uge.Cells["OrderId"].Value.ToString() });
- if (rt.Resultcode != 0)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- GetPUR_ORDER_M();
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "orderId", strOrderId);
- getOrderC(strOrderId, odC.OrderLineSqe);
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[2].Text)
- {
- UltraGridRow ugc = ultraGrid4.ActiveRow;
- if(ugc==null)
- {
- return;
- }
- String strOrderLineDSqe = ugc.GetCellValue("orderLineDSqe").ToString().Trim();
- String strOrderLineSqe = ugc.Cells["orderLineSqe"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strOrderLineDSqe))
- {
- MessageUtil.ShowTips("数据异常,该合同发货行的发货行号为空!");
- return;
- }
- if (testOrderCDStatus(strOrderLineDSqe,1) == false)
- {
- return;
- }
- OrderCD orderCD = new OrderCD();
- orderCD.OrderLineDSqe = strOrderLineDSqe;
- orderCD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- orderCD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- orderCD.DeleteTime = DateTime.Now;
- orderCD.Validflag = "0";
- if (MessageUtil.ShowYesNoAndQuestion("确定删除发货行【" + strOrderLineDSqe + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCDService", "doUpdate", new object[] { orderCD });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("删除成功");
- getOrderC(uge.GetCellValue("orderId").ToString().Trim(), strOrderLineSqe);
- }
- else
- {
- MessageUtil.ShowTips("删除失败:" + re.Resultmsg);
- return;
- }
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowWarning("操作失败! " + e);
- return;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void UpdPUR_ORDER_M()// 修改
- {
- try
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- if(String.IsNullOrEmpty(strOrderId))
- {
- MessageUtil.ShowTips("该合同头编号为空!");
- return;
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[0].Text || ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[3].Text)
- {
- //验证合同头是否可以增删改
- if (testOrderMStatus(strOrderId, 1) == false)
- {
- return;
- }
- //验证合同头输入数据的有效信息
- if (testOrderM() == false)
- {
- return;
- }
- OrderM Odm = new OrderM();
- Odm.BuyerName = txt_BuyerName.Text;
- //Odm.BuyerDeptDesc = txt_BuyerDeptDesc.Text;
- //Odm.BuyerUnitDesc = txt_BuyerUnitDesc.Text;
- Odm.Currency = txt_Currency.Value == null ? "" : txt_Currency.Value.ToString().Trim();
- Odm.OrderType = txt_OrderType.Value.ToString().Trim();//合同类别
- Odm.OrderClass = txt_OrderClass.Value.ToString().Trim();//合同分类
- Odm.ExchangeRateCur = (txt_ExchangeRateCur.Value == null ? 0 : Convert.ToDouble(txt_ExchangeRateCur.Text));
- Odm.OrderId = strOrderId;
- Odm.ModeName = txt_ModeName.Text;
- Odm.ModeId = init_Mode_Id;
- Odm.SuppCode = init_Supp_Code;
- Odm.SuppName = txt_SuppName.Text;
- Odm.OrderMoneyType = txt_OrderMoneyType.Value == null ? null : txt_OrderMoneyType.Value.ToString().Trim();
- Odm.SignDate = Convert.ToDateTime(txt_SignDate.Value);//签订日期
- Odm.OrderTitleCode = init_OrderTitleCode;
- Odm.SignAddress = txt_SignAddress.Text;
- Odm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- Odm.UpdateUserid = CoreUserInfo.UserInfo.GetUserID();
- Odm.UpdateTime = DateTime.Now;
- Odm.TaxRateName = txt_TaxRateName.Value.ToString().Trim();
- Odm.DeliveryCondition = txt_deliveryCondition.Value.ToString().Trim();//运输条件
- Odm.DeliveryType = txt_deliveryType.Value.ToString().ToString().Trim();//运输方式
- if (MessageBox.Show("确定修改合同[" + strOrderId + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "doUpdate", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", strOrderId);
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)
- {
- //验证合同头是否可以删改
- if (testOrderMStatus(strOrderId, 1) == false)
- {
- return;
- }
- if (testOrderC() == false)
- {
- return;
- }
- UltraGridRow uRe = ultraGrid2.ActiveRow;
- OrderC odC = new OrderC();
- odC.OrderId = strOrderId;
- odC.OrderLineSqe = txt_OrderLineSqe.Text.ToString().Trim();
- odC.ItemCode = txt_ItemCode.Text.ToString().Trim();
- odC.ItemAttr = txt_itemAttrName.Text.ToString().Trim();
- odC.ItemAttrId = init_itemAttrId.ToString().Trim();
- odC.PriceWithoutTax = (txt_PriceWithoutTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithoutTax.Value));
- odC.PriceWithTax = (txt_PriceWithTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithTax.Value));
- odC.PriceWithoutTax = (txt_PriceWithoutTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithoutTax.Value));
- odC.WithoutTaxAmt = (txt_WithoutTaxAmt2.Value == null ? 0 : Convert.ToDouble(txt_WithoutTaxAmt2.Value));
- odC.WithAmtTax = (txt_WithAmtTax2.Value == null ? 0 : Convert.ToDouble(txt_WithAmtTax2.Value));
- odC.TaxAmt = (txt_TaxAmt2.Value == null ? 0 : Convert.ToDouble(txt_TaxAmt2.Value));
- odC.Qty = (txt_Qty.Value == null ? 0 : Convert.ToDouble(txt_Qty.Value));
- //odC.BuyerDeptDesc = txt_BuyerDeptDesc.Text;
- odC.ItemName = txt_ItemName.Text;
- //odC.BuyerUnitDesc = txt_BuyerUnitDesc.Text;
- odC.BuyerName = txt_BuyerName2.Text;
- odC.ChemPriceNo = txt_ChemPriceNo.Text;
- //OtherPriceNum = txt_OtherPriceNum.Text;
- odC.ReceiveType = txt_ReceiveType.Value.ToString();
- odC.StartDate = Convert.ToDateTime(txt_StartDate2.Value);//交货开始时间
- odC.EndDate = Convert.ToDateTime(txt_EndDate2.Value);//交货结束时间
- odC.GradePriceNo = txt_GradePriceNo.Text;
- //odC.BasePriceNo = txt_BasePriceNo.Text;
- odC.DeliveryLocationCode = init_deliveryLocationCode;
- odC.QuantityPriceNum = txt_QuantityPriceNum.Text;
- odC.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- odC.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- odC.UpdateTime = DateTime.Now;
- odC.Remark = txt_Remark.Text.ToString().Trim();
- odC.PackageType = txt_packType.Value==null?null:txt_packType.Value.ToString().Trim();//包装方式
- odC.PaymentCode = txt_paymentType.Value == null ? null : txt_paymentType.Value.ToString().Trim();//付款方式
- if (txt_Pur_Clause.Value != null)
- {
- odC.BcmId = txt_Pur_Clause.Value.ToString().Trim();
- }
- else
- {
- odC.BcmId = "";
- }
- odC.PurStandardsCode = txt_purstandardscode.Text;
- odC.ItemUomConefficient = Convert.ToDouble(txt_ItemUomConefficient.Text);
- odC.ItemUom = txt_UNIT.Text;
- odC.WeightUnit = txt_WEIGHTUNIT.Text;
- odC.ItemUseUom = "1";
- odC.CkQty = ultraTextEditor6.Value == null ? 0 : Convert.ToDouble(ultraTextEditor6.Value);
- odC.ItemUnique = init_itemUnique;
- odC.ItemStandardsId = init_itemStandardsId;
- odC.ItemUomId = init_itemUomId;
- odC.ItemAttrId = init_itemAttrId;
- if (MessageBox.Show("确定修改合同行[" + odC.OrderLineSqe + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult rt2 = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCService", "update_MC", new object[] { odC, uge.Cells["OrderId"].Value.ToString() });
- if (rt2.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败!" + rt2.Resultmsg);
- return;
- }
- ////主表合同额跟随从表变化
- //OrderM Omg = new OrderM();
- //Omg.OrderId = uge.Cells["OrderId"].Value.ToString();
- //Omg.WithAmtTax = (uge.Cells["WithAmtTax"].Value == null ? 0 : Convert.ToDouble(uge.Cells["WithAmtTax"].Value.ToString())) - (uRe.Cells["WithAmtTax"].Value == ""? 0 : Convert.ToDouble(uRe.Cells["WithAmtTax"].Value.ToString()))+odC.WithAmtTax;
- //Omg.WithoutTaxAmt = (uge.Cells["WithoutTaxAmt"].Value == null ? 0 : Convert.ToDouble(uge.Cells["WithoutTaxAmt"].Value.ToString())) - (uRe.Cells["WithoutTaxAmt"].Value == "" ? 0 : Convert.ToDouble(uRe.Cells["WithoutTaxAmt"].Value.ToString()))+odC.WithoutTaxAmt;
- //this.execute("com.hnshituo.pur.order.service.OrderMService", "update", new object[] { Omg });
- MessageUtil.ShowTips("修改成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "OrderId", strOrderId);
- getOrderC(strOrderId, odC.OrderLineSqe);
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[2].Text)
- {
- UltraGridRow ugc = ultraGrid4.ActiveRow;
- if (ugc == null)
- {
- MessageUtil.ShowTips("请选择合同发货行!");
- return;
- }
- String strOrderLineDSqe=ugc.GetCellValue("orderLineDSqe").ToString().Trim();
- if(string.IsNullOrEmpty(strOrderLineDSqe))
- {
- MessageUtil.ShowTips("选择的合同发货行编号为空!");
- return;
- }
- //验证是否可以删改
- if (testOrderCDStatus(strOrderLineDSqe, 1) == false)
- {
- return;
- }
- if (testOrderCD() == false)
- {
- return;
- }
- OrderCD orderCD = new OrderCD();
- orderCD.DeliveryDateEnd = Convert.ToDateTime(txt_askDeliveryDateEnd.Value);
- orderCD.DeliveryDateStart = Convert.ToDateTime(txt_askDeliveryDateStart.Value);
- String strOrderLineSqe = ultraGrid2.ActiveRow.Cells["orderLineSqe"].Value.ToString().Trim();
- orderCD.OrderLineDSqe = strOrderLineDSqe;
- orderCD.OrderLineSqe = strOrderLineSqe;
- orderCD.Qty = double.Parse(txt_CD_Qty.Value.ToString().Trim());
- orderCD.Remark = txt_orderCD_Remark.Text.ToString().Trim();
- orderCD.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- orderCD.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- orderCD.UpdateTime = DateTime.Now;
- if (MessageUtil.ShowYesNoAndQuestion("确定修改发货行【" + strOrderLineDSqe + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCDService", "doUpdateOrderCD", new object[] { orderCD });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("修改成功");
- getOrderC(strOrderId, strOrderLineSqe);
- doActiveSelRow(ultraGrid4, "orderLineDSqe", strOrderLineDSqe);
- }
- else
- {
- MessageUtil.ShowTips("修改失败:" + re.Resultmsg);
- return;
- }
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowWarning("修改失败! " + e);
- return;
- }
- finally
- {
-
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetPUR_ORDER_M()// 查询
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- ClearTab1();
- ClearTab2();
- ClearTab3();
- ClearTab4();
- dataSet1.Clear();
- dataSet2.Clear();
- dataSet3.Clear();
- OrderM Odm = new OrderM();
- Odm.Status = COPStatus.Value == null ? null : COPStatus.Value.ToString().Trim();
- Odm.OrderType = COP_OrderType.Value == null ? null : COP_OrderType.Value.ToString().Trim();
- if(CK_Ctime.Checked==true)
- {
- if (txt_createTimeStart.Text != "")
- {
- Odm.CreateTime = Convert.ToDateTime(txt_createTimeStart.Value);
- }
- if (txt_createTimeEnd.Text != "")
- {
- Odm.UpdateTime = Convert.ToDateTime(txt_createTimeEnd.Value);
- }
- }
- Odm.OrderId = COP_OrderId.Text;
- Odm.SuppName = COP_SuppName.Text;
- Odm.Validflag = "1";
- Odm.ValidDataPurviewIds = this.ValidDataPurviewIds;
- Odm.BpmUserId = UserInfo.GetUserID();
- string strDataFlag = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.order.FrmOrderMNew" });
- //if(!Odm.OrderId.Equals("")){
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderMService", "find_OrderM", new object[] { Odm, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- // }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("查询合同头数据失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void AddPUR_ORDER_M()// 新增
- {
- try
- {
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[0].Text || ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[3].Text)
- {
- if (testOrderM() == false)
- {
- return;
- }
- OrderM Odm = new OrderM();
- Odm.AftPaymentAmt1 = (txt_AftPaymentAmt1.Value == null ? 0 : Convert.ToDouble(txt_AftPaymentAmt1.Text));
- Odm.BuyerName = txt_BuyerName.Text;
- Odm.ExchangeRateCur = (txt_ExchangeRateCur.Value == null ? 0 : Convert.ToDouble(txt_ExchangeRateCur.Text));
- Odm.Currency = txt_Currency.Value.ToString().Trim();
- Odm.OrderType = txt_OrderType.Value.ToString().Trim();//合同类别
- Odm.OrderClass = txt_OrderClass.Value.ToString().Trim();//合同分类
- Odm.ModeName = txt_ModeName.Text;
- Odm.ModeId = init_Mode_Id;
- Odm.SuppName = txt_SuppName.Text;
- Odm.SuppCode = init_Supp_Code;
- Odm.OrderMoneyType = txt_OrderMoneyType.Value == null ? null : txt_OrderMoneyType.Value.ToString().Trim();//合同金额分类
- Odm.SignDate = Convert.ToDateTime(txt_SignDate.Value);//签订日期
- Odm.OrderTitleCode = init_OrderTitleCode;
- Odm.BuyerName = UserInfo.GetUserName();
- Odm.CreateName = UserInfo.GetUserName();
- Odm.CreateUserid = UserInfo.GetUserID();
- Odm.CreateTime = DateTime.Now;
- Odm.SignAddress = txt_SignAddress.Text;
- Odm.TaxRateName = txt_TaxRateName.Value.ToString().Trim();
- Odm.DeliveryCondition = txt_deliveryCondition.Value.ToString().Trim();//运输条件
- Odm.DeliveryType = txt_deliveryType.Value.ToString().ToString().Trim();//运输方式
- Odm.Validflag = "1";
- Odm.Status = "1";
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderMService", "insert_OrderM", new object[] { Odm });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("新增失败!" + rt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("新增成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", rt.Resultmsg);
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId=uge.Cells["OrderId"].Value.ToString();
- if (strOrderId == "")
- {
- MessageUtil.ShowTips("合同头编号不能为空!");
- return;
- }
- //验证合同头是否可以增删改
- if (testOrderMStatus(strOrderId,1) == false)
- {
- return;
- }
- //验证填写数据的有效性
- if (testOrderC() == false)
- {
- return;
- }
- string str = strOrderId;
- OrderC odC = new OrderC();
- odC.OrderId = str;
- odC.ItemCode = txt_ItemCode.Text;
- odC.ItemAttr = txt_itemAttrName.Text;
- odC.ItemAttrId = init_itemAttrId;
- odC.PriceWithoutTax = (txt_PriceWithoutTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithoutTax.Value));
- odC.PriceWithTax = (txt_PriceWithTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithTax.Value));
- //odC.BuyerDeptDesc = txt_BuyerDeptDesc.Text;
-
- odC.PriceWithoutTax = (txt_PriceWithoutTax.Value == null ? 0 : Convert.ToDouble(txt_PriceWithoutTax.Value));
- //odC.BuyerUnitDesc = txt_BuyerUnitDesc.Text;
- odC.TaxAmt = (txt_TaxAmt2.Value == null ? 0 : Convert.ToDouble(txt_TaxAmt2.Value));
- odC.WithoutTaxAmt = (txt_WithoutTaxAmt2.Value == null ? 0 : Convert.ToDouble(txt_WithoutTaxAmt2.Value));
- odC.WithAmtTax = (txt_WithAmtTax2.Value == null ? 0 : Convert.ToDouble(txt_WithAmtTax2.Value));
- odC.ItemName = txt_ItemName.Text;
- odC.BuyerName = txt_BuyerName2.Text;
- odC.ChemPriceNo = txt_ChemPriceNo.Text;
- //odC.OtherPriceNum = txt_OtherPriceNum.Text;
- odC.ReceiveType = txt_ReceiveType.Value.ToString();
- odC.StartDate = Convert.ToDateTime(txt_StartDate2.Value);//交货开始时间
- odC.EndDate = Convert.ToDateTime(txt_EndDate2.Value);//交货结束时间
- odC.GradePriceNo = txt_GradePriceNo.Text;
- //odC.BasePriceNo = txt_BasePriceNo.Text;
-
- odC.DeliveryLocationCode = init_deliveryLocationCode;
- odC.QuantityPriceNum = txt_QuantityPriceNum.Text;
- odC.Remark = txt_Remark.Text.ToString().Trim();
- odC.PackageType = txt_packType.Value == null ? null : txt_packType.Value.ToString().Trim();//包装方式
- odC.PaymentCode = txt_paymentType.Value == null ? null : txt_paymentType.Value.ToString().Trim();//付款方式
- odC.Validflag = "1";
- if (txt_Pur_Clause.Value != null)
- {
- odC.BcmId = txt_Pur_Clause.Value.ToString().Trim();
- }
- else
- {
- odC.BcmId = "";
- }
- odC.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- odC.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- odC.CreateTime = DateTime.Now;
- odC.PurStandardsCode = txt_purstandardscode.Text;
- odC.Qty = (txt_Qty.Value == null ? 0 : Convert.ToDouble(txt_Qty.Text));
- odC.ItemUomConefficient = Convert.ToDouble(txt_ItemUomConefficient.Text);
- odC.ItemUom = txt_UNIT.Text;
- odC.WeightUnit = txt_WEIGHTUNIT.Text;
- odC.ItemUseUom = "1";
- odC.CkQty = ultraTextEditor6.Value == null ? 0 : Convert.ToDouble(ultraTextEditor6.Value);
- odC.ItemUnique = init_itemUnique;
- odC.ItemStandardsId = init_itemStandardsId;
- odC.ItemUomId = init_itemUomId;
- odC.ItemAttrId = init_itemAttrId;
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCService", "insert_MC", new object[] { odC, uge.Cells["OrderId"].Value.ToString() });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("新增失败!" + crt.Resultmsg);
- return;
- }
- //OrderM Omg = new OrderM();
- //Omg.OrderId = uge.Cells["OrderId"].Value.ToString();
- //Omg.WithAmtTax = (uge.Cells["WithAmtTax"].Value == null ? 0 : Convert.ToDouble(uge.Cells["WithAmtTax"].Value.ToString())) + odC.WithAmtTax;
- //Omg.WithoutTaxAmt = (uge.Cells["WithoutTaxAmt"].Value == null ? 0 : Convert.ToDouble(uge.Cells["WithoutTaxAmt"].Value.ToString())) + odC.WithoutTaxAmt;
- //this.execute("com.hnshituo.pur.order.service.OrderMService", "update", new object[] { Omg });
- MessageUtil.ShowTips("新增成功!");
- GetPUR_ORDER_M();
- doActiveSelRow(ultraGrid1, "orderId", odC.OrderId);
- getOrderC(odC.OrderId, odC.OrderLineSqe);
- }
- if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[2].Text)
- {
- try
- {
- UltraGridRow ugc = ultraGrid2.ActiveRow;
- if (ugc == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = ugc.GetCellValue("orderId").ToString().Trim();
- String strOrderLineSqe = ugc.GetCellValue("orderLineSqe").ToString().Trim();
- if (strOrderId == "" || strOrderLineSqe == "")
- {
- MessageUtil.ShowTips("合同行、合同头和合同行编号不能为空!");
- return;
- }
- if (testOrderCD() == false)
- {
- return;
- }
- OrderCD orderCD = new OrderCD();
- orderCD.DeliveryDateEnd = Convert.ToDateTime(txt_askDeliveryDateEnd.Value);
- orderCD.DeliveryDateStart = Convert.ToDateTime(txt_askDeliveryDateStart.Value);
- orderCD.Qty = double.Parse(txt_CD_Qty.Value.ToString().Trim());
- orderCD.OrderId = strOrderId;
- orderCD.OrderLineSqe = strOrderLineSqe;
- orderCD.Remark = txt_orderCD_Remark.Text.ToString().Trim();
- orderCD.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- orderCD.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- orderCD.CreateTime = DateTime.Now;
- orderCD.Validflag = "1";
- orderCD.Status = "0";
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCDService", "doInsertOrderCD", new object[] { orderCD });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("新增成功");
- getOrderC(strOrderId, strOrderLineSqe);
- doActiveSelRow(ultraGrid4, "orderLineDSqe", re.Resultmsg);
- }
- else
- {
- MessageUtil.ShowTips("新增失败:"+re.Resultmsg);
- return;
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("新增失败:"+ex);
- }
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowWarning("新增失败" + e);
- return;
- }
- }
- /// <summary>
- /// 打印预览
- /// </summary>
- private void getReportHT(String isSign)//打印 签名0显示,1不显示
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择您要查看的合同!");
- return;
- }
- //string ordLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
- //string saleOrg = ugr.Cells["SALE_ORG"].Value.ToString();
- //string ordPk = ugr.Cells["ORD_PK"].Value.ToString();
- string orderNo = ugr.Cells["OrderId"].Value.ToString();
- 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=RepPurOrderDev.cpt&__bypagesize__=false" + "&cmbOrder=" + orderNo + "&USER=" + isSign;
- }
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurOrder.cpt&__bypagesize__=false" + "&cmbOrder=" + orderNo + "&USER=" + isSign;
- }
- }
- else
- {
- //测试环境
- if (TipsEnv == "2")
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurOrderDev.cpt&__bypagesize__=false" + "&cmbOrder=" + orderNo + "&USER=" + isSign;
- }
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurOrder.cpt&__bypagesize__=false" + "&cmbOrder=" + orderNo + "&USER=" + isSign;
- }
- }
- //if (ob.MainUrl.StartsWith("http://127.0.0.1"))
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurOrderDev.cpt&__bypagesize__=false" + "&cmbOrder=" + orderNo;
- //}
- //else
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurOrder.cpt&__bypagesize__=false" + "&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 getReportJY()//打印
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择您要查看采购纪要的合同头!");
- return;
- }
- //string ordLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
- //string saleOrg = ugr.Cells["SALE_ORG"].Value.ToString();
- //string ordPk = ugr.Cells["ORD_PK"].Value.ToString();
- string strTaskRecordId = ugr.Cells["TaskRecordId"].Value.ToString().Trim();
- 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=RepTaskRecordDev.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- }
- //其它为生成环境
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepTaskRecord.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- }
- }
- else
- {
- //测试环境
- if (TipsEnv == "2")
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepTaskRecordDev.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- }
- //其它为生成环境
- else
- {
- strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepTaskRecord.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- }
- }
- //if (ob.MainUrl.StartsWith("http://127.0.0.1"))
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepTaskRecordDev.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- //}
- //else
- //{
- // strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepTaskRecordDev.cpt&__bypagesize__=false" + "&cmbTaskRecordId=" + strTaskRecordId;
- //}
- 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;
- }
- }
- #endregion
- #region 界面事件
- /// <summary>
- /// 点击表格 tab1页跳转事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- try
- {
- ClearTab1();
- ClearTab2();
- ClearTab4();
- ClearTab3();
- UltraGridRow uge = ultraGrid1.ActiveRow;
- currencylabel1.Text = uge.GetCellValue("Currency").ToString().ToString();
- currencylabel2.Text = uge.GetCellValue("Currency").ToString().ToString();
- currencylabel3.Text = uge.GetCellValue("Currency").ToString().ToString();
- currencylabel4.Text = uge.GetCellValue("Currency").ToString().ToString();
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- //加载编辑区数据
- OrderM Omg = this.execute<OrderM>("com.hnshituo.pur.order.service.OrderMService", "findById", new object[] { strOrderId });
- txt_OrderType.Value = Omg.OrderType == null ? null : Omg.OrderType.ToString();//合同类别
- txt_OrderClass.Value = Omg.OrderClass == null ? null : Omg.OrderClass.ToString().Trim();//合同分类
- txt_Currency.Value = Omg.Currency == null ? null : Omg.Currency.ToString();//合同货币代码
- txt_deliveryCondition.Value = Omg.DeliveryCondition == null ? "" : Omg.DeliveryCondition.ToString().Trim();//运输条件
- txt_deliveryType.Value = Omg.DeliveryType == null ? "" : Omg.DeliveryType.ToString().Trim();//运输条件
- txt_OrderMoneyType.Value = Omg.OrderMoneyType == null ? null : Omg.OrderMoneyType.ToString().Trim();//合同金额类别
- txt_TaxRateName.Value = Omg.TaxRateName == null ? null : Omg.TaxRateName.ToString().Trim();//合同税率
- txt_SignAddress.Text = Omg.SignAddress == null ? null : Omg.SignAddress.ToString();//签订地点
- init_OrderTitleCode = Omg.OrderTitleCode == null ? null : Omg.OrderTitleCode.ToString();//合同抬头编号
- Title title = this.execute<Title>("com.hnshituo.pur.configure.service.TitleService", "findById", new object[] { init_OrderTitleCode });
- if (title != null)
- {
- txt_TitleName.Text = title.TitleName;//合同抬头名称
- }
- txt_BuyerName.Text = Omg.BuyerName == null ? null : Omg.BuyerName.ToString();//采购员
- txt_CreateTime.Value = Omg.CreateTime;//创建时间
- txt_SignDate.Value = Omg.SignDate == null ? null : Omg.SignDate;//签订日期
- txt_SuppName.Text = Omg.SuppName == null ? null : Omg.SuppName.ToString();//供应商名称
- txt_ModeName.Text = Omg.ModeName == null ? null : Omg.ModeName.ToString();//模板名称
- init_Mode_Id = Omg.ModeId;//模板id
- txt_OrderId.Text = Omg.OrderId == null ? null : Omg.OrderId.ToString();//合同号
- init_Supp_Code = Omg.SuppCode;
- txt_TaskRecordId.Text = Omg.TaskRecordId;
- txt_WithAmtTax.Value = Omg.WithAmtTax;//含税金额
- txt_AftPaymentAmt1.Value = Omg.AftPaymentAmt1;//尾款1
- txt_WithoutTaxAmt.Value = Omg.WithoutTaxAmt;//不含税金额
- txt_TaxAmt.Value = Omg.TaxAmt;//合同税额
- //加载从表数据
- OrderC odC = new OrderC();
- odC.OrderId = strOrderId;
- odC.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- //加载任务单数据
- OrderModeC Omc = new OrderModeC();
- Omc.ModeId = Omg.ModeId;
- if (!string.IsNullOrEmpty(Omc.ModeId))
- {
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderModeCService", "find_ModeC", new object[] { Omc, 0, 0 });
- GridHelper.CopyDataToDatatable(dt1, dataTable3, true);
- }
- //加载采购纪要数据
- string strTaskRecordId = Omg.TaskRecordId;
- PurTaskRecordEntity taskRecord = this.execute<PurTaskRecordEntity>("com.hnshituo.pur.purplan.service.TaskRecordService", "findById", new object[] { strTaskRecordId });
- jy_buyerUsername.Text = taskRecord.BuyerUsername;
- jy_mngOrgName.Text = taskRecord.MngOrgName;
- jy_negDate.Value = taskRecord.NegDate;
- jy_procRecord.Text = taskRecord.ProcRecord;
- jy_taskId.Text = taskRecord.TaskId;
- jy_taskName.Text = taskRecord.TaskName;
- //加载采购纪要评单记录表
- DataTable dt6 = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskEvaService", "doQueryEva", new object[] { taskRecord.TaskId });
- GridHelper.CopyDataToDatatable(dt6, dataTable5, true);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("加载合同行和条款数据失败:" + ex);
- }
- }
- private void ultraGrid1_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- }
- /// <summary>
- /// 点击表格 tab2页跳转事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
- ClearTab2();
- ClearTab3();
- UltraGridRow uge1 = ultraGrid1.ActiveRow;
- currencyLabel62.Text = uge1.GetCellValue("Currency").ToString().ToString();
- currencyLabel63.Text = uge1.GetCellValue("Currency").ToString().ToString();
- currencyLabel64.Text = uge1.GetCellValue("Currency").ToString().ToString();
- currencyLabel65.Text = uge1.GetCellValue("Currency").ToString().ToString();
- currencyLabel66.Text = uge1.GetCellValue("Currency").ToString().ToString();
- UltraGridRow uge = ultraGrid2.ActiveRow;
- String strOrderLineSqe = uge.Cells["OrderLineSqe"].Value.ToString();
- if (String.IsNullOrEmpty(strOrderLineSqe))
- {
- MessageUtil.ShowTips("合同行号为空");
- return;
- }
- OrderC Odc = this.execute<OrderC>("com.hnshituo.pur.order.service.OrderCService", "findById", new object[] { strOrderLineSqe });
- txt_ReceiveType.Value = Odc.ReceiveType == null ? null : Odc.ReceiveType.ToString().Trim();//入库类型
- txt_packType.Value = Odc.PackageType == null ? "" : Odc.PackageType.ToString().Trim();//包装方式
- txt_paymentType.Value = Odc.PaymentCode == null ? null : Odc.PaymentCode.ToString().Trim();//付款方式
- txt_Pur_Clause.Value = Odc.BcmId == null ? "" : Odc.BcmId.ToString().Trim();//结算条款
- txt_PriceWithoutTax.Value = Odc.PriceWithoutTax;//不含税单价
- txt_PriceWithTax.Value = Odc.PriceWithTax;//含税单价
- txt_Qty.Value = Odc.Qty = Odc.Qty;//合同数量
- txt_QuantityPriceNum.Text = Odc.QuantityPriceNum == null ? null : Odc.QuantityPriceNum.ToString();//保量加价标准编号
- init_deliveryLocationCode = Odc.DeliveryLocationCode;//交付地点编码
- //txt_BasePriceNo.Value = Odc.BasePriceNo == null ? null : Odc.BasePriceNo.ToString();//基础价格编号
- txt_GradePriceNo.Text = Odc.GradePriceNo == null ? null : Odc.GradePriceNo.ToString();//品级计价标准编号
- //txt_OtherPriceNum.Text = Odc.OtherPriceNum == null ? null : Odc.OtherPriceNum.ToString();//其它计价标准编号
- txt_ChemPriceNo.Text = Odc.ChemPriceNo == null ? null : Odc.ChemPriceNo.ToString();//成分计价标准编号
- //txt_BuyerUnitDesc.Text = Odc.BuyerUnitDesc == null ? null : Odc.BuyerUnitDesc.ToString();//采购管理科室描叙
- txt_ItemName.Text = Odc.ItemName == null ? null : Odc.ItemName.ToString();//物料简称
- //txt_BuyerDeptDesc.Text = Odc.BuyerDeptDesc == null ? null : Odc.BuyerDeptDesc.ToString();//采购管理部门描叙
- txt_itemAttrName.Text = Odc.ItemAttr == null ? null : Odc.ItemAttr.ToString();//物料属性名称
- txt_OrderLineSqe.Text = Odc.OrderLineSqe == null ? null : Odc.OrderLineSqe.ToString();//合同行号
- txt_UNIT.Text = Odc.ItemUom == null ? null : Odc.ItemUom.ToString();
- txt_WEIGHTUNIT.Text = Odc.WeightUnit == null ? null : Odc.WeightUnit.ToString();
- txt_purstandardscode.Text = Odc.ItemStandardsCode;
- txt_Remark.Text = Odc.Remark;
- txt_ItemUomConefficient.Text = Odc.ItemUomConefficient == null ? null : Odc.ItemUomConefficient.ToString();
- ultraTextEditor6.Text = Odc.CkQty.ToString().Trim();
- txt_ItemCode.Text = Odc.ItemCode == null ? null : Odc.ItemCode.ToString();//物料编码
- init_itemAttrId = Odc.ItemAttrId == null ? null : Odc.ItemAttrId.ToString();//物料属性
- init_itemUomId = Odc.ItemUomId;//物料单位换算ID
- init_itemStandardsId = Odc.ItemStandardsId;//采购标准ID
- init_itemUnique = Odc.ItemUnique;//物料唯一码
- txt_StartDate2.Value = Odc.StartDate;//开始交期
- txt_EndDate2.Value = Odc.EndDate;//结束交期
- //加载交货行数据
- Get_OrderCD(txt_OrderLineSqe.Text);
- //计算剩余可编制量
- getRemainQty(txt_OrderLineSqe.Text);
- //初始化交货行交期
- txt_askDeliveryDateEnd.Value = Odc.EndDate;
- }
- private void ultraGrid2_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
- }
- /// <summary>
- /// 点击表格 tab3页跳转事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid4_ClickCell(object sender, ClickCellEventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[2];
- UltraGridRow ucd = ultraGrid4.ActiveRow;
- txt_CD_Qty.Value = ucd.GetCellValue("qty");
- txt_askDeliveryDateEnd.Value = ucd.GetCellValue("deliveryDateend");
- txt_askDeliveryDateStart.Value = ucd.GetCellValue("deliveryDatestart");
- txt_orderCD_Remark.Text = ucd.GetCellValue("remark").ToString().Trim();
- }
- private void ultraGrid4_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[2];
- }
- /// <summary>
- /// 控制输入数字
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_QtyOrder_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
- {
- e.Handled = true;
- }
- }
- /// <summary>
- /// 金额自动计算
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_QtyOrder_ValueChanged(object sender, EventArgs e)
- {
- String StrTaxRate;
- if (ultraGrid1.ActiveRow != null)
- {
- StrTaxRate = ultraGrid1.ActiveRow.Cells["taxRateName"].Value.ToString().Trim();
- }
- else
- {
- MessageUtil.ShowTips("请在合同信息区域选择有效合同行");
- return;
- }
- if (String.IsNullOrEmpty(StrTaxRate))
- {
- //MessageUtil.ShowTips("获取合同税率失败,请先完善合同信息");
- return;
- }
- if (StrTaxRate == "NULL")
- {
- return;
- }
- Double demiTaxRate = Convert.ToDouble(StrTaxRate.Substring(0, StrTaxRate.Length-1))/100;
- if (!string.IsNullOrEmpty(txt_ItemUomConefficient.Text))
- {
- ultraTextEditor6.Value = Convert.ToDouble(txt_ItemUomConefficient.Value) * Convert.ToDouble(txt_Qty.Value);
- }
- if (txt_PriceWithoutTax.Value !=null && txt_Qty.Value != null)
- {
- txt_WithAmtTax2.Value = Math.Round(Convert.ToDouble(txt_Qty.Value) * Convert.ToDouble(txt_PriceWithoutTax.Value) * (1 + demiTaxRate), 2);
- txt_WithoutTaxAmt2.Value = Convert.ToDouble(txt_Qty.Value) * Convert.ToDouble(txt_PriceWithoutTax.Value);
- txt_TaxAmt2.Value = Math.Round(Convert.ToDouble(txt_WithAmtTax2.Value) - Convert.ToDouble(txt_WithoutTaxAmt2.Value), 2);
- txt_PriceWithTax.Value = Math.Round(Convert.ToDouble(txt_PriceWithoutTax.Value) * (1 + demiTaxRate), 2);
- }
- else
- {
- txt_WithAmtTax2.Value = 0;
- txt_WithoutTaxAmt2.Value = 0;
- txt_TaxAmt2.Value = 0;
- txt_PriceWithTax.Value = 0;
- }
- }
- private void txt_PriceWithoutTax_ValueChanged(object sender, EventArgs e)
- {
- String StrTaxRate;
- if (ultraGrid1.ActiveRow != null)
- {
- StrTaxRate = ultraGrid1.ActiveRow.Cells["taxRateName"].Value.ToString().Trim();
- }
- else
- {
- MessageUtil.ShowTips("请在合同信息区域选择有效合同行");
- return;
- }
- if (String.IsNullOrEmpty(StrTaxRate))
- {
- //MessageUtil.ShowTips("获取合同税率失败,请先完善合同信息");
- return;
- }
- if (StrTaxRate == "NULL")
- {
- return;
- }
- Double demiTaxRate = Convert.ToDouble(StrTaxRate.Substring(0, StrTaxRate.Length - 1))/100;
- if (txt_Qty.Value != null && txt_PriceWithoutTax.Value != null)
- {
- txt_PriceWithTax.Value = Math.Round( Convert.ToDouble(txt_PriceWithoutTax.Value) * (1 + demiTaxRate), 2);
- txt_WithAmtTax2.Value = Math.Round(Convert.ToDouble(txt_Qty.Value) * Convert.ToDouble(txt_PriceWithoutTax.Value) * (1 + demiTaxRate), 2);
- txt_WithoutTaxAmt2.Value = Convert.ToDouble(txt_Qty.Value) * Convert.ToDouble(txt_PriceWithoutTax.Value);
- txt_TaxAmt2.Value = Math.Round(Convert.ToDouble(txt_WithAmtTax2.Value) - Convert.ToDouble(txt_WithoutTaxAmt2.Value), 2);
- }
- else
- {
- txt_WithAmtTax2.Value = 0;
- txt_WithoutTaxAmt2.Value = 0;
- txt_TaxAmt2.Value = 0;
- txt_PriceWithTax.Value = 0;
- }
- }
- /// <summary>
- /// 合同模板弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_ModeName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPop_upOrderMode Pop = new FrmPop_upOrderMode(this.ob);
- Pop.ShowDialog();
- if (Pop.ModeId == null)
- return;
- txt_ModeName.Text = Pop.ModeName.ToString();
- init_Mode_Id = Pop.ModeId.ToString();
- }
- /// <summary>
- /// 供应商弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_SuppName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- //Supp Sp = new Supp();
- //Sp.Validflag = "1";
- //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppService", "find", new object[] { Sp, 0, 0 });
- frmSuppSel Sky = new frmSuppSel(this.ob);
- Sky.ShowDialog();
- if (Sky.strSUPP_CODE == null)
- return;
- txt_SuppName.Text = Sky.strSUPP_NAME.ToString();
- init_Supp_Code = Sky.strSUPP_CODE.ToString();
- txt_TaxRateName.Value = Sky.strSUPP_TAX_RATE.ToString().Trim();
- }
- /// <summary>
- /// 物料弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_ItemCode_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPurPlanMat mat = new FrmPurPlanMat(this.ob);
- mat.ShowDialog();
- if (mat.getItemCode() == null)
- return;
- if (mat.ItemAttrId == null) //属性编码
- {
- MessageUtil.ShowTips("物料属性为空");
- return;
- }
- if (mat.ItemStandardsId == null)
- {
- MessageUtil.ShowTips("标准编号值为空");
- return;
- }
- if (mat.ItemUomId==null)
- {
- MessageUtil.ShowTips("单位换算为空");
- return;
- }
- txt_ItemCode.Value = mat.getItemCode().ToString();
- txt_ItemName.Value = mat.getItemName().ToString();
- txt_UNIT.Text = mat.UomName.ToString();
- txt_WEIGHTUNIT.Text = mat.getWeightUnit().ToString();
- txt_ReceiveType.Value = mat.getReceiveType().ToString();//默认接收方式
- init_itemAttrId = mat.ItemAttrId == null ? "" : mat.ItemAttrId.ToString();
- txt_itemAttrName.Value = mat.ItemAttr == null ? "" : mat.ItemAttr.ToString();
- txt_ItemUomConefficient.Text = mat.getItemUomConefficient().ToString();
- init_itemAttrId = mat.ItemAttrId;//属性编码
- init_itemStandardsId = mat.ItemStandardsId;//采购标准编码
- init_itemUomId = mat.ItemUomId;//单位换算编码
- init_itemUnique = mat.ItemUnique;
- txt_purstandardscode.Text = mat.StandardsCode;
- //选择新物料后清空数据
- txt_Qty.Value = 0;//合同数量
- txt_PriceWithoutTax.Value = 0;//不含税单价
- }
- /// <summary>
- /// 抬头弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_TitleName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPop_upTitle Pot = new FrmPop_upTitle(this.ob);
- Pot.ShowDialog();
- if (Pot.Id == null)
- return;
- init_OrderTitleCode = Pot.Id;
- txt_TitleName.Text = Pot.TitleName;
- }
- /// <summary>
- /// 交货行编制数量输入校验
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_CD_Qty_ValueChanged(object sender, EventArgs e)
- {
- if (txt_CD_Qty.Value != null)
- {
- if (ultraGrid4.ActiveRow == null)
- {
- if ((double)txt_CD_Qty.Value > double.Parse(init_MaxOrderCDQty))
- {
- label3.Text = "新增可编制量" + init_MaxOrderCDQty + "[" + init_OrderCDUom + "]";
- //txt_CD_Qty.Value = double.Parse(MaxOrderCDQty);
- //System.Windows.Forms.Application.DoEvents();
- label3.ForeColor = Color.Red;
- label3.Visible = true;
- }
- else
- {
- label3.ForeColor = Color.Black;
- label3.Visible = true;
- }
- }
- else
- {
- double canUse = double.Parse(init_MaxOrderCDQty) + double.Parse(ultraGrid4.ActiveRow.Cells["qty"].Value.ToString().Trim());
- if ((double)txt_CD_Qty.Value > canUse)
- {
- //txt_CD_Qty.Value = canUse;
- label3.Text = "新增可编制量" + init_MaxOrderCDQty + "[" + init_OrderCDUom + "] | 修改可编辑量" + canUse + "[" + init_OrderCDUom + "]";
- //System.Windows.Forms.Application.DoEvents();
- label3.ForeColor = Color.Red;
- label3.Visible = true;
- }
- else
- {
- label3.ForeColor = Color.Black;
- label3.Visible = true;
- }
- }
- }
- }
- /// <summary>
- /// 交货行交货开始时间校验
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_askDeliveryDateStart_ValueChanged(object sender, EventArgs e)// 交货行交货开始时间校验
- {
- if (String.IsNullOrEmpty(txt_askDeliveryDateStart.Text))
- {
- label4.Text = "*无效交期";
- label4.ForeColor = Color.Red;
- label4.Visible = true;
- }
- else
- {
- label4.Visible = false;
- }
- }
- /// <summary>
- /// 交货行交货结束时间校验
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_askDeliveryDateEnd_ValueChanged(object sender, EventArgs e)// 交货行交货结束时间校验
- {
- if (String.IsNullOrEmpty(txt_askDeliveryDateEnd.Text))
- {
- label2.Text = "*无效交期";
- label2.ForeColor = Color.Red;
- label2.Visible = true;
- }
- else
- {
- DateTime timeNow = DateTime.Now;
- label2.Text = "*该交期小于等于当前时间,可能导致供方无法交货";
- if (!String.IsNullOrEmpty(txt_askDeliveryDateStart.Text))
- {
- DateTime timeNow1 = Convert.ToDateTime(txt_askDeliveryDateStart.Value);
- //取当前时间和发货开始时间最大的数
- if (timeNow1 > timeNow)//取发货时间比较
- {
- timeNow = timeNow1;
- label2.Text = "*该交期小于等于发货开始时间,可能导致供方无法交货";
- }
- }
- DateTime inputDate = Convert.ToDateTime(txt_askDeliveryDateEnd.Value);
- if (inputDate <= timeNow)
- {
-
- label2.ForeColor = Color.Red;
- label2.Visible = true;
- }
- else
- {
- label2.Visible = false;
- }
- }
- }
- /// <summary>
- /// 合同货币类型选择-界面上货币名称变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_Currency_ValueChanged(object sender, EventArgs e)
- {
- currencylabel1.Text = txt_Currency.Text;
- currencylabel2.Text = txt_Currency.Text;
- currencylabel3.Text = txt_Currency.Text;
- currencylabel4.Text = txt_Currency.Text;
- currencyLabel62.Text = txt_Currency.Text;
- currencyLabel63.Text = txt_Currency.Text;
- currencyLabel64.Text = txt_Currency.Text;
- currencyLabel65.Text = txt_Currency.Text;
- currencyLabel66.Text = txt_Currency.Text;
- }
- /// <summary>
- /// 创建时间查询控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void CK_Ctime_CheckedChanged(object sender, EventArgs e)// 创建时间查询控制
- {
- if (CK_Ctime.Checked == false)
- {
- txt_createTimeEnd.Enabled = false;
- txt_createTimeStart.Enabled = false;
- }
- else
- {
- txt_createTimeEnd.Enabled = true;
- txt_createTimeStart.Enabled = true;
- }
- }
- #endregion
- #region 初始化函数
- /// <summary>
- /// 选择和合同结算
- /// </summary>
- private void Init()
- {
- switch (this.CustomInfo.ToString().Trim())
- {
- case "@Confirma":
- #region
- ultraGrid1.DisplayLayout.Bands[0].Columns["Check"].Hidden = false;
- ultraExpandableGroupBox2.Visible = false;
- COPStatus.SelectedIndex = 3;
- #endregion
- break;
- }
- initDropDownList();
- //合同状态默认全部
- COPStatus.SelectedIndex = 0;
- txt_BuyerName.Text = CoreUserInfo.UserInfo.GetUserName();
- txt_BuyerName2.Text = CoreUserInfo.UserInfo.GetUserName();
- //头初始化
- txt_SignDate.Value = DateTime.Now;//签订日期
- txt_CreateTime.Value = DateTime.Now;//录入日期
- txt_SignAddress.Text = "公司本部";
- //行初始化
- txt_StartDate2.Value = DateTime.Now;//送货开始日期
- txt_EndDate2.Value = DateTime.Now ;//送货结束日期
- CK_Ctime.Checked = true;
- txt_createTimeStart.Value = DateTime.Now.AddDays(-2);
- txt_createTimeEnd.Value = DateTime.Now.AddDays(2);
- //交货行
- txt_askDeliveryDateStart.Value = DateTime.Now;
- txt_askDeliveryDateEnd.Value = DateTime.Now;
- //加载数据 加载太耗费时间
- //GetPUR_ORDER_M();
- //默认收起编辑区
- ultraExpandableGroupBox2.Expanded = false;
- //设置Grid不可编辑
- //SetColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
- SetColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
- SetColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { });
- SetColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] { });
- SetColumnsActive(ultraGrid6.DisplayLayout.Bands[0], new string[] { });
- }
- /// <summary>
- /// 初始化DropDownList控件
- /// </summary>
- private void initDropDownList()// 初始化DropDownList控件
- {
- //加载结算条款
- BalanceClauseM bm = new BalanceClauseM();
- bm.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceClauseMService", "doQueryClauseM", new object[] { bm });
- comm.FilComboboxAdd(txt_Pur_Clause, dt, "bcmId", "bcmName", null, true, "/", "");
- //合同类别
- DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1200" }, this.ob);
- comm.FilComboboxAdd(COP_OrderType, dt1, "baseCode", "baseName", "validflag NOT in ('0')", true, "全部", "");
- COP_OrderType.SelectedIndex = 0;
- comm.FilComboboxAdd(txt_OrderType, dt1, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- //合同税率
- DataTable dt2 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1109" }, this.ob);
- comm.FilComboboxAdd(txt_TaxRateName, dt2, "memo", "baseName", "validflag NOT in ('0')", false, "/", "");
- //合同分类
- DataTable dt3 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1220" }, this.ob);
- comm.FilComboboxAdd(txt_OrderClass, dt3, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- //货币代码
- //throw new NotImplementedException();
- DataTable dt4 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1001" }, this.ob);
- comm.FilComboboxAdd(txt_Currency, dt4, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- txt_Currency.SelectedIndex = 1;
- //接收方式
- DataTable dt5 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob);
- comm.FilComboboxAdd(txt_ReceiveType, dt5, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- //加载运输条件
- DataTable dt6 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1105" }, this.ob);
- comm.FilComboboxAdd(txt_deliveryCondition, dt6, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", "");
- //加载运输方式
- DataTable dt7 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1102" }, this.ob);
- comm.FilComboboxAdd(txt_deliveryType, dt7, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", "");
- //加载包装方式
- DataTable dt8 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1107" }, this.ob);
- comm.FilComboboxAdd(txt_packType, dt8, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", "");
- //加载付款方式
- DataTable dt9 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1104" }, this.ob);
- comm.FilComboboxAdd(txt_paymentType, dt9, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- //加载合同金额分类
- DataTable dt10 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1222" }, this.ob);
- comm.FilComboboxAdd(txt_OrderMoneyType, dt10, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
- }
- /// <summary>
- /// 清除合同头编辑区
- /// </summary>
- private void ClearTab1()//清除合同头编辑区
- {
- txt_WithAmtTax.Value = 0;//含税金额
- txt_AftPaymentAmt1.Value = 0;//尾款1
- txt_TaxAmt.Value = 0;//合同税额
- txt_WithoutTaxAmt.Value = 0;//不含税金额
- txt_OrderId.Text = "";//合同号
- init_Supp_Code = "";//供应商编码
- init_Mode_Id = "";//合同模板编码
- txt_OrderId.Text = "";//合同编号
- txt_TaskRecordId.Text = "";//采购纪要
- txt_ModeName.Text = "";//合同模板名称
- txt_TitleName.Text = "";//合同头名称
- init_OrderTitleCode = "";//合同头编码
- init_OrderTitleCode = "";//合同头编码
- currencylabel1.Text = "-";
- currencylabel2.Text = "-";
- currencylabel3.Text = "-";
- currencylabel4.Text = "-";
- txt_SignAddress.Value= "公司本部";//签订地点
- txt_BuyerName.Text = "";//采购员
- txt_CreateTime.Value = DateTime.Now;//创建时间
- txt_SignDate.Value = DateTime.Now;//签订日期
- txt_SuppName.Text = "";//供应商名称
- init_Supp_Code = "";//供应商编号
- txt_ModeName.Text = "";//模板名称
- init_Mode_Id = "";//模板id
- txt_TaskRecordId.Text = "";//采购纪要号
- txt_OrderType.SelectedIndex = -1;//合同类别
- txt_Currency.SelectedIndex = -1;//合同货币代码
- txt_OrderClass.SelectedIndex = -1;//合同分类置空
- txt_TaxRateName.SelectedIndex=-1;//税率
- txt_OrderMoneyType.SelectedIndex = -1;//合同金额类别
- txt_deliveryType.SelectedIndex = -1;//运输方式
- txt_deliveryCondition.SelectedIndex = -1;//运输条件
-
- }
- /// <summary>
- /// 清空合同行编辑区
- /// </summary>
- private void ClearTab2()// 清空合同行编辑区
- {
- //合同行部分
- txt_Qty.Value = 0;//合同数量
- txt_PriceWithTax.Value = 0;//含税单价
- txt_PriceWithoutTax.Value = 0;//不含税单价
- txt_CD_Qty.Value = 0;
- txt_QuantityPriceNum.Text = "";//保量加价标准编号
- init_deliveryLocationCode = "";//交付地点编码
- //txt_BasePriceNo.Text = "";//基础价格编号
- txt_GradePriceNo.Text = "";//品级计价标准编号
- //txt_OtherPriceNum.Text = "";//其它计价标准编号
- txt_ChemPriceNo.Text = "";//成分计价标准编号
- txt_DelvryRangeMin.Text = "";//交货量差下限
- //txt_BuyerUnitDesc.Text = "";//采购管理科室描叙
- txt_ItemName.Text = "";//物料简称
- //txt_BuyerDeptDesc.Text = "";//采购管理部门描叙
- txt_ItemCode.Text = "";//物料编码
- txt_OrderLineSqe.Text = "";//合同行号
- txt_UNIT.Text = "-";
- txt_WEIGHTUNIT.Text = "-";
- txt_purstandardscode.Text = "";
- txt_itemAttrName.Text = "";
- txt_orderCD_Remark.Text = "";
-
- init_itemUomId = "";//物料单位换算ID
- init_itemStandardsId = "";//采购标准ID
- init_itemAttrId = "";//物料属性编码
- init_itemUnique = "";//物料唯一码
- txt_StartDate2.Value = DateTime.Now;//交期开始
- txt_EndDate2.Value = DateTime.Now;//交期结束
- txt_ReceiveType.SelectedIndex = -1;//接收方式
- txt_Pur_Clause.SelectedIndex = -1;//结算条款
- txt_paymentType.SelectedIndex = -1;//付款方式
- txt_packType.SelectedIndex = -1;//包装方式
- currencyLabel62.Text = "-";
- currencyLabel63.Text = "-";
- currencyLabel64.Text = "-";
- currencyLabel65.Text = "-";
- currencyLabel66.Text = "-";
- }
- /// <summary>
- /// 清空发货行编辑区
- /// </summary>
- private void ClearTab3()// 清空发货行编辑区
- {
- txt_CD_Qty.Value = null;
- txt_orderCD_Remark.Text = "";
- label3.Text = "";
- label3.Visible = false;
- label2.Text = "";
- label2.Visible = false;
- label4.Visible = false;
- txt_askDeliveryDateEnd.Value = DateTime.Now;
- txt_askDeliveryDateStart.Value = DateTime.Now;
- }
- private void ClearTab4()
- {
- ConfigureClassCommon.clearOldData(panel1);
- jy_procRecord.Clear();
- }
- #endregion
- #region 公共函数
- /// <summary>
- ///从表 查询
- /// </summary>
- private void getOrderC(string ab, String lineId)
- {
- dataTable2.Clear();
- dataTable3.Clear();
- OrderC odC = new OrderC();
- odC.OrderId = ab;
- odC.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- ConfigureClassCommon.doActiveSelRow(ultraGrid2, "orderLineSqe", lineId);
- }
- /// <summary>
- /// 查询合同行可生成的交货行数量
- /// </summary>
- /// <param name="strOrderLineSqe"></param>
- /// <returns></returns>
- private void getRemainQty(String strOrderLineSqe)
- {
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCDService", "doRemainQty", new object[] { strOrderLineSqe });
- if (re.Resultcode!=0)
- {
- MessageUtil.ShowTips("查询剩余可编制量失败:"+re.Resultmsg);
- return;
- }
- label3.Text = "剩余可编制量" + re.Resultmsg + "[" + re.Resultdata + "]";
- init_MaxOrderCDQty = re.Resultmsg;
- init_OrderCDUom = re.Resultdata == null ? "" : re.Resultdata.ToString();
- //txt_CD_Qty.MaxValue = double.Parse(re.Resultmsg);
- label3.ForeColor = Color.Black;
- label3.Visible = true;
- }
- /// <summary>
- /// 根据合同行号查交货行信息
- /// </summary>
- private void Get_OrderCD(String strOrderLineSqe)
- {
- if (String.IsNullOrEmpty(strOrderLineSqe))
- {
- return;
- }
- else
- {
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCDService", "doQueryOrderCD", new object[] { strOrderLineSqe });
- GridHelper.CopyDataToDatatable(dt, dataTable4, true);
- }
- }
- /// <summary>
- /// 设置包含在指定列中的列可编辑
- /// </summary>
- /// <param name="band"></param>
- /// <param name="columnKeys"></param>
- public static void SetColumnsActive(UltraGridBand band, params string[] columnKeys)
- {
- foreach (UltraGridColumn gridColumn in band.Columns)
- {
- if (columnKeys.Contains(gridColumn.Key) != true)
- {
- gridColumn.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 字符串转是否能转换成非负数
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public static bool Is_Below_zero(string str)
- {
- try
- {
- if (str.Equals(""))
- {
- return false;
- }
- else
- {
- if (StringUtil.IsDouble(str) && double.Parse(str) > 0)
- return true;
- else
- return false;
- }
- }
- catch
- {
- return false;
- }
- }
- /// <summary>
- /// 激活输入当前值行数据
- /// </summary>
- /// <param name="ug">ultragrid</param>
- /// <param name="strColumn">列名</param>
- /// <param name="strKey">列值</param>
- public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey)// 激活输入当前值行数据
- {
- try
- {
- if (strKey != "")
- {
- foreach (UltraGridRow row in ug.Rows)
- {
- if (row.Cells[strColumn].Text.ToString() == strKey)
- {
- row.Activated = true;
- if (row.ChildBands != null)
- row.Expanded = true;
- }
- }
- }
- return "";
- }
- catch (Exception ex)
- {
- return ex.ToString();
- }
- }
- /// <summary>
- /// 验证合同头输入数据有效性
- /// </summary>
- /// <returns></returns>
- private bool testOrderM()// 验证合同头输入数据有效性
- {
- if (string.IsNullOrEmpty(txt_Currency.Text) || txt_Currency.Text.ToString().Trim() == "/")
- {
- MessageUtil.ShowTips("合同货币类型不能为空");
- txt_Currency.Focus();
- return false;
- }
- if (string.IsNullOrEmpty(txt_OrderType.Text) || txt_OrderType.Text.ToString().Trim() == "/")
- {
- MessageUtil.ShowTips("合同类别不能为空!");
- txt_OrderType.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(init_Supp_Code))
- {
- MessageUtil.ShowTips("供应商不能为空,请选择供方信息");
- txt_SuppName.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_TaxRateName.Text))
- {
- MessageUtil.ShowTips("合同税率不允许为空");
- txt_TaxRateName.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_OrderType.Value.ToString().Trim()) || txt_OrderType.Value.ToString().Trim() == "/")
- {
- MessageUtil.ShowTips("未选择合同类别为空,请选择合同类别");
- txt_OrderType.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(init_Mode_Id) || init_Mode_Id == "/")
- {
- MessageUtil.ShowTips("未选择合同模板,请选择合同模板");
- txt_ModeName.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_SignDate.Text))
- {
- MessageUtil.ShowTips("请输入合同签订日期");
- txt_SignDate.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证合同行输入数据的有效性
- /// </summary>
- /// <returns></returns>
- private bool testOrderC()// 验证合同行输入数据的有效性
- {
- if (txt_Qty.Value==null || txt_PriceWithoutTax.Value==null || string.IsNullOrEmpty(txt_ItemCode.Text))
- {
- MessageUtil.ShowTips("合同数,单价,物料不能为空");
- return false;
- }
- if (txt_PriceWithoutTax.Value==null|| txt_PriceWithTax.Value==null)
- {
- MessageUtil.ShowTips("请输入物料有效的含税单价和不含税单价");
- txt_PriceWithoutTax.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_ReceiveType.Text))
- {
- MessageUtil.ShowTips("请选择接收方式");
- txt_ReceiveType.Focus();
- return false;
- }
- if (txt_paymentType.SelectedIndex==-1)
- {
- MessageUtil.ShowTips("请选择付款方式");
- txt_paymentType.Focus();
- return false;
- }
- if (string.IsNullOrEmpty(txt_ItemUomConefficient.Text))
- {
- MessageUtil.ShowTips("转化系数为空");
- txt_ItemUomConefficient.Focus();
- return false;
- }
- if (txt_UNIT.Text == "" || txt_UNIT.Text == "-" || txt_WEIGHTUNIT.Text == "" || txt_WEIGHTUNIT.Text == "-")
- {
- MessageUtil.ShowTips("采购单位或者库存单位无效");
- return false;
- }
- //if (String.IsNullOrEmpty(txt_StartDate2.Text))
- //{
- // MessageUtil.ShowTips("请输入有效的合同行交货开始时间");
- // txt_StartDate2.Focus();
- // return false;
- //}
- if (String.IsNullOrEmpty(txt_EndDate2.Text))
- {
- MessageUtil.ShowTips("请输入有效的合同行交货开始时间");
- txt_EndDate2.Focus();
- return false;
- }
- //if (Convert.ToDateTime(txt_StartDate2.Value) > Convert.ToDateTime(txt_EndDate2.Value))
- //{
- // MessageUtil.ShowTips("交货开始时间不能需早于接收时间,请输入有效的合同行交货开始时间");
- // txt_EndDate2.Focus();
- // return false;
- //}
- return true;
- }
- /// <summary>
- /// 验证交货行输入数据的有效性
- /// </summary>
- /// <returns></returns>
- private bool testOrderCD()// 验证交货行输入数据的有效性
- {
- if (txt_CD_Qty.Value == null)
- {
- MessageUtil.ShowTips("请编制交货行的数量");
- txt_CD_Qty.Focus();
- return false;
- }
- else
- {
- if (!Is_Below_zero(txt_CD_Qty.Value.ToString().Trim()))
- {
- MessageUtil.ShowTips("请编制有效的交货行的数量");
- txt_CD_Qty.Focus();
- return false;
- }
- }
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择合同行");
- return false;
- }
- if (String.IsNullOrEmpty(txt_askDeliveryDateEnd.Text))
- {
- MessageUtil.ShowTips("请输入交货结束时间");
- txt_askDeliveryDateEnd.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txt_askDeliveryDateStart.Text))
- {
- MessageUtil.ShowTips("请输入交货开始时间");
- txt_askDeliveryDateStart.Focus();
- return false;
- }
- if (Convert.ToDateTime(txt_askDeliveryDateStart.Value) >= Convert.ToDateTime(txt_askDeliveryDateEnd.Value))
- {
- MessageUtil.ShowTips("合同交货行的交货结束时间需大于开始时间");
- txt_askDeliveryDateStart.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证合同行的状态有效性
- /// </summary>
- /// <param name="strOrderLineSqe"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testOrderCStatus(string strOrderLineSqe, int p)// 验证合同行的状态有效性
- {
- OrderC oc = this.execute<OrderC>("com.hnshituo.pur.order.service.OrderCService", "findById", new object[] { strOrderLineSqe });
- if (oc == null)
- {
- MessageUtil.ShowTips("无合同行【" + strOrderLineSqe + "】的信息记录,可能已被作废,或请刷新界面重新操作!");
- return false;
- }
- if (oc.Validflag=="0")
- {
- MessageUtil.ShowTips("合同行【" + strOrderLineSqe + "】的信息记录可能已被作废,或请刷新界面重新操作!");
- return false;
- }
- String strOrderId = oc.OrderId;
- //是否允许删除
- if (p == 1)
- {
- if (testOrderMStatus(strOrderId, 1) == false)
- {
- return false;
- }
- OrderCD ordercd = new OrderCD();
- ordercd.OrderLineSqe = strOrderLineSqe;
- ordercd.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCDService", "find", new object[] { ordercd,0,0});
- if (dt != null)
- {
- if (dt.Rows.Count > 0)
- {
- MessageUtil.ShowTips("合同行【" + strOrderLineSqe + "】存在" + dt.Rows.Count + "条有效的合同发货行,请先作废这些合同发货行记录!");
- return false;
- }
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证合同行数据的有效性!");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证合同发货行数据的有效性
- /// </summary>
- /// <param name="strOrderLineDSqe"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testOrderCDStatus(string strOrderLineDSqe, int p)// 验证合同发货行数据的有效性
- {
- OrderCD Ocd = this.execute<OrderCD>("com.hnshituo.pur.order.service.OrderCDService", "findById", new object[] { strOrderLineDSqe });
- if (Ocd == null)
- {
- MessageUtil.ShowTips("无合同发货行【" + strOrderLineDSqe + "】的信息记录,可能已作废,或请刷新界面重新操作!");
- return false;
- }
- if (Ocd.Validflag=="0")
- {
- MessageUtil.ShowTips("合同发货行【" + strOrderLineDSqe + "】的信息记录可能已作废,或请刷新界面重新操作!");
- return false;
- }
- string strStatus = Ocd.Status;
- //是否可以删改
- if (p == 1)
- {
- if (!(strStatus == "0"))
- {
- MessageUtil.ShowTips("已生成发货通知,无法进行删改!");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证合同发货行数据的有效性!");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证合同头的状态有效性
- /// </summary>
- /// <param name="strOrderId"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testOrderMStatus(string strOrderId, int p)// 验证合同头的状态有效性
- {
- OrderM Omg = this.execute<OrderM>("com.hnshituo.pur.order.service.OrderMService", "findById", new object[] { strOrderId });
- if (Omg == null)
- {
- MessageUtil.ShowTips("未发现合同【" + strOrderId + "】的信息记录,可能已作废,或请刷新界面重新操作!");
- return false;
- }
- if (Omg.CreateUserid != UserInfo.GetUserID())
- {
- MessageUtil.ShowWarning("非提报该合同本人,无权限进行增删改操作,或请刷新后再操作!");
- return false;
- }
- String tempStatus = Omg.Status.ToString().Trim();
- //验证合同头是否可以增改
- if (p == 1)
- {
- if (tempStatus != "1" )
- {
- MessageUtil.ShowWarning("合同【" + strOrderId + "】不在“待提报”状态,无法进行增删改操作,请刷新后再操作!");
- return false;
- }
- }
- //验证合同是否可以删除
- else if (p == 2)
- {
- if (tempStatus != "1" || tempStatus != "0")
- {
- MessageUtil.ShowWarning("合同【" + strOrderId + "】不在“待提报”或“草稿”状态,无权限进行增删改操作,请刷新后再操作!");
- return false;
- }
- if (Omg.Status != "0")
- {
- OrderC orderc = new OrderC();
- orderc.OrderId = strOrderId;
- orderc.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCService", "find", new object[] { orderc, 0, 0 });
- if (dt != null)
- {
- if (dt.Rows.Count > 0)
- {
- MessageUtil.ShowTips("合同【" + strOrderId + "】存在" + dt.Rows.Count + "条有效的合同行,请先删除这些合同行!");
- return false;
- }
- }
- }
- }
- //验证是否可以提报
- else if(p==3)
- {
- if ( tempStatus != "1")
- {
- MessageUtil.ShowWarning("合同【" + strOrderId + "】不在“待提报”状态,请刷新后再操作!");
- return false;
- }
- OrderC orderc = new OrderC();
- orderc.OrderId = strOrderId;
- orderc.Validflag = "1";
- List<OrderC> dt = this.execute<List<OrderC>>("com.hnshituo.pur.order.service.OrderCService", "find", new object[] { orderc ,0,0});
- if (dt == null || dt.Count < 1)
- {
- MessageUtil.ShowTips("合同【" + strOrderId + "】无有效的行信息,或请刷新界面重新操作!");
- return false;
- }
- //验证数据的有效性--头有效性
- if (string.IsNullOrEmpty(Omg.Currency))
- {
- MessageUtil.ShowTips("需要完善合同货币类型,该项不能为空!");
- return false;
- }
- if (string.IsNullOrEmpty(Omg.OrderType))
- {
- MessageUtil.ShowTips("需要完善合同类别,该项不能为空!");
- return false;
- }
- if (String.IsNullOrEmpty(Omg.SuppCode))
- {
- MessageUtil.ShowTips("需要完善供方信息,供应商编号不能为空!");
- return false;
- }
- if (String.IsNullOrEmpty(Omg.TaxRateName))
- {
- MessageUtil.ShowTips("需要完善合同税率信息,合同税率不允许为空!");
- return false;
- }
- if (String.IsNullOrEmpty(Omg.ModeId))
- {
- MessageUtil.ShowTips("需要选择合同模板,合同模板不允许为空!");
- return false;
- }
- if (Omg.SignDate==null)
- {
- MessageUtil.ShowTips("需完善合同签订日期,合同签订日期不允许为空");
- txt_SignDate.Focus();
- return false;
- }
- for(int i=0;i<dt.Count;i++)
- {
- OrderC oc=dt[i];
- if (!isRightDoubleWithoutZero(oc.Qty) || string.IsNullOrEmpty(oc.ItemCode))
- {
- MessageUtil.ShowTips("合同行【"+oc.OrderLineSqe+"】的合同数量数,物料未维护,上述项不允许为空!");
- return false;
- }
- if (!isRightDoubleWithZero(oc.PriceWithoutTax) || !isRightDoubleWithZero(oc.PriceWithTax))
- {
- MessageUtil.ShowTips("合同行【"+oc.OrderLineSqe+"】的含税单价和不含税单价未维护,上述项不允许为空!");
- txt_PriceWithoutTax.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(oc.ReceiveType))
- {
- MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的接收方式未维护,上述项不允许为空!");
- return false;
- }
- //if (String.IsNullOrEmpty(oc.DeliveryLocation) || String.IsNullOrEmpty(oc.DeliveryLocationCode))
- //{
- // MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的交付地点和地点编码未维护,上述项不能为空!");
- // return false;
- //}
- if (!isRightDoubleWithoutZero(oc.ItemUomConefficient))
- {
- MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的单位转化系数为空,数据异常!");
- return false;
- }
- if (string.IsNullOrEmpty(oc.ItemUom)||string.IsNullOrEmpty(oc.WeightUnit))
- {
- MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的库存单位和采购单位为空,数据异常!");
- return false;
- }
- //if (oc.StartDate==null)
- //{
- // MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的交货开始时间未维护,上述项不能为空!");
- // return false;
- //}
- if (oc.EndDate==null)
- {
- MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的交货结束时间未维护,上述项不能为空!");
- return false;
- }
- //if (Convert.ToDateTime(oc.StartDate) > Convert.ToDateTime(oc.EndDate))
- //{
- // MessageUtil.ShowTips("合同行【" + oc.OrderLineSqe + "】的交货开始时间不能需早于接收时间,请维护有效的交货时间!");
- // return false;
- //}
- }
- }
- else if (p == 4)
- {
- if (tempStatus!="2")
- {
- MessageUtil.ShowWarning("合同【" + strOrderId + "】未在“审批中”状态,无权限撤回,请刷新后再操作!");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数,无法验证合同头数据的有效性!");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证是否为非负小数
- /// </summary>
- /// <param name="db"></param>
- /// <returns></returns>
- private bool isRightDoubleWithZero(double? db)// 验证是否为非负小数
- {
- if (db == null)
- {
- return false;
- }
- if (db < 0)
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证是否为大于0的正数
- /// </summary>
- /// <param name="db"></param>
- /// <returns></returns>
- private bool isRightDoubleWithoutZero(double? db)// 验证是否为大于0的正数
- {
- if (db == null)
- {
- return false;
- }
- if (db <= 0)
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 查看流程详情
- /// </summary>
- private void Process()//查看流程详情
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择合同头!");
- return;
- }
- String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim();
- ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_ORDER_AUDIT, strOrderId);
- detail.ShowDialog();
- }
- #endregion
- }
- }
|