| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224 |
- 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 System.Diagnostics;
- using System.IO;
- using System.Text.RegularExpressions;
- using CoreFS.CA06;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using System.Net;
- using System.Collections;
- using CoreFS.SA06;
- namespace Core.StlMes.Client.BuyBillet
- {
- public partial class FrmCGpRk : FrmBase
- {
- private string ord_no_pk;
- private string gpreq_id;
- private string stove_no;
- private string judge_stove_no;
- private string car_no;
- public FrmCGpRk()
- {
- InitializeComponent();
- }
- private void FrmCGpRk_Load(object sender, System.EventArgs e)
- {
- Initial_rukuData();
- Bind_Supplier();
- ds_rukuinfo.Tables[0].AcceptChanges();
- var ids = this.ValidDataPurviewIds;
- Bind_Stock();
- Bind_Level();
- ForbidSort(this.ug_rukinfo);
- this.ultraCheckEditor2.Visible = false;
- this.cb_supplier_cd.Visible = false;
- setTpcoTH();
- }
- private void Initial_rukuData()
- {
- for(int i=0;i<7;i++)
- {
- DataRow row = ds_rukuinfo.Tables[0].NewRow();
- row["倍尺"] = i + 1;
- ds_rukuinfo.Tables[0].Rows.Add(row);
- }
- }
- private void setToolBarAppearance(DefaultableBoolean appearance0, DefaultableBoolean appearance1, DefaultableBoolean appearance2)
- {
- if (toolMenu == null)
- {
- return;
- }
- string toolBarItem = string.Empty;
- toolBarItem = "doSave";
- if (toolMenu.Toolbars[0].Tools.Exists(toolBarItem))
- {
- toolMenu.Toolbars[0].Tools[toolBarItem].InstanceProps.Visible = appearance0;
- }
- toolBarItem = "doDelete";
- if (toolMenu.Toolbars[0].Tools.Exists(toolBarItem))
- {
- toolMenu.Toolbars[0].Tools[toolBarItem].InstanceProps.Visible = appearance1;
- }
- toolBarItem = "doJQCancel";
- if (toolMenu.Toolbars[0].Tools.Exists(toolBarItem))
- {
- toolMenu.Toolbars[0].Tools[toolBarItem].InstanceProps.Visible = appearance2;
- }
- toolBarItem = "doJQ";
- if (toolMenu.Toolbars[0].Tools.Exists(toolBarItem))
- {
- toolMenu.Toolbars[0].Tools[toolBarItem].InstanceProps.Visible = appearance2;
- }
- }
- private void tabC_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (tabC.ActiveTab.Key == "tab1")
- {
- setToolBarAppearance(DefaultableBoolean.True, DefaultableBoolean.False, DefaultableBoolean.False);
- }
-
- if (tabC.ActiveTab.Key == "tab2")
- {
- setToolBarAppearance(DefaultableBoolean.False, DefaultableBoolean.True, DefaultableBoolean.False);
- }
- if (tabC.ActiveTab.Key == "tab3")
- {
- setToolBarAppearance(DefaultableBoolean.False, DefaultableBoolean.False, DefaultableBoolean.True);
- }
- }
- private void doSave1(){
- ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.test071211", new object[] { }, this.ob);
- return;
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Close":
- this.Close();
- break;
- case "doQuery":
- doQuery();
- break;
- case "doSave":
- //doSave1();
- //return;
- if (!Query_Jielu())
- {
- doSave();
- }
- else
- {
- MessageUtil.ShowTips("此判定炉号已结炉!");
- }
- break;
- case "doDelete":
- doChedan();
- break;
- case "doJQ":
- doJQ();
- break;
- case "doJQCancel":
- doJQCancel();
- break;
- }
- }
- /// <summary>
- /// 撤销交齐
- /// </summary>
- private void doJQCancel()
- {
- //ArrayList list = new ArrayList();
- //list.Add("a");
- //list.Add("b");
- //list.Add("c");
- ////ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.test171224", new object[] { list }, this.ob);
- //List<MatGpModelEntity> matgpList = EntityHelper.GetData<MatGpModelEntity>
- // ("com.steering.pss.buybillet.Buybillet.test171224", new object[] { list }, this.ob);
- //return;
- UltraGridRow row = ug_wgpstockinfo.ActiveRow;
- if (row == null)
- return;
- string judge_apply_code = row.Cells["jugde_apply_code"].Value.ToString();
- string judge_stove_no_no = row.Cells["judge_stove_no"].Value.ToString();
- if (!string.IsNullOrEmpty(judge_apply_code))
- {
- MessageUtil.ShowTips("已申请判定,不能撤销结炉!");
- return;
- }
- string isJielu = row.Cells["node_fur_flag"].Value.ToString();
- if (isJielu == "否")
- {
- MessageUtil.ShowTips("未结炉,不需要撤销!");
- return;
- }
- string stockname = cb_stock_jl.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_JIELUINFO", new object[] { judge_stove_no_no }, this.ob);
-
- ArrayList arr = new ArrayList();
- bool hasStock = false;
- bool hasJudgeApply = false;
- foreach(DataRow dtrow in dt.Rows)
- {
- ArrayList arr1 = new ArrayList();
- string tempstock = dtrow["storage_name"].ToString();
- string temp_judge_apply_code = dtrow["jugde_apply_code"].ToString();
- string gpreq_id = dtrow["gpreq_id"].ToString();
- if(!string.IsNullOrEmpty(gpreq_id) && !arr1.Contains(gpreq_id))
- {
- arr1.Add(gpreq_id);
- arr1.Add(judge_stove_no_no);
- arr1.Add("");
- arr.Add(arr1);
- }
- if (tempstock == stockname)
- hasStock = true;
- if (!string.IsNullOrEmpty(temp_judge_apply_code))
- hasJudgeApply = true;
- }
- string message = string.Empty;
- if(!hasStock)
- {
- message += "本仓库无库存,不能退结炉.\n";
- }
- if (hasJudgeApply)
- {
- message += "已经申请判定,不能退结炉.\n";
- }
- if (!string.IsNullOrEmpty(message))
- {
- MessageUtil.ShowTips(message);
- return;
- }
- if (MessageUtil.ShowYesNoAndTips("确认撤销:" + judge_stove_no_no + " 结炉?") == DialogResult.No)
- {
- return;
- }
- if (arr.Count > 0)
- {
- //调用取消虚拟炉计划
- CoreClientParam ccp = new CoreClientParam();
- string create_name = this.UserInfo.GetUserName();
- ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace";
- ccp.MethodName = "deletePlnOutsourc";
- ccp.ServerParams = new object[] { arr, create_name };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
-
- if (ccp.ReturnInfo!="成功")
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- return;
- }
- }
- //以下进行实际退结炉操作
- ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.deleteMatGpMStocksJielu", new object[] { judge_stove_no_no }, this.ob);
- Query_wgpStockinfo();
- MessageUtil.ShowTips("撤销成功!");
-
- }
- /// <summary>
- /// 交齐(库存标注交齐使用)
- /// </summary>
- private void doJQ()
- {
- UltraGridRow row = ug_wgpstockinfo.ActiveRow;
- if (row == null)
- return;
-
- string judge_stove_no_no = row.Cells["judge_stove_no"].Value.ToString();
- string isJielu = row.Cells["node_fur_flag"].Value.ToString();
- if (isJielu == "是")
- {
- MessageUtil.ShowTips("已结炉,不需要再次结炉!");
- return;
- }
- string stockname = cb_stock_jl.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_JIELUINFO", new object[] { judge_stove_no_no }, this.ob);
- ArrayList arr = new ArrayList();
- bool hasStock = false;
- foreach (DataRow dtrow in dt.Rows)
- {
- ArrayList arr1 = new ArrayList();
- string tempstock = dtrow["storage_name"].ToString();
- string temp_judge_apply_code = dtrow["jugde_apply_code"].ToString();
- string gpreq_id = dtrow["gpreq_id"].ToString();
- if (!string.IsNullOrEmpty(gpreq_id) && !arr1.Contains(gpreq_id))
- {
- arr1.Add(gpreq_id);
- arr1.Add(judge_stove_no_no);
- arr.Add(arr1);
- }
- if (tempstock == stockname)
- hasStock = true;
- }
- string message = string.Empty;
- if (!hasStock)
- {
- message += "本仓库无库存,不能在此结炉.\n";
- }
- if (!string.IsNullOrEmpty(message))
- {
- MessageUtil.ShowTips(message);
- return;
- }
- if (MessageUtil.ShowYesNoAndTips("确认:" + judge_stove_no_no + " 结炉?") == DialogResult.No)
- {
- return;
- }
- //以下调用虚拟炉计划(结炉时调用)
- if (true)
- {
- CoreClientParam ccp = new CoreClientParam();
- string create_name = this.UserInfo.GetUserName();
- ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace";
- ccp.MethodName = "queryPlnOutsourc";
- ccp.ServerParams = new object[] { "", judge_stove_no_no, create_name };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- //以下进行实际结炉操作
- ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.updateMatGpMStocksJielu", new object[] { judge_stove_no_no }, this.ob);
- Query_wgpStockinfo();
- MessageUtil.ShowTips("结炉成功!");
- }
- /// <summary>
- /// 撤单
- /// </summary>
- private void doChedan()
- {
- //UltraGridRow row = ug_rkinfo_p.ActiveRow;
- //string instock_doc = row.GetValue("INSTOCK_DOC");
- StringBuilder sb = new StringBuilder();
- StringBuilder sb1 = new StringBuilder();
- ArrayList arr = new ArrayList();
- int resultCount = 0;
- foreach (UltraGridRow row in ug_rkinfo_p.Rows)
- {
- ArrayList arr1 = new ArrayList();
- if (row.Cells["CHK"].Text.ToString() == "True")
- {
- //sb.Append(row.Cells["INSTOCK_DOC"].Value.ToString());
- //sb.Append(",");
- string instock_doc = row.Cells["INSTOCK_DOC"].Value.ToString();
- string gpreq_id = row.Cells["GPREQ_ID"].Value.ToString();
- string judge_stove_no = row.Cells["JUDGE_STOVE_NO"].Value.ToString();
- arr1.Add(gpreq_id);
- arr1.Add(judge_stove_no);
- arr1.Add(instock_doc);
- arr.Add(arr1);
- sb.Append(instock_doc);
- sb.Append(",");
- sb1.Append(judge_stove_no);
- sb1.Append(",");
- resultCount++;
- }
- }
- string ids = sb.ToString();
- if (ids.EndsWith(","))
- {
- ids = ids.Substring(0, ids.Length - 1);
- }
- string ids1 = sb1.ToString();
- if (ids1.EndsWith(","))
- {
- ids1 = ids1.Substring(0, ids1.Length - 1);
- }
- if (string.IsNullOrEmpty(ids))
- {
- MessageBox.Show("未选中有效的记录!");
- return;
- }
- if(MessageUtil.ShowYesNoAndTips("确认撤销:"+resultCount+"条记录")== DialogResult.No){
- return;
- }
- //调用取消虚拟炉计划
- CoreClientParam ccp = new CoreClientParam();
- string create_name = this.UserInfo.GetUserName();
- ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace";
- ccp.MethodName = "deletePlnOutsourc";
- ccp.ServerParams = new object[] { arr, create_name };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnInfo != "成功")
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- return;
- }
- string stockcode = cb_stock_cd.Value.ToString();
- ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.delete_CGP_Stock_CHEDAN_New", new object[] { ids, stockcode,ids1 }, this.ob);
-
- Query_wgpKucun();
- ds_rkinfo_c.Tables[0].Rows.Clear();
- MessageUtil.ShowTips("操作完成!");
- }
- //查询(共用)
- private void doQuery()
- {
- if(tabC.ActiveTab.Key=="tab1")
- {
- Query_wgpOrders();
- }
- if (tabC.ActiveTab.Key == "tab2")
- {
- Query_wgpKucun();
- }
- if (tabC.ActiveTab.Key == "tab3")
- {
- Query_wgpStockinfo();
- }
- }
- private string queryIsRKinfoOk()
- {
- string resultMessage = string.Empty;
- UltraGridRow row = ug_orders.ActiveRow;
- if (row == null)
- return "未选中有效合同";
-
- string dbpc = row.GetValue("单倍坯长");
- string dm = row.GetValue("断面");
- string gz = row.GetValue("钢种");
- CoreClientParam ccp = new CoreClientParam();
-
- ccp.ServerName = "com.steering.pss.buybillet.Buybillet";
- ccp.MethodName = "queryRkinfo";
- ccp.ServerParams = new object[] { judge_stove_no, dm, dbpc, gz };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- resultMessage = ccp.ReturnInfo;
- //if (ccp.ReturnCode != -1)
- //{
- // if (ccp.ReturnInfo.Equals("保存成功!"))
- // {
- // }
- // else
- // {
- // MessageUtil.ShowTips(ccp.ReturnInfo);
- // }
- //}
- return resultMessage;
- }
- //入库操作
- private void doSave()
- {
- bool zdzl = true;
- get_stove_no();
- stove_no = stove_no.Trim();
- judge_stove_no = judge_stove_no.Trim();
- stove_no = stove_no.Replace(" ", "");
- judge_stove_no = judge_stove_no.Replace(" ", "");
- string departmentid = this.UserInfo.GetDeptid();
- string deptId = this.UserInfo.GetDeptid();
- if (string.IsNullOrEmpty(stove_no))
- {
- MessageUtil.ShowTips("炉号不能为空!");
- return;
- }
- if (string.IsNullOrEmpty(judge_stove_no) && !deptId.StartsWith("002023"))
- {
- MessageUtil.ShowTips("判定炉号不能为空!");
- return;
- }
- if (!Regex.Match(stove_no, "^\\d+$").Success && !deptId.StartsWith("002023"))
- {
- MessageUtil.ShowTips("炉号含有非数字字符!");
- return;
- }
- if (!Regex.Match(judge_stove_no, "^\\d+$").Success && !deptId.StartsWith("002023"))
- {
- MessageUtil.ShowTips("判定炉号含有非数字字符!");
- return;
- }
- judge_stove_no = stove_no;
- if (stove_no != judge_stove_no)
- {
- MessageUtil.ShowTips("炉号和判定炉号不相等,不能保存!");
- return;
- }
- string locationtemp = txt_location.Text.Trim();
- locationtemp += "AAA";
- if (string.IsNullOrEmpty(locationtemp))
- {
- MessageUtil.ShowTips("库位不能为空!");
- return;
- }
- string ischongfu = queryIsRKinfoOk();
- if(!string.IsNullOrEmpty(ischongfu))
- {
- MessageUtil.ShowTips(ischongfu);
- return;
- }
- string isJielu = "0";
- if (ck_jielu.Checked && MessageUtil.ShowYesNoAndQuestion("是否确认结炉?") == DialogResult.No)
- {
- return;
- }
- if (ck_jielu.Checked)
- {
- isJielu = "1";
- }
- this.ug_rukinfo.UpdateData();
-
- String username = this.UserInfo.GetUserName();
- String stockname = cb_stock.Text;
- String location = txt_location.Text.Trim();
- String level = cb_level.Text;
- ArrayList parm = new ArrayList();
- DataTable dt = this.ds_rukuinfo.Tables[0].GetChanges(DataRowState.Modified);
- if(dt == null)
- {
- return;
- }
- if (dt.GetChanges(DataRowState.Modified) == null)
- {
- MessageBox.Show("没有修改的数据!");
- }
- else
- {
- var rs = from rows in dt.AsEnumerable()
- where rows.RowState == DataRowState.Modified
- select rows;
- foreach (var row in rs)
- {
- string bc = row["倍尺"].ToString();
- int count = 0;
- int.TryParse(row["支数"].ToString(), out count);
- decimal weight = 0;
- decimal.TryParse(row["重量"].ToString(), out weight);
- int gplength = 0;
- int.TryParse(row["管坯长度"].ToString(), out gplength);
- string message = bc + "倍尺 :";
- if (count == 0)
- {
- message += " 支数不正确;";
- }
- if (weight == 0)
- {
- message += " 重量不正确;";
- }
- if (gplength == 0)
- {
- message += " 管坯长度不正确;";
- }
- if (count == 0 && weight == 0)
- {
- continue;
- }
- if (count == 0 || weight == 0)
- {
- MessageUtil.ShowTips(message);
- return;
- }
- string str = string.Empty;
- str += "bc:";
- str += row["倍尺"].ToString();
- str += ";";
- str += "count:";
- str += row["支数"].ToString();
- str += ";";
- str += "weight:";
- str += row["重量"].ToString();
- str += ";";
- str += "gplength:";
- str += row["管坯长度"].ToString();
- str += ";";
- parm.Add(str);
- if (deptId.StartsWith("002023") && row["管坯长度"].ToString() != row["管坯理论长度"].ToString())
- {
- zdzl = false;
- }
-
- }
- if (parm.Count == 0)
- {
- return;
- }
-
- //天淮deptid,如果是天淮,首先获取最大炉号
- if (deptId.StartsWith("002023"))
- {
- DataTable dtJudge_stove_no = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_TH_GP_JUDGE_STOVE_NO", new object[] { }, this.ob);
- if (dtJudge_stove_no != null && dtJudge_stove_no.Rows.Count > 0)
- {
- judge_stove_no = dtJudge_stove_no.Rows[0][0].ToString();
- }
- }
- ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.do_CGP_RK", new object[] { ord_no_pk,stove_no,judge_stove_no,car_no,departmentid,parm,username,stockname,location,level,isJielu }, this.ob);
- //foreach (var row in rs)
- //{
- // string bc = row["倍尺"].ToString();
- // string count = row["支数"].ToString();
- // CoreClientParam ccp = new CoreClientParam();
- // ccp.ServerName = "com.steering.pss.buybillet.Buybillet";
- // ccp.MethodName = "update_RKZL";
- // ccp.ServerParams = new object[] { ord_no_pk, stove_no };
- // ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
- // if(ccp.ReturnCode.Equals(1))
- // {
- // MessageUtil.ShowTips("操作成功!");
- // }
- //}
- UltraGridRow rowOrder = ug_orders.ActiveRow;
- String type = "1";
- if (rowOrder != null)
- {
- String gptype = rowOrder.Cells["管坯类型"].Value.ToString();
- if (gptype == "锻坯")
- type = "0";
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.buybillet.Buybillet";
- ccp.MethodName = "update_RKZL";
- ccp.ServerParams = new object[] { ord_no_pk, stove_no, judge_stove_no,type };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- //if (ccp.ReturnCode.Equals(1))
- //{
- // MessageUtil.ShowTips("操作成功!");
- //}
- //ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.update_RKZL", new object[] { ord_no_pk, stove_no, judge_stove_no }, this.ob);
- //以下调用虚拟炉计划(结炉时调用)
- if (ck_jielu.Checked && zdzl)
- {
- string create_name = this.UserInfo.GetUserName();
- ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace";
- ccp.MethodName = "queryPlnOutsourc";
- ccp.ServerParams = new object[] { gpreq_id, judge_stove_no, create_name };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- MessageUtil.ShowTips("操作成功!");
- this.ug_rukinfo.UpdateData();
- foreach(DataRow row in this.ds_rukuinfo.Tables[0].Rows)
- {
- row["支数"] = DBNull.Value;
- row["重量"] = DBNull.Value;
- row["理论重量"] = DBNull.Value;
- row["管坯理论重量"] = DBNull.Value;
- }
- ds_rukuinfo.Tables[0].AcceptChanges();
- txt_carno.Focus();
- txt_stove_no.Text = string.Empty;
- txt_judge_stove_no.Text = string.Empty;
- }
- }
- /// <summary>
- /// 查询外购坯合同
- /// </summary>
- private void Query_wgpOrders()
- {
- //ds_orders
- string supplier = "";
- string orderno = "";
- if (ck_supplier.Checked)
- {
- supplier = cb_supplier.Text;
- }
- if(ck_orderno.Checked)
- {
- orderno = txt_orderno.Text.Trim();
- }
- string deptId = this.UserInfo.GetDeptid();
- DataTable dt = new DataTable();
- //天淮deptid
- if (deptId.StartsWith("002023"))
- {
- dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_RK_OrdersTH", new object[] { supplier, orderno }, this.ob);
- }
- else
- {
- dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_RK_Orders", new object[] { supplier, orderno }, this.ob);
- }
- GridHelper.CopyDataToDatatable(dt,ds_orders.Tables[0], true);
- RefreshAndAutoSize(ug_orders);
- }
- /// <summary>
- /// 查询入库清单(撤单用)
- /// </summary>
- private void Query_wgpKucun()
- {
- //查询条件仓库编码
- string stockcode = cb_stock_cd.Value.ToString();
- string orderno = "";
- string judge_stove_no = "";
- if(ultraCheckEditor1.Checked)
- {
- orderno = txt_orderno_cd.Text.Trim();
- }
- if (ultraCheckEditor3.Checked)
- {
- judge_stove_no = this.txt_stove_judgeno_cd.Text.Trim();
-
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_CHEDAN", new object[] { stockcode, orderno, judge_stove_no }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_rkinfo_p.Tables[0], true);
- RefreshAndAutoSize(ug_rkinfo_p);
- }
- /// <summary>
- /// 查询外购坯到厂预报
- /// </summary>
- private void Query_wgpDcyb(string ord_no_pk)
- {
- //ds_dcyb = ???
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Orders_Dcyb", new object[] { ord_no_pk }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_dcyb.Tables[0], true);
- }
- //绑定供应商
- private void Bind_Supplier()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.queryBUY_BASE_CUSTOMER", new object[] { }, this.ob);
- DataTable _dt = new DataTable();
- _dt.Columns.Add("SUPPLIER", typeof(string));
- var _rows = dt.AsEnumerable().OrderBy(r => r.Field<string>("CUSTOMER_NO"));
- foreach (var row in _rows)
- {
- if(row["CUSTOMER_NM"].ToString()=="全部")
- {
- continue;
- }
- DataRow _row = _dt.NewRow();
- _row["SUPPLIER"] = row["CUSTOMER_NM"];
- _dt.Rows.Add(_row);
- }
- this.cb_supplier.DataSource = _dt;
- this.cb_supplier_cd.DataSource = _dt;
-
-
- }
- /// <summary>
- /// 绑定仓库
- /// </summary>
- private void Bind_Stock()
- {
- var departments = this.ValidDataPurviewIds;
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock", new object[] { departments }, this.ob);
- if (dt.Rows.Count > 0)
- {
- cb_stock.DataSource = dt;
- cb_stock.DisplayMember = "storage_name";
- cb_stock.ValueMember = "storage_no";
- cb_stock.SelectedIndex = 0;
- cb_stock_cd.DataSource = dt;
- cb_stock_cd.DisplayMember = "storage_name";
- cb_stock_cd.ValueMember = "storage_no";
- cb_stock_cd.SelectedIndex = 0;
- cb_stock_jl.DataSource = dt;
- cb_stock_jl.DisplayMember = "storage_name";
- cb_stock_jl.ValueMember = "storage_no";
- cb_stock_jl.SelectedIndex = 0;
- }
- }
- /// <summary>
- /// 绑定层数
- /// </summary>
- private void Bind_Level()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_RK_Level", new object[] { }, this.ob);
- cb_level.DataSource = dt;
- cb_level.SelectedIndex = 0;
- }
- private void ck_orderno_CheckedChanged(object sender, System.EventArgs e)
- {
- if (ck_orderno.Checked)
- {
- txt_orderno.Enabled = true;
- }
- else
- {
- txt_orderno.Enabled = false;
- }
- }
- /// <summary>
- /// 选择行,查询到厂预报
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ug_orders_ClickCell(object sender, ClickCellEventArgs e)
- {
- bind_ug_orders();
- }
- private void ug_orders_Click(object sender, EventArgs e)
- {
- bind_ug_orders();
- }
- private void bind_ug_orders()
- {
- UltraGridRow row = ug_orders.ActiveRow;
- if (row == null)
- return;
- ord_no_pk = row.GetValue("ORD_NO_PK");
- gpreq_id = row.GetValue("GPBUYPLANID");
- Query_wgpDcyb(ord_no_pk);
- string dbpc = row.GetValue("单倍坯长");
- Bind_GpLengthTo_ugrkinfo(dbpc);
- }
- private void Bind_GpLengthTo_ugrkinfo(string db_pc)
- {
- int dbpc = int.Parse(db_pc);
- foreach (DataRow row in ds_rukuinfo.Tables[0].Rows)
- {
- row["管坯长度"] = Convert.ToInt32(row["倍尺"]) * dbpc;
- row["管坯理论长度"] = Convert.ToInt32(row["倍尺"]) * dbpc;
- }
-
- }
- private void ck_sglcode_CheckedChanged(object sender, System.EventArgs e)
- {
- txt_stove_no.Text = string.Empty;
- txt_judge_stove_no.Text = string.Empty;
- if(ck_sglcode.Checked)
- {
- txt_stove_no.Enabled = true;
- txt_judge_stove_no.Enabled = true;
- }
- else
- {
- txt_stove_no.Enabled = false;
- txt_judge_stove_no.Enabled = false;
- }
- }
- /// <summary>
- /// 获取炉号以及判定炉号
- /// </summary>
- private void get_stove_no()
- {
- UltraGridRow row = ug_dcyb.ActiveRow;
- if(row != null)
- {
- stove_no = row.Cells["炉号"].Value.ToString();
- judge_stove_no = row.Cells["判定炉号"].Value.ToString();
- }
- if(ck_sglcode.Checked)
- {
- stove_no = txt_stove_no.Text.Trim();
- judge_stove_no = txt_judge_stove_no.Text.Trim();
- }
- car_no = txt_carno.Text.Trim();
- }
- private void cb_stock_SelectionChanged(object sender, System.EventArgs e)
- {
- string stockname = cb_stock.Text;
- Bind_location(stockname);
- }
- private void Bind_location(string stockname)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_Location", new object[] {stockname}, this.ob);
- if (dt.Rows.Count > 0)
- {
- cb_location.DataSource = dt;
- cb_location.DisplayMember = "LOCATION_NAME";
- cb_location.ValueMember = "LOCATION_NAME";
- cb_location.SelectedIndex = 0;
- txt_location.Text = dt.Rows[0]["LOCATION_NAME"].ToString();
- }
- }
- private bool Query_Jielu()
- {
-
- get_stove_no();
- if(string.IsNullOrEmpty(ord_no_pk) || string.IsNullOrEmpty(judge_stove_no))
- {
- return false;
- }
- bool flag = false;
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_RK_JIELU", new object[] { ord_no_pk, judge_stove_no }, this.ob);
- if(int.Parse(dt.Rows[0][0].ToString())>0)
- {
- flag = true;
- }
- return flag;
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- /// <summary>
- /// 查询详细信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ug_rkinfo_p_ClickCell(object sender, ClickCellEventArgs e)
- {
- UltraGridRow row = ug_rkinfo_p.ActiveRow;
- if (row == null)
- return;
- string instock_doc = row.GetValue("INSTOCK_DOC");
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_CHEDAN_DETAILS", new object[] { instock_doc }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_rkinfo_c.Tables[0], true);
- RefreshAndAutoSize(ug_rkinfo_c);
- SetStaticsInfocd();
- }
- private void ug_rkinfo_p_Click(object sender, EventArgs e)
- {
- UltraGridRow row = ug_rkinfo_p.ActiveRow;
- if (row == null)
- return;
- string instock_doc = row.GetValue("INSTOCK_DOC");
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_CHEDAN_DETAILS", new object[] { instock_doc }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_rkinfo_c.Tables[0], true);
- RefreshAndAutoSize(ug_rkinfo_c);
- SetStaticsInfocd();
- }
- private void FrmCGpRk_Shown(object sender, EventArgs e)
- {
- setToolBarAppearance(DefaultableBoolean.True, DefaultableBoolean.False, DefaultableBoolean.False);
- RefreshAndAutoSize(ug_orders);
- RefreshAndAutoSize(ug_dcyb);
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckEditor1.Checked)
- {
- txt_orderno_cd.Enabled = true;
- }
- else
- {
- txt_orderno_cd.Enabled = false;
- }
- }
- private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckEditor3.Checked)
- {
- txt_stove_judgeno_cd.Enabled = true;
- }
- else
- {
- txt_stove_judgeno_cd.Enabled = false;
- }
- }
- private void ug_rkinfo_p_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ug_rkinfo_p.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHK"].Value = true;
- }
- }
- }
- /// <summary>
- /// 禁止排序
- /// </summary>
- /// <param name="ugr"></param>
- public void ForbidSort(UltraGrid ugr)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- ugc.SortIndicator = SortIndicator.Disabled;
- ugc.AllowRowFiltering = DefaultableBoolean.False;
- }
- }
- private void ug_rkinfo_p_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow row = ug_rkinfo_p.ActiveRow;
- string instock_doc = row.GetValue("INSTOCK_DOC");
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_CHEDAN_DETAILS", new object[] { instock_doc }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_rkinfo_c.Tables[0], true);
- RefreshAndAutoSize(ug_rkinfo_c);
- SetStaticsInfocd();
- }
- private void ug_orders_AfterRowActivate(object sender, EventArgs e)
- {
- bind_ug_orders();
-
- }
- private void txt_location_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- string stockname = cb_stock.Text;
- StockLocationPopup frm = new StockLocationPopup(this.ob);
- frm.StockName = stockname;
- frm.StartPosition = FormStartPosition.CenterScreen;
- frm.Show();
- frm.onSelected += frm_onSelected;
-
- }
- private void frm_onSelected(string location)
- {
- txt_location.Text = location;
- }
- private void Query_wgpStockinfo()
- {
- string judge_stove_no = txt_judge_stoveno_jl.Text.Trim();
- string stockcode = cb_stock_jl.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_CGP_Stock_INFO", new object[] { stockcode, judge_stove_no }, this.ob);
- GridHelper.CopyDataToDatatable(dt, ds_stockinfo_qry.Tables[0], true);
- RefreshAndAutoSize(ug_wgpstockinfo);
- }
- private void btn_cancelJieLu_Click_1(object sender, EventArgs e)
- {
- UltraGridRow row = ug_wgpstockinfo.ActiveRow;
- if (row == null)
- return;
- string judge_apply_code = row.Cells["jugde_apply_code"].Value.ToString();
- if(!string.IsNullOrEmpty(judge_apply_code))
- {
- MessageUtil.ShowTips("已申请判定,不能撤销结炉!");
- return;
- }
- string isJielu = row.Cells["node_fur_flag"].Value.ToString();
- if (isJielu=="否")
- {
- MessageUtil.ShowTips("未结炉,不需要撤销!");
- return;
- }
- MessageUtil.ShowTips("撤销成功!");
- }
- private void ug_rukinfo_AfterCellUpdate(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key == "支数" || e.Cell.Column.Key == "管坯长度")
- {
- UltraGridRow row = e.Cell.Row;
- calculate_ug_rukinfo_theoryweight(row);
- }
- }
- private void calculate_ug_rukinfo_theoryweight(UltraGridRow _row)
- {
- object value = _row.GetValue("支数");
- string gplength = _row.GetValue("管坯长度");
- string gplengthll = _row.GetValue("管坯理论长度");
- if (value == null)
- return;
- int quantity;
- if (Int32.TryParse(value.ToString(), out quantity) && quantity > 0)
- {
- UltraGridRow row = ug_orders.ActiveRow;
- if (row == null)
- return;
- string diam = row.GetValue("断面");
- double d = double.Parse(diam) / 1000;
- double weight = quantity * (d * d / 4) * 3.1415 * 7.8 * double.Parse(gplength) / 1000;
- double weightll = quantity * (d * d / 4) * 3.1415 * 7.8 * double.Parse(gplengthll) / 1000;
- _row.SetValue("理论重量", Math.Round(weight, 3).ToString());
- _row.SetValue("管坯理论重量", Math.Round(weightll, 3).ToString());
- }
- else
- {
- _row.Cells["理论重量"].Value = DBNull.Value;
- _row.Cells["管坯理论重量"].Value = DBNull.Value;
- _row.Cells["重量"].Value = DBNull.Value;
- }
- SetStaticsInfo();
- }
- private void SetStaticsInfo()
- {
- try
- {
- if (this.ug_rukinfo.Rows.Count == 0)
- {
- this.ug_rukinfo.DisplayLayout.Bands[0].Summaries.Clear();
- }
- else
- {
- ArrayList alist = new ArrayList();
- //废钢
- alist.Add("支数");
- alist.Add("理论重量");
- alist.Add("重量");
- SetStaticsInfoSum(ref this.ug_rukinfo, alist, true);
- }
- }
- catch { }
- }
- private void SetStaticsInfocd()
- {
- try
- {
- if (this.ug_rkinfo_c.Rows.Count == 0)
- {
- this.ug_rkinfo_c.DisplayLayout.Bands[0].Summaries.Clear();
- }
- else
- {
- ArrayList alist = new ArrayList();
- //废钢
- alist.Add("支数");
- alist.Add("重量");
- SetStaticsInfoSum(ref this.ug_rkinfo_c, alist, true);
- }
- }
- catch { }
- }
- public void SetStaticsInfoSum(ref UltraGrid myGrid1, ArrayList alistColumns, bool clearExists)
- {
- try
- {
- UltraGridBand band = myGrid1.DisplayLayout.Bands[0];
- if (clearExists)
- band.Summaries.Clear();
- band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
- for (int i = 0; i < alistColumns.Count; i++)
- {
- try
- {
- SummarySettings summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- if (alistColumns[i].ToString().Contains("COUNT") || alistColumns[i].ToString().Contains("支数"))
- {
- summary.DisplayFormat = "{0:N0}";
- }
- else
- {
- summary.DisplayFormat = "{0:N3}";
- }
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- summary.Lines = 3;
- }
- catch { }
- }
- //band.Summaries.Add("Summary1", SummaryType.Count, band.Columns["GTLRATEYLG"]);
- //band.Summaries["Summary1"].Formula ="sum([FGSTYLG])*100/sum([MATERIALOUTYLG])";
- }
- catch { }
- }
- /// <summary>
- /// 设置tpco 天淮 是否可以修改长度及隐藏 参考列
- /// </summary>
- public void setTpcoTH()
- {
- string deptId = this.UserInfo.GetDeptid();
- if (deptId.StartsWith("002023"))
- {
- ug_rukinfo.DisplayLayout.Bands[0].Columns["管坯长度"].CellActivation = Activation.AllowEdit;
- this.ck_sglcode.Checked = true;
- this.ck_jielu.Checked = false;
- }
- ug_rukinfo.DisplayLayout.Bands[0].Columns["管坯理论长度"].Hidden = true;
- ug_rukinfo.DisplayLayout.Bands[0].Columns["管坯理论重量"].Hidden = true;
- }
- }
- }
|