Mar 11, 2015

using epicor InvTransferAdapter

public void TransferData(DataRow editRow)
        {           
            string PartNum = editRow["Character01"].ToString();
            string UOM = editRow["Character07"].ToString();

            InvTransferAdapter invTransferAdapter = new InvTransferAdapter(oTrans);
            invTransferAdapter.BOConnect();
            InvTransferDataSet transferRecord = invTransferAdapter.GetTransferRecord(PartNum, UOM);
            invTransferAdapter.InvTransferData.Clear();
            invTransferAdapter.InvTransferData.Merge(transferRecord);
            invTransferAdapter.InvTransferData.AcceptChanges();
            InvTransferDataSet.InvTransDataTable table = (InvTransferDataSet.InvTransDataTable)invTransferAdapter.InvTransferData.InvTrans;
            if (table.Count != 0)
            {
                DataRow dr = table.Rows[0];
                dr.BeginEdit();
                dr["TransferQty"] = editRow["Number10"];
                dr["FromWarehouseCode"] = editRow["Character08"];
                dr["FromBinNum"] = editRow["Character09"];
                dr["FromLotNumber"] = editRow["Key4"];
                dr["ToWarehouseCode"] = editRow["ShortChar02"];
                dr["ToBinNum"] = editRow["Character09"];
                dr["ToLotNumber"] = editRow["Key4"];
                dr["TranReference"] = editRow["Character05"];
                dr.EndEdit();
                string str6;
                string str7;
                InvTransferDataSet.InvTransRow row = (InvTransferDataSet.InvTransRow)table.Rows[0];
                string partNum = row.PartNum;
                string fromWarehouseCode = row.FromWarehouseCode;
                string fromBinNum = row.FromBinNum;
                string fromLotNumber = row.FromLotNumber;
                string transferQtyUOM = row.TransferQtyUOM;
                decimal pdTranQty = 1M;
                decimal pdDimConvFactor = decimal.Parse(row.TransferQty.ToString());
                invTransferAdapter.NegativeInventoryTest(partNum, fromWarehouseCode, fromBinNum, fromLotNumber, transferQtyUOM, pdDimConvFactor, pdTranQty, out str6, out str7);
                if (string.Compare(str6, "Ask User", true) == 0)
                {
                    if (MessageBox.Show(str7, "", MessageBoxButtons.OKCancel) != DialogResult.OK)
                    {
                        return;
                    }
                }
                else if (string.Compare(str6, "Stop", true) == 0)
                {
                    MessageBox.Show(str7);
                    return;
                }
                bool requiresUserInput = false;
                bool flag2 = true;
                try
                {
                    if (!invTransferAdapter.PreCommitTransfer(invTransferAdapter.InvTransferData, out requiresUserInput))
                    {
                        return;
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString());
                    return;
                }
                //if (requiresUserInput)
                //{
                //    DialogResult result2 = (DialogResult)LegalNumberPromptArgs.Start(this, this.adapter.InvTransferData.LegalNumGenOpts, true, fromWarehouseCode);
                //    if (result2 != DialogResult.OK)
                //    {
                //        flag2 = false;
                //    }
                //}
                if (flag2)
                {
                    string str16;
                    string str8 = row.TransferQty.ToString();
                    string str9 = row.TransferQtyUOM;
                    string fromWarehouseDesc = row.FromWarehouseDesc;
                    string fromBinDesc = row.FromBinDesc;
                    string toWarehouseDesc = row.ToWarehouseDesc;
                    string toBinDesc = row.ToBinDesc;
                    string toLotNumber = row.ToLotNumber;
                    string legalNumberMessage = "";
                    try
                    {
                        //if (toLotNumber != "")
                        //{
                        //    bool needsLotAttrs = false;
                        //    invTransferAdapter.ChkForNeedsLotAttrs(partNum, toLotNumber, out needsLotAttrs);
                        //    if (needsLotAttrs)
                        //    {
                        //        DialogResult result3 = (DialogResult)LotNumberEntryArgs.LaunchFormLotAttributes(this, partNum, toLotNumber, true);
                        //        if (result3 != DialogResult.OK)
                        //        {
                        //            flag2 = false;
                        //        }
                        //    }
                        //    if (!flag2)
                        //    {
                        //        return;
                        //    }
                        //}
                        bool flag3 = invTransferAdapter.CommitTransfer(invTransferAdapter.InvTransferData, out legalNumberMessage, out str16);
                        //if ((legalNumberMessage != null) && (legalNumberMessage.Length > 0))
                        //{
                        //    EpiMessageBox.Show(legalNumberMessage);
                        //}
                        //if (!flag3)
                        //{
                        //    return;
                        //}
                    }
                    catch (Exception exception2)
                    {
                        MessageBox.Show(exception2.ToString());
                        return;
                    }                  
                }
            }
            invTransferAdapter.Dispose();

        }

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib