| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- 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 Pur.Entity.ck;
- using Pur.require_plan;
- using Pur.Entity.configureEntity;
- using Core.Mes.Client.Comm.Control;
- using com.hnshituo.pur.vo;
- using Pur.configure;
- using Infragistics.Win;
- using Pur.PublicTools;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Pop_upWindow;
- using Core.Mes.Client.Comm.Tool;
- using System.Collections;
- namespace Pur.ck
- {
- public partial class FrmCkStorageConfirm : FrmPmsBase
- {
- public FrmCkStorageConfirm()
- {
- InitializeComponent();
- txt_createTimeE.Value = System.DateTime.Now;
- txt_createTimeS.Value = ((DateTime)txt_createTimeE.Value).AddMonths(-1);
- //ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- }
- //菜单按钮事件
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- if (ultraTabControl2.SelectedTab.Key=="0")
- {
- GetPUR_CK_STORAGE();
- getPur_Ck_StorageSuorce();
- }
- else
- {
- getPur_Ck_StorageSuorce();
- }
- break;
- case "cockInv":
- cockInv();
- break;
- case "unCockInv":
- unCockInv();
- break;
- case "MovingInvPhy":
- MovingInvPhy();
- break;
- case "CanCelMovingInvPhy":
- CanCelMovingInvPhy();
- break;
- case "doexport":
- doexport();
- break;
-
- }
- }
- public void doexport()
- {
- if (ultraTabControl2.ActiveTab.Key == "0")
- GridHelper.ulGridToExcel(ultraGrid1, ultraGrid1.Text);
- else
- GridHelper.ulGridToExcel(ultraGrid5, ultraGrid5.Text);
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetPUR_CK_STORAGE()
- {
- dataTable2.Rows.Clear();
- dataTable3.Rows.Clear();
- CkStorage CkSto = new CkStorage();
- CkSto.InvId = txt_InvId.Text;
- CkSto.ItemCode = txt_itemCode.Text;
- CkSto.ItemName = txt_itemName.Text;
- CkSto.SuppName = txt_suppName.Text;
- CkSto.OrderId = txt_orderId.Text;
- CkSto.InStockNo = txt_inStockNo.Text;
- CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
- CkSto.CreateName = txtItemClass.Text;
- if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
- {
- CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
- CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
- }
- CkSto.YkStatus = "1";
- string depid = this.UserInfo.GetDeptid();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_StorageByStatus", new object[] { CkSto, depid });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- //publicPms.autoGridColumnWSize(ultraGrid1.DisplayLayout.Bands[0]);
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- //标记待检状态入库单
- if (ugr.Cells["USESTATUS"].Value.ToString() == "不可用")
- {
- ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
- ugr.Cells["STATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
- }
- else
- {
- ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Black;
- ugr.Cells["STATUS"].Appearance.ForeColor = Color.Black;// System.Drawing.Color.FromArgb(255, 128, 0);
- }
- }
-
- }
- /// <summary>
- /// 获取移库记录
- /// </summary>
- private void getPur_Ck_StorageSuorce()
- {
- //dataTable7.Rows.Clear();
- //CkStorage CkSto = new CkStorage();
- //CkSto.InvId = txt_InvId.Text;
- //CkSto.ItemCode = txt_itemCode.Text;
- //CkSto.ItemName = txt_itemName.Text;
- //if (txt_invBin.Value != null)
- //{
- // CkSto.DeleteName = txt_invBin.Text;
- //}
- ////CkSto.InvLogic = txt_invLogic.Text;
- //if (txt_invPhysic.Value != null)
- //{
- // CkSto.DeleteUserid = txt_invPhysic.Text;
- //}
- //CkSto.SuppName = txt_suppName.Text;
- //CkSto.OrderId = txt_orderId.Text;
- //CkSto.InStockNo = txt_inStockNo.Text;
- //CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
- //if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
- //{
- // CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
- // CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
- //}
- ////查询源移库记录
- //CkSto.Status = "11";
- //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
- //GridHelper.CopyDataToDatatable(dt, dataTable4, true);
- //GridHelper.RefreshAndAutoSize(ultraGrid2);
- dataTable6.Rows.Clear();
- CkStorage CkSto = new CkStorage();
- CkSto.InvId = txt_InvId.Text;
- CkSto.ItemCode = txt_itemCode.Text;
- CkSto.ItemName = txt_itemName.Text;
- //CkSto.InvLogic = txt_invLogic.Text;
- CkSto.SuppName = txt_suppName.Text;
- CkSto.OrderId = txt_orderId.Text;
- CkSto.InStockNo = txt_inStockNo.Text;
- CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
- if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
- {
- CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
- CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
- }
- string[] datePurviewIds = this.ValidDataPurviewIds;
- //查询源移库记录
- //CkSto.Status = "11";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageUseService", "getCkConfirm", new object[] { CkSto,UserInfo.GetDeptid() });
- GridHelper.CopyDataToDatatable(dt, dataTable6, true);
- GridHelper.RefreshAndAutoSize(ultraGrid5);
- }
- /// <summary>
- /// 解冻库存
- /// </summary>
- private void unCockInv()
- {
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- CkStorage ck = new CkStorage();
- ck.InvId = ugr.Cells["InvId"].Value.ToString();
- ck.UseStatus = "1";
- if (MessageUtil.ShowYesNoAndQuestion("确定解冻库存【" + ck.InvId + "】?").Equals(DialogResult.No))
- {
- return;
- }
- CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
- if (re1.Resultcode == -1)
- {
- MessageBox.Show("解冻失败:" + re1.Resultmsg, "");
- return;
- }
- MessageBox.Show("解冻成功!");
- GetPUR_CK_STORAGE();
- getPur_Ck_StorageSuorce();
- }
- /// <summary>
- /// 冻结库存
- /// </summary>
- private void cockInv()
- {
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- CkStorage ck = new CkStorage();
- ck.InvId = ugr.Cells["InvId"].Value.ToString();
- ck.UseStatus = "0";
- if (MessageUtil.ShowYesNoAndQuestion("确定冻结库存【" + ck.InvId + "】?").Equals(DialogResult.No))
- {
- return;
- }
- CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
- if (re1.Resultcode == -1)
- {
- MessageBox.Show("冻结失败:" + re1.Resultmsg, "");
- return;
- }
- MessageBox.Show("冻结成功!");
- GetPUR_CK_STORAGE();
- getPur_Ck_StorageSuorce();
- }
- /// <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)
- {
- txt_itemCode.Text = mat.getItemCode().ToString();
- txt_itemName.Text = mat.getItemName().ToString();
- }
- }
- /// <summary>
- /// 界面加载,库区下拉框加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PurCkStorage_Load(object sender, EventArgs e)
- {
- txt_createTimeS.Text = DateTime.Now.AddMonths(-1).ToString();
- //获取
- PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();
- DataTable dt_GropByItem = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
- comm.FilComboboxAdd(txtItemClass, dt_GropByItem, "basecode", "basename", "", true, "", "");
- //LogicWareHouseEntity lhouse = new LogicWareHouseEntity();
- //lhouse.Validflag = "1";
- //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.LogicSeatService", "getLogicSeat", new object[] { lhouse, 0, 0 });
- //if (dt.Rows.Count > 0)
- //{
- // txt_invLogic.DataSource = dt;
- // this.txt_invLogic.DisplayMember = "invLogicName";
- // this.txt_invLogic.ValueMember = "invLogic";
- //}
- //PhysicSeatEntity Phouse = new PhysicSeatEntity();
- //Phouse.Validflag = "1";
- //DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatService", "getActualSeat", new object[] { Phouse, 0, 0 });
- //if (dt1.Rows.Count > 0)
- //{
- // txt_invPhysic.DataSource = dt1;
- // this.txt_invPhysic.DisplayMember = "invPhysicName";
- // this.txt_invPhysic.ValueMember = "invPhysic";
- //}
- //ActualSeatPosEntity PosEntity = new ActualSeatPosEntity();
- //PosEntity.Validflag = "1";
- //DataTable dt3 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { PosEntity, 0, 0 });
- //if (dt3.Rows.Count > 0)
- //{
- // txt_invBin.DataSource = dt3;
- // this.txt_invBin.DisplayMember = "invPosName";
- // this.txt_invBin.ValueMember = "invPos";
- //}
- GridHelper.SetExcludeColumnsActive(ultraGrid5.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "Check", "MoveQtyKC", "MoveQty");
- //GetPUR_CK_STORAGE();
- }
- /// <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();
- //Supp_Code = Sky.strSUPP_CODE.ToString();
- }
- /// <summary>
- /// 激活库存表
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- //GetPUR_CK_STORAGE_USE();
- //GetPUR_CK_STORAGE_POS();
- }
- /// <summary>
- /// 查询库存使用表
- /// </summary>
- private void GetPUR_CK_STORAGE_USE()
- {
- if (ultraGrid1.ActiveRow != null)
- {
- PurCkStorageUseEntity CkStorageUseEntity = new PurCkStorageUseEntity();
- CkStorageUseEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
- CkStorageUseEntity.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageUseService", "find", new object[] { CkStorageUseEntity,0,0 });
- //按创建时间降序
- if (dt.Rows.Count > 1)
- {
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- }
-
- GridHelper.CopyDataToDatatable(dt, dataTable3, true);
- }
- }
- /// <summary>
- /// 查询库存库位
- /// </summary>
- private void GetPUR_CK_STORAGE_POS()
- {
- if (ultraGrid1.ActiveRow != null)
- {
- PurCkStoragePosEntity CkStoragePosEntity = new PurCkStoragePosEntity();
- CkStoragePosEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePos_ByInvId", new object[] { CkStoragePosEntity });
- //按创建时间降序
- if (dt.Rows.Count > 1)
- {
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- }
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- }
- //publicPms.autoGridColumnWSize(ultraGrid2.DisplayLayout.Bands[0]);
- }
- /// <summary>
- /// 勾选库存记录
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- object o = e.Cell.Value;
- ultraGrid1.UpdateData();
- //UltraGridRow[] ugrs = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check" }, new string[] { e.Cell.Value.ToString()});
- //判断库区是否全相同
- //UltraGridRow[] ugrsPhysic = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check","invPhysic" }, new string[] { e.Cell.Value.ToString(),e.Cell.Row.Cells["invPhysic"].Value.ToString() });
- //判断库位是否全相同
- //UltraGridRow[] ugrsPhysicPos = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check", "invPos" }, new string[] { e.Cell.Value.ToString(), e.Cell.Row.Cells["invPos"].Value.ToString() });
- if (e.Cell.Column.Key == "MoveQtyKC")
- {
- double bMoveQtyKC = 0;
- double.TryParse(e.Cell.Row.Cells["MoveQtyKC"].Value.ToString(), out bMoveQtyKC);
- double bINVQTYWEIGHT = 0;
- double.TryParse(e.Cell.Row.Cells["INVQTYWEIGHT"].Value.ToString(), out bINVQTYWEIGHT);
- double bITEMUOMCONEFFICIENT = 0;
- double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
- if(bMoveQtyKC>bINVQTYWEIGHT)
- {
- MessageUtil.ShowTips("移库数量不能>库存数量");
- e.Cell.Value = o;
- return;
- }
- else
- {
- if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
- {
- e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC * bITEMUOMCONEFFICIENT, 3);
- }
- else
- {
- e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC / bITEMUOMCONEFFICIENT, 3);
- }
-
- }
- }
- if (e.Cell.Column.Key == "MoveQty")
- {
- double bMoveQty = 0;
- double.TryParse(e.Cell.Row.Cells["MoveQty"].Value.ToString(), out bMoveQty);
- double bINVQTY = 0;
- double.TryParse(e.Cell.Row.Cells["INVQTY"].Value.ToString(), out bINVQTY);
- double bITEMUOMCONEFFICIENT = 0;
- double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
- if (bMoveQty > bINVQTY)
- {
- MessageUtil.ShowTips("移库数量不能>采购数量");
- e.Cell.Value = o;
- return;
- }
- else
- {
- if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
- {
- e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty / bITEMUOMCONEFFICIENT, 3);
- }
- else
- {
- e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty * bITEMUOMCONEFFICIENT, 3);
- }
-
- }
- }
- }
- /// <summary>
- /// 移库操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_MovePhysic_Click(object sender, EventArgs e)
- {
- MovingInvPhy();
- }
- /// <summary>
- /// 确认
- /// </summary>
- private void MovingInvPhy()
- {
- ultraGrid1.UpdateData();
- if (ultraTabControl2.SelectedTab.Key != "0")
- {
- MessageUtil.ShowTips("请切换tab页面到“库存记录”,再进行操作");
- return;
- }
- ArrayList al = new ArrayList();
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if ((bool)ugr.Cells["Check"].Value)
- {
- al.Add(ugr.Cells["InvId"].Value.ToString());
- }
- }
- if (ultraGrid1.Rows.Where(t => t.Selected).Count() > 0 && al.Count <= 0)
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows.Where(t => t.Selected))
- {
- al.Add(ugr.Cells["InvId"].Value.ToString());
- }
- }
- if(al.Count<1)
- {
- MessageUtil.ShowTips("请勾选需要确认的记录");
- return;
- }
- CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "MoveInvConfirm", new object[] { al, UserInfo.GetUserName() });
- if (re1.Resultcode == -1)
- {
- MessageBox.Show("操作失败:" + re1.Resultmsg, "");
- return;
- }
- MessageBox.Show("确认成功!");
- GetPUR_CK_STORAGE();
- getPur_Ck_StorageSuorce();
- }
- /// <summary>
- /// 撤销移库
- /// </summary>
- private void CanCelMovingInvPhy()
- {
- if (ultraTabControl2.SelectedTab.Key != "1")
- {
- MessageUtil.ShowTips("请切换tab页面到“移库记录”,再撤销移库确认");
- return;
- }
- if(ultraGrid5.ActiveRow!=null)
- {
- if (comm.ConfirmOption("确定撤销库存记录号【" + ultraGrid5.ActiveRow.Cells["INVIDNEW"].Value.ToString() + "】的移库确认"))
- {
- CkStorage ck = new CkStorage();
- ck.InvId = ultraGrid5.ActiveRow.Cells["INVIDNEW"].Value.ToString();
- ck.UpdateName = UserInfo.GetUserName();
- ck.UpdateUserid = UserInfo.GetUserID();
- CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "CancelMoveInvConfirm", new object[] { ck });
- if (re1.Resultcode == -1)
- {
- MessageBox.Show("撤销失败:" + re1.Resultmsg, "");
- return;
- }
- MessageBox.Show("撤销成功!");
- GetPUR_CK_STORAGE();
- getPur_Ck_StorageSuorce();
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择移库记录");
- return;
- }
- }
- /// <summary>
- /// 选择新库位
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtPhysicPosNew_ValueChanged(object sender, EventArgs e)
- {
- //获取库位编码
- }
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- CkStorage CkSto = new CkStorage();
- CkSto.InvIdSource = ultraGrid2.ActiveRow.Cells["InvId"].Value.ToString();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
- GridHelper.CopyDataToDatatable(dt, dataTable7, true);
- GridHelper.RefreshAndAutoSize(ultraGrid4);
- }
- }
- }
|