| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Core.StlMes.Client.YdmPipeManage.Controls;
- using System.Collections;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using Core.StlMes.Client.YdmPipeManage.Tool;
- using com.steering.pss.ydm.entity;
- namespace Core.StlMes.Client.YdmPipeManage
- {
- public partial class frmPipeInventoryOut : FrmBase
- {
- private string errMessage = "";
- public frmPipeInventoryOut()
- {
- InitializeComponent();
- }
- private void frmPipeInventoryOut_Load(object sender, EventArgs e)
- {
- RegStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
- RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(1).AddSeconds(-1);
- BaseMethod.InitStorage(cmbStorage, CustomInfo, this.ValidDataPurviewIds, this.ob);
- EntityHelper.ShowGridCaption<YdmZcStocktakinglistEntity>(ultraGridOut.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<MatZcMEntity>(ultraGridManagement.DisplayLayout.Bands[0]);
- BaseMethod.InitReason(cmbRsn, this.ob);
- //BaseMethod.setOtherColumnReadOnly(ultraGridOut, new string[] { "Chc" });
- BaseMethod.setOtherColumnReadOnly(ultraGridManagement, new string[] { "" });
- BaseMethod.InitCellPosition(ultraGridOut, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater" });
- ultraGridOut.DisplayLayout.Bands[0].Columns["StocktakingRsnName"].Header.Caption = "盘亏原因";
- InitStaus();
- }
- private void InitStaus()
- {
- //材料状态
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150101", "材料产出等待");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150102", "材料管理封锁");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150103", "材料质量封锁");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150104", "材料可编计划");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150105", "材料已编计划");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150106", "材料为余材");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150201", "材料产出等待(未综合判定)");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150202", "材料产出(已综合判定");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150203", "材料为余材(已综合判定)");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150204", "材料脱单余材(销售组织脱单)");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150301", "材料可编提单");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150302", "材料已编提单");
- this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150303", "销售出厂");
- //材料类别
- this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801401", "在制品");
- this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801402", "成品");
- this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801403", "商品");
- //封锁标识
- this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("0", "未封锁");
- this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("1", "管理封锁");
- this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("2", "质量封锁");
- this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("3", "管理质量双封锁");
- //DataTable ds = ClsLoad.GetValueListDataTable("8014", this.ob);
- //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["ProductFlag"].ValueList = ClsLoad.GeneralValuelist(ref ds, "BASECODE", "BASENAME");
- //string[] arr = new string[3] { "801501", "801502", "801503" };
- //DataTable dt = ClsLoad.GetValueListDataTable(arr, this.ob);
- //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["MatStatus"].ValueList = ClsLoad.GeneralValuelist(ref dt, "BASECODE", "BASENAME");
- //DataTable dd = ClsLoad.GetValueListDataTable(this.ob);
- //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["lockFlag"].ValueList = ClsLoad.GeneralValuelist(ref dd, "LOCK_FLAG", "FLAG");
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- DoQueryMangement();
- break;
- case"Query1":
- DoQueryOut();
- break;
- case "Delete":
- DoDelete();
- break;
- case "updateYear":
- updateYear();
- break;
- case"Read":
- readCard();
- break;
- case "Export":
- GridHelper.ulGridToExcel(ultraGridOut, "盘亏实绩");
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 读卡
- /// </summary>
- private void readCard()
- {
-
- }
- /// <summary>
- /// 修改结转年月
- /// </summary>
- private void updateYear()
- {
- this.ultraGridOut.UpdateData();
- ArrayList list = new ArrayList();
- ArrayList parm = new ArrayList();
- UltraGridRow uRow = this.ultraGridOut.ActiveRow;
- string yearMoth = uRow.Cells["balYearMonth"].Text.Substring(0, 4) + uRow.Cells["balYearMonth"].Text.Substring(5, 2);
- string adjustDoc = uRow.Cells["stocktakingDoc"].Value.ToString();
- string heatNo = uRow.Cells["judgeStoveNo"].Value.ToString();
- string bacthNo = uRow.Cells["batchNo"].Value.ToString();
- string bacthGroupNo = uRow.Cells["batchGroudNo"].Value.ToString();
- //string moth = DateTime.Now.AddMonths(1).ToString("yyyyMM");
- string moth = DateTime.Parse(uRow.Cells["balYearMonth"].Text).AddMonths(1).ToString("yyyyMM");
- string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob);
- //parm.Add(heatNo);
- //parm.Add(bacthNo);
- //parm.Add(bacthGroupNo);
- parm.Add(moth);
- DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.selectYearMoth", new object[] { parm,arr }, ob);
- if (int.Parse(ds.Rows[0]["ACOUNT"].ToString()) > 0)
- {
- MessageUtil.ShowTips("此炉【" + heatNo + "】已进行结转,不允许调整结转年月!");
- return;
- }
- string nowYearMoth = DateTime.Now.ToString("yyyyMM");
- //if (int.Parse(yearMoth) < int.Parse(nowYearMoth))
- //{
- // MessageUtil.ShowTips("修改的结转年月不能小于当月!");
- // return;
- //}
- list.Add(yearMoth);
- list.Add(yearMoth + "02 12:00:00");
- list.Add(adjustDoc);
- int count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.updateYear", new object[] { list }, ob);
- if (count > 0)
- {
- DoQueryOut();
- MessageUtil.ShowTips("修改成功");
- }
- }
- private void chk_CheckedChanged(object sender, EventArgs e)
- {
- if (chkRegTime.Checked)
- {
- RegStartTime.Enabled = true;
- RegEndTime.Enabled = true;
- }
- else
- {
- RegStartTime.Enabled = false;
- RegEndTime.Enabled = false;
- }
- if (chkFurnace.Checked)
- {
- txtFurnace.Enabled = true;
- }
- else
- {
- txtFurnace.Enabled = false;
- }
- if (chkMaterial.Checked)
- {
- cmbLocation.Enabled = true;
- }
- else
- {
- cmbLocation.Enabled = false;
- }
- }
- private void cmbStorage_SelectionChanged(object sender, EventArgs e)
- {
- if (cmbStorage.Value == null)
- {
- cmbLocation.DataSource = null;
- return;
- }
- string storageNo = cmbStorage.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getLocationNo", new object[] { storageNo }, this.ob);
- cmbLocation.DataSource = dt;
- cmbLocation.DisplayMember = "LOCATION_NO";
- cmbLocation.ValueMember = "LOCATION_NO";
- }
- private void chkWarehous_CheckedChanged(object sender, EventArgs e)
- {
- if (chkWarehous.Checked)
- {
- cmbStorage.Enabled = true;
- chkMaterial.Enabled = true;
- if (chkMaterial.Checked)
- {
- cmbLocation.Enabled = true;
- }
- else
- {
- cmbLocation.Enabled = false;
- }
- }
- else
- {
- chkMaterial.Checked = false;
- cmbStorage.Enabled = false;
- chkMaterial.Enabled = false;
- cmbLocation.Enabled = false;
- }
- }
- /// <summary>
- /// 查询条件
- /// </summary>
- /// <returns></returns>
- private ArrayList getQueryCondition()
- {
- ArrayList param = new ArrayList();
- string strBegin = "1900-01-01 00:00:00";
- string strEnd = "9900-01-01 00:00:00";
- string justStoveNo = "";
- string stoveNo = "";//仓库号;
- string locationNo = "";//料位号
- if (chkRegTime.Checked)
- {
- if (RegStartTime.Value == null || RegEndTime.Value == null)
- {
- errMessage = "请选择正确的时间";
- return null;
- }
- strBegin = RegStartTime.Value.ToString();
- strEnd = RegEndTime.Value.ToString();
- }
- if (chkFurnace.Checked)
- {
- justStoveNo = txtFurnace.Text.Trim();
- }
- if (chkWarehous.Checked && cmbStorage.Value != null)
- {
- stoveNo = cmbStorage.Value.ToString();
- }
- if (chkMaterial.Checked && cmbLocation.Value != null)
- {
- locationNo = cmbLocation.Value.ToString();
- }
- param.Add(strBegin);
- param.Add(strEnd);
- param.Add(justStoveNo);
- param.Add(stoveNo);
- param.Add(locationNo);
- return param;
- }
- /// <summary>
- /// 查询库存信息
- /// </summary>
- private void DoQueryMangement()
- {
- ArrayList param = getQueryCondition();
- if (param == null)
- {
- MessageUtil.ShowWarning(errMessage);
- return;
- }
- //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob);
- string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
- string supplyUnit = this.CustomInfo;
- List<MatZcMEntity> listSource = EntityHelper.GetData<MatZcMEntity>(
- "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getMangement", new object[] { param, stoveages, supplyUnit }, this.ob);
- matZcMEntityBindingSource.DataSource = listSource;
- BaseMethod.MergedCell(ultraGridManagement,new string[]{"BelongName"});
- }
- /// <summary>
- /// 查询盘亏信息
- /// </summary>
- private void DoQueryOut()
- {
- ArrayList param = getQueryCondition();
- if (param == null)
- {
- MessageUtil.ShowWarning(errMessage);
- return;
- }
- //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob);
- string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
- string supplyUnit = this.CustomInfo;
- List<YdmZcStocktakinglistEntity> listSource = EntityHelper.GetData<YdmZcStocktakinglistEntity>(
- "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getOut", new object[] { param, stoveages, supplyUnit }, this.ob);
- ydmZcStocktakinglistEntityBindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 盘亏操作
- /// </summary>
- private void DoDelete()
- {
- UltraGridRow ugr = ultraGridManagement.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowWarning("请选择要盘亏的记录!");
- return;
- }
- MatZcMEntity matzcMEntity = (MatZcMEntity)ugr.ListObject;
- int count = TxtNum.Value == null ? 0 : Convert.ToInt32(TxtNum.Value.ToString());
- if (count <= 0)
- {
- MessageUtil.ShowWarning("盘亏支数必须大于0!");
- return;
- }
- if (count > Convert.ToInt32(matzcMEntity.ActCount.ToString()))
- {
- MessageUtil.ShowWarning("盘亏支数不能大于库存实际支数!");
- return;
- }
- string reasonCode = cmbRsn.Value == null ? "" : cmbRsn.Value.ToString();
- if (reasonCode.Equals(""))
- {
- MessageUtil.ShowWarning("请选择盘亏原因!");
- return;
- }
- //if (ugr.Cells["matStatus"].Value != "材料可编计划(发运控制)")
- //{
- // MessageUtil.ShowWarning("材料已被做计划,不能盘亏!");
- // return;
- //}
- string reasonName = cmbRsn.Text;
- string memo = txtMemo.Text.Trim();
- ArrayList param = new ArrayList();
- param.Add(count);
- param.Add(reasonCode);
- param.Add(reasonName);
- param.Add(memo);
- param.Add(UserInfo.GetUserName());
- param.Add(ugr.Cells["OrdLnDlyPk"].Value.ToString());
- param.Add(DateTime.Now.ToString("yyyyMM"));
- DataTable dd = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getLockFlag", new object[] { matzcMEntity.JudgeStoveNo, matzcMEntity.BatchNo, matzcMEntity.BatchGroudNo }, ob);
- if (int.Parse(dd.Rows[0]["ACOUNT"].ToString()) > 0)
- {
- MessageUtil.ShowTips("炉号:" + matzcMEntity.JudgeStoveNo + "、批号:" + matzcMEntity.BatchNo + "的数据有被封锁的,不能进行盘亏!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否对炉号:" + matzcMEntity.JudgeStoveNo + " 批号:" + matzcMEntity.BatchNo + " 组号:" + matzcMEntity.BatchGroudNo + "进行盘亏操作?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut";
- ccp.MethodName = "InventoryOut";
- ccp.ServerParams = new object[] { matzcMEntity, param,this.CustomInfo };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- DoQueryMangement();
- //DoQueryOut();
- BaseMethod.UltraGridLocation(ultraGridManagement, new string[] { "BatchNo", "JudgeStoveNo", "BatchGroudNo" },
- new string[] { matzcMEntity.BatchNo, matzcMEntity.JudgeStoveNo, matzcMEntity.BatchGroudNo });
-
- }
- }
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (toolMenu == null) return;
- if(ultraTabControl1.SelectedTab.Key == "0")
- {
- if (toolMenu.Toolbars[0].Tools.Exists("Query"))
- {
- toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
- {
- toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
- {
- toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Export"))
- {
- toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
- {
- toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- this.chkRegTime.Text = "入库时间";
- }
- else if (ultraTabControl1.SelectedTab.Key == "1")
- {
- if (toolMenu.Toolbars[0].Tools.Exists("Query"))
- {
- toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
- {
- toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
- {
- toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Export"))
- {
- toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
- {
- toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- this.chkRegTime.Text = "盘亏时间";
- }
- }
- private void frmPipeInventoryOut_Shown(object sender, EventArgs e)
- {
- if (toolMenu == null) return;
- if (toolMenu.Toolbars[0].Tools.Exists("Query"))
- {
- toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
- {
- toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
- {
- toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("Export"))
- {
- toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
- {
- toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False;
- }
- }
- }
- }
|