Esempio n. 1
0
        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            log.Info("M_Inventory_ID=" + _m_Inventory_ID);
            MInventory inventory = new MInventory(GetCtx(), _m_Inventory_ID, Get_TrxName());

            if (inventory.Get_ID() == 0)
            {
                throw new SystemException("Not found: M_Inventory_ID=" + _m_Inventory_ID);
            }

            //	Multiple Lines for one item
            //jz simple the SQL so that Derby also like it. To avoid testing Oracle by now, leave no change for Oracle
            String sql = null;

            if (DataBase.DB.IsOracle())
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN "
                      + "(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + "HAVING COUNT(*) > 1)";
            }
            else
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND EXISTS "
                      + "(SELECT COUNT(*) "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + "HAVING COUNT(*) > 1)";
            }
            int multiple = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Multiple=" + multiple);

            int delMA = MInventoryLineMA.DeleteInventoryMA(_m_Inventory_ID, Get_TrxName());

            log.Info("DeletedMA=" + delMA);

            //	ASI
            sql = "UPDATE M_InventoryLine l "
                  + "SET (QtyBook,QtyCount) = "
                  + "(SELECT QtyOnHand,QtyOnHand FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),"
                  + " Updated=SysDate,"
                  + " UpdatedBy=" + GetAD_User_ID()
                  //
                  + " WHERE M_Inventory_ID=" + _m_Inventory_ID
                  + " AND EXISTS (SELECT * FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)";
            int no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Update with ASI =" + no);

            //	No ASI
            int noMA = UpdateWithMA();

            //	Set Count to Zero
            if (_inventoryCountSetZero)
            {
                sql = "UPDATE M_InventoryLine l "
                      + "SET QtyCount=0 "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID;
                no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());
                log.Info("Set Count to Zero =" + no);
            }
            if (_AdjustinventoryCount)
            {
                MInventoryLine[] lines = inventory.GetLines(true);
                for (int i = 0; i < lines.Length; i++)
                {
                    decimal        currentQty = 0;
                    string         query = "", qry = "";
                    int            result       = 0;
                    MInventoryLine iLine        = lines[i];
                    int            M_Product_ID = Utility.Util.GetValueOfInt(iLine.GetM_Product_ID());
                    int            M_Locator_ID = Utility.Util.GetValueOfInt(iLine.GetM_Locator_ID());
                    int            M_AttributeSetInstance_ID = Util.GetValueOfInt(iLine.GetM_AttributeSetInstance_ID());

                    query  = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate = " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @" 
                           AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                    result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                    if (result > 0)
                    {
                        qry        = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                        currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                    }
                    else
                    {
                        query  = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                        result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                        if (result > 0)
                        {
                            qry        = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                            currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                        }
                    }
                    iLine.SetQtyBook(currentQty);
                    iLine.SetOpeningStock(currentQty);
                    if (iLine.GetAdjustmentType() == "A")
                    {
                        iLine.SetDifferenceQty(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetAsOnDateCount()));
                    }
                    else if (iLine.GetAdjustmentType() == "D")
                    {
                        iLine.SetAsOnDateCount(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                    }
                    iLine.SetQtyCount(Util.GetValueOfDecimal(iLine.GetQtyBook()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                    if (!iLine.Save())
                    {
                    }
                }

                //sql = "UPDATE M_InventoryLine "
                //    + "SET QtyCount = QtyBook - NVL(DifferenceQty,0),OpeningStock = " + currentQty
                //    + "WHERE M_Inventory_ID=" + _m_Inventory_ID;
                //no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());
                //log.Info("Inventory Adjustment =" + no);
            }

            inventory.SetIsAdjusted(true);
            if (!inventory.Save())
            {
            }
            if (multiple > 0)
            {
                return("@M_InventoryLine_ID@ - #" + (no + noMA) + " --> @InventoryProductMultiple@");
            }

            return("@M_InventoryLine_ID@ - #" + (no + noMA));
        }
Esempio n. 2
0
        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            isContainerApplicable = MTransaction.ProductContainerApplicable(GetCtx());

            log.Info("M_Inventory_ID=" + _m_Inventory_ID);
            inventory = new MInventory(GetCtx(), _m_Inventory_ID, Get_TrxName());
            if (inventory.Get_ID() == 0)
            {
                throw new SystemException("Not found: M_Inventory_ID=" + _m_Inventory_ID);
            }

            //	Multiple Lines for one item
            //jz simple the SQL so that Derby also like it. To avoid testing Oracle by now, leave no change for Oracle
            String sql = null;

            if (DataBase.DB.IsOracle())
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN "
                      + "(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + (isContainerApplicable ? " , M_ProductContainer_ID" : "")
                      + "HAVING COUNT(*) > 1)";
            }
            else
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND EXISTS "
                      + "(SELECT COUNT(*) "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + (isContainerApplicable ? " , M_ProductContainer_ID" : "")
                      + "HAVING COUNT(*) > 1)";
            }
            int multiple = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Multiple=" + multiple);

            int delMA = MInventoryLineMA.DeleteInventoryMA(_m_Inventory_ID, Get_TrxName());

            log.Info("DeletedMA=" + delMA);

            //	ASI
            sql = "UPDATE M_InventoryLine l "
                  + "SET (QtyBook,QtyCount) = "
                  + "(SELECT QtyOnHand,QtyOnHand FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),"
                  + " Updated=SysDate,"
                  + " UpdatedBy=" + GetAD_User_ID()
                  //
                  + " WHERE M_Inventory_ID=" + _m_Inventory_ID
                  + " AND EXISTS (SELECT * FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)";
            int no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Update with ASI =" + no);

            //	No ASI
            //int noMA = UpdateWithMA();

            //	Set Count to Zero
            if (_inventoryCountSetZero)
            {
                sql = "UPDATE M_InventoryLine l "
                      + "SET QtyCount=0 "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID;
                no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());
                log.Info("Set Count to Zero =" + no);
            }
            if (_AdjustinventoryCount)
            {
                //                MInventoryLine[] lines = inventory.GetLines(true);
                //                for (int i = 0; i < lines.Length; i++)
                //                {
                //                    decimal currentQty = 0;
                //                    string query = "", qry = "";
                //                    int result = 0;
                //                    MInventoryLine iLine = lines[i];
                //                    int M_Product_ID = Utility.Util.GetValueOfInt(iLine.GetM_Product_ID());
                //                    int M_Locator_ID = Utility.Util.GetValueOfInt(iLine.GetM_Locator_ID());
                //                    int M_AttributeSetInstance_ID = Util.GetValueOfInt(iLine.GetM_AttributeSetInstance_ID());

                //                    query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate = " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                           AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                    result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                //                    if (result > 0)
                //                    {
                //                        qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                        currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                //                    }
                //                    else
                //                    {
                //                        query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                        result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                //                        if (result > 0)
                //                        {
                //                            qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                            currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                //                        }
                //                    }
                //                    iLine.SetQtyBook(currentQty);
                //                    iLine.SetOpeningStock(currentQty);
                //                    if (iLine.GetAdjustmentType() == "A")
                //                    {
                //                        iLine.SetDifferenceQty(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetAsOnDateCount()));
                //                    }
                //                    else if (iLine.GetAdjustmentType() == "D")
                //                    {
                //                        iLine.SetAsOnDateCount(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                //                    }
                //                    iLine.SetQtyCount(Util.GetValueOfDecimal(iLine.GetQtyBook()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                //                    if (!iLine.Save())
                //                    {

                //                    }
                //                }

                // Work done by Bharat on 26/12/2016 for optimization
                if (isContainerApplicable)
                {
                    sql = @"SELECT m.M_InventoryLine_ID, m.M_Locator_ID, m.M_Product_ID, m.M_AttributeSetInstance_ID, m.AdjustmentType, m.AsOnDateCount, m.DifferenceQty,
                nvl(mt.CurrentQty, 0) as CurrentQty FROM M_InventoryLine m LEFT JOIN (SELECT DISTINCT t.M_Locator_ID, t.M_Product_ID, t.M_AttributeSetInstance_ID, t.M_ProductContainer_ID,
                FIRST_VALUE(t.ContainerCurrentQty) OVER (PARTITION BY t.M_Product_ID, t.M_AttributeSetInstance_ID, t.M_Locator_ID, NVL(t.M_ProductContainer_ID, 0) ORDER BY t.MovementDate DESC, t.M_Transaction_ID DESC) AS CurrentQty FROM M_Transaction t
                INNER JOIN M_Locator l ON t.M_Locator_ID = l.M_Locator_ID WHERE t.MovementDate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) +
                          " AND t.AD_Client_ID = " + inventory.GetAD_Client_ID() + @") mt ON m.M_Product_ID = mt.M_Product_ID AND nvl(m.M_AttributeSetInstance_ID, 0) = nvl(mt.M_AttributeSetInstance_ID, 0) 
                AND m.M_Locator_ID = mt.M_Locator_ID AND nvl(m.M_ProductContainer_ID, 0) = nvl(mt.M_ProductContainer_ID, 0) 
                WHERE m.M_Inventory_ID = " + _m_Inventory_ID + " ORDER BY m.Line";
                }
                else
                {
                    sql = @"SELECT m.M_InventoryLine_ID, m.M_Locator_ID, m.M_Product_ID, m.M_AttributeSetInstance_ID, m.AdjustmentType, m.AsOnDateCount, m.DifferenceQty,
                nvl(mt.CurrentQty, 0) as CurrentQty FROM M_InventoryLine m LEFT JOIN (SELECT DISTINCT t.M_Locator_ID, t.M_Product_ID, t.M_AttributeSetInstance_ID, 
                FIRST_VALUE(t.CurrentQty) OVER (PARTITION BY t.M_Product_ID, t.M_AttributeSetInstance_ID, t.M_Locator_ID ORDER BY t.MovementDate DESC, t.M_Transaction_ID DESC) AS CurrentQty FROM M_Transaction t
                INNER JOIN M_Locator l ON t.M_Locator_ID = l.M_Locator_ID WHERE t.MovementDate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) +
                          " AND t.AD_Client_ID = " + inventory.GetAD_Client_ID() + @") mt ON m.M_Product_ID = mt.M_Product_ID AND nvl(m.M_AttributeSetInstance_ID, 0) = nvl(mt.M_AttributeSetInstance_ID, 0) 
                AND m.M_Locator_ID = mt.M_Locator_ID WHERE m.M_Inventory_ID = " + _m_Inventory_ID + " ORDER BY m.Line";
                }

                int           totalRec  = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(M_InventoryLine_ID) FROM ( " + sql + " ) t", null, null));
                int           pageSize  = 500;
                int           TotalPage = (totalRec % pageSize) == 0 ? (totalRec / pageSize) : ((totalRec / pageSize) + 1);
                int           count     = 0;
                DataSet       ds        = null;
                StringBuilder updateSql = new StringBuilder();
                try
                {
                    if (totalRec > 0)
                    {
                        log.Info(" =====> Physical Inventory update process Started at " + DateTime.Now.ToString());
                        if (!_SkipBL)
                        {
                            for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                            {
                                ds = DB.GetDatabase().ExecuteDatasetPaging(sql, pageNo, pageSize, 0);
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                    {
                                        decimal currentQty = 0;
                                        int     line_ID    = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                        currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][7]);
                                        MInventoryLine iLine = new MInventoryLine(GetCtx(), line_ID, Get_TrxName());
                                        iLine.SetQtyBook(currentQty);
                                        iLine.SetOpeningStock(currentQty);
                                        if (iLine.GetAdjustmentType() == "A")
                                        {
                                            iLine.SetDifferenceQty(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetAsOnDateCount()));
                                        }
                                        else if (iLine.GetAdjustmentType() == "D")
                                        {
                                            iLine.SetAsOnDateCount(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                                        }
                                        iLine.SetQtyCount(Util.GetValueOfDecimal(iLine.GetQtyBook()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                                        if (!iLine.Save())
                                        {
                                        }
                                        else
                                        {
                                            count++;
                                        }
                                    }
                                    ds.Dispose();
                                    log.Info(" =====>  records updated at " + DateTime.Now.ToString() + " are = " + count + " <===== ");
                                }
                            }
                        }
                        else
                        {
                            for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                            {
                                //updateSql.Clear();
                                ds = DB.GetDatabase().ExecuteDatasetPaging(sql, pageNo, pageSize, 0);
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    //updateSql.Append("BEGIN ");
                                    //for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                    //{
                                    //    int line_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                    //    int locator_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][1]);
                                    //    int product_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][2]);
                                    //    string AdjustType = Util.GetValueOfString(ds.Tables[0].Rows[j][4]);
                                    //    decimal AsonDateCount = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][5]);
                                    //    decimal DiffQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][6]);
                                    //    decimal currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][7]);
                                    //    string updateQry = UpdateInventoryLine(line_ID, product_ID, locator_ID, currentQty, AdjustType, AsonDateCount, DiffQty);
                                    //    if (updateQry != "")
                                    //    {
                                    //        updateSql.Append(updateQry);
                                    //    }
                                    //}
                                    //ds.Dispose();
                                    //updateSql.Append(" END;");
                                    //int cnt = DB.ExecuteQuery(updateSql.ToString(), null, Get_Trx());
                                    //log.Info(" =====>  records updated at " + DateTime.Now.ToString() + " are = " + count + " <===== ");

                                    string updateQry = DBFunctionCollection.UpdateInventoryLine(GetCtx(), ds, Get_Trx());
                                    ds.Dispose();
                                    int cnt = DB.ExecuteQuery(updateQry, null, Get_Trx());
                                }
                            }
                        }
                        log.Info(" =====>  Physical Inventory update process end at " + DateTime.Now.ToString());
                    }
                }
                catch (Exception e)
                {
                    if (ds != null)
                    {
                        ds.Dispose();
                    }
                    log.Log(Level.SEVERE, sql.ToString(), e);
                }
            }
            inventory.SetIsAdjusted(true);
            if (!inventory.Save())
            {
            }
            if (multiple > 0)
            {
                return("@M_InventoryLine_ID@ - #" + no + " --> @InventoryProductMultiple@");
            }

            //return "@M_InventoryLine_ID@ - #" + (no + noMA);
            return("Physical Inventory Updated");
        }
Esempio n. 3
0
        protected override string DoIt()
        {
            sql = @"SELECT   M_Product_ID ,   M_Locator_ID ,   M_AttributeSetInstance_ID ,  M_Transaction_ID , M_InventoryLine_ID , 
                           CurrentQty ,   MovementQty ,  MovementType , movementdate , TO_Char(Created, 'DD-MON-YY HH24:MI:SS')
                    FROM M_Transaction WHERE IsActive= 'Y' ";
            //if (orgId != null && !string.IsNullOrEmpty(orgId))
            //{
            //    sql += " AND AD_Org_ID  IN ( " + orgId + " )";
            //}
            if (productId != null && !string.IsNullOrEmpty(productId))
            {
                sql += " AND M_Product_ID IN ( " + productId + " )";
            }
            sql          += " ORDER BY   M_Product_ID  ,  M_Locator_ID ,  M_AttributeSetInstance_ID , movementdate , M_Transaction_ID ASC ";
            dsTransaction = new DataSet();
            try
            {
                dsTransaction = DB.ExecuteDataset(sql, null, Get_Trx());
                if (dsTransaction != null)
                {
                    if (dsTransaction.Tables.Count > 0)
                    {
                        if (dsTransaction.Tables[0].Rows.Count > 0)
                        {
                            int i = 0;
                            for (i = 0; i < dsTransaction.Tables[0].Rows.Count; i++)
                            {
                                if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                    _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                    _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]) &&
                                    Util.GetValueOfString(dsTransaction.Tables[0].Rows[i]["MovementType"]) == "I+" &&
                                    Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_InventoryLine_ID"]) > 0)
                                {
                                    //update Quantity Book at inventory line
                                    inventoryLine = new MInventoryLine(GetCtx(), Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_InventoryLine_ID"]), Get_Trx());
                                    inventory     = new MInventory(GetCtx(), Util.GetValueOfInt(inventoryLine.GetM_Inventory_ID()), null);
                                    if (!inventory.IsInternalUse())
                                    {
                                        inventoryLine.SetQtyBook(_currentQty);
                                        inventoryLine.SetOpeningStock(_currentQty);
                                        inventoryLine.SetDifferenceQty(Decimal.Subtract(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"])));
                                        if (!inventoryLine.Save())
                                        {
                                            log.Info("Quantity Book Not Updated at Inventory Line Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_InventoryLine_ID"]));
                                            Rollback();
                                            continue;
                                        }
                                        else
                                        {
                                            Commit();
                                        }

                                        // update movement Qty at Transaction for the same record
                                        transaction = new VAdvantage.Model.MTransaction(GetCtx(), Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]), Get_Trx());
                                        // transaction.SetMovementQty(Decimal.Subtract(inventoryLine.GetQtyCount(), _currentQty));
                                        transaction.SetMovementQty(Decimal.Negate(Decimal.Subtract(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]))));
                                        if (!transaction.Save())
                                        {
                                            log.Info("Current Quantity Not Updated at Transaction Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]));
                                        }
                                        else
                                        {
                                            Commit();
                                            _currentQty = Util.GetValueOfDecimal(transaction.GetCurrentQty());
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        transaction = new VAdvantage.Model.MTransaction(GetCtx(), Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]), Get_Trx());
                                        transaction.SetCurrentQty(Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"])));
                                        if (!transaction.Save())
                                        {
                                            log.Info("Current Quantity Not Updated at Transaction Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]));
                                        }
                                        else
                                        {
                                            Commit();
                                            _currentQty = Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"]));
                                            continue;
                                        }
                                    }
                                }
                                else if (Util.GetValueOfString(dsTransaction.Tables[0].Rows[i]["MovementType"]) == "I+" &&
                                         Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_InventoryLine_ID"]) > 0)
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }

                                if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                    _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                    _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    transaction = new VAdvantage.Model.MTransaction(GetCtx(), Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]), Get_Trx());
                                    transaction.SetCurrentQty(Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"])));
                                    if (!transaction.Save())
                                    {
                                        log.Info("Current Quantity Not Updated at Transaction Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]));
                                    }
                                    else
                                    {
                                        Commit();
                                        log.Info("Current Quantity  Updated at Transaction Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]));
                                        _currentQty = Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"]));
                                    }
                                }
                                //when Attribute not matched
                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                                // when Locator not Matched
                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                                //when Product , Locator n Attribute both not matched (means First Record)
                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                                //when Locator n Attribute both not matched
                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                                // when product and Locator not Matched
                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                                // when product and Attribute not Matched
                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
                                         _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
                                         _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
                                {
                                    if (_M_Product_ID > 0)
                                    {
                                        UpdateStorage(_M_Product_ID, _M_Locator_ID, _M_AttributeSetInstance_ID, _currentQty);
                                    }
                                    _currentQty   = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
                                    continue;
                                }
                            }
                        }
                    }
                }
                dsTransaction.Dispose();
            }
            catch
            {
                if (dsTransaction != null)
                {
                    dsTransaction.Dispose();
                }
                return(Msg.GetMsg(GetCtx(), "NotCompleted"));
            }
            finally
            {
                if (dsTransaction != null)
                {
                    dsTransaction.Dispose();
                }
            }
            return(Msg.GetMsg(GetCtx(), "SucessfullyCompleted"));

            #region
            //            sql = @"SELECT   M_Product_ID ,   M_Locator_ID ,   M_AttributeSetInstance_ID ,  M_Transaction_ID ,
            //                           CurrentQty ,   MovementQty ,  MovementType , TO_Char(Created, 'DD-MON-YY HH24:MI:SS')
            //                    FROM M_Transaction WHERE IsActive= 'Y' ";
            //            //if (orgId != null && !string.IsNullOrEmpty(orgId))
            //            //{
            //            //    sql += " AND AD_Org_ID  IN ( " + orgId + " )";
            //            //}
            //            if (productId != null && !string.IsNullOrEmpty(productId))
            //            {
            //                sql += " AND M_Product_ID IN ( " + productId + " )";
            //            }
            //            sql += " ORDER BY   M_Product_ID  ,  M_Locator_ID ,  M_AttributeSetInstance_ID , Created ASC ";
            //            dsTransaction = new DataSet();
            //            try
            //            {
            //                dsTransaction = DB.ExecuteDataset(sql, null, null);
            //                if (dsTransaction != null)
            //                {
            //                    if (dsTransaction.Tables.Count > 0)
            //                    {
            //                        if (dsTransaction.Tables[0].Rows.Count > 0)
            //                        {
            //                            int i = 0;
            //                            for (i = 0; i < dsTransaction.Tables[0].Rows.Count; i++)
            //                            {
            //                                if (Util.GetValueOfString(dsTransaction.Tables[0].Rows[i]["MovementType"]) == "I+")
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                          _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                          _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    transaction = new VAdvantage.Model.MTransaction(GetCtx(), Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]), null);
            //                                    transaction.SetCurrentQty(Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"])));
            //                                    if (!transaction.Save())
            //                                    {
            //                                        log.Info("Current Quantity Not Updated at Transaction Tab <===> " + Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Transaction_ID"]));
            //                                    }
            //                                    else
            //                                    {
            //                                        Commit();
            //                                        _currentQty = Decimal.Add(_currentQty, Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["MovementQty"]));
            //                                    }
            //                                }
            //                                //when Attribute not matched
            //                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                          _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                          _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                // when Locator not Matched
            //                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                         _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                         _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                //when Product , Locator n Attribute both not matched (means First Record)
            //                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                        _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                        _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                //when Locator n Attribute both not matched
            //                                else if (_M_Product_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                   _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                   _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                // when product and Locator not Matched
            //                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                        _M_Locator_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                        _M_AttributeSetInstance_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                                // when product and Attribute not Matched
            //                                else if (_M_Product_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]) &&
            //                                        _M_Locator_ID == Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]) &&
            //                                        _M_AttributeSetInstance_ID != Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]))
            //                                {
            //                                    _currentQty = Util.GetValueOfDecimal(dsTransaction.Tables[0].Rows[i]["CurrentQty"]);
            //                                    _M_Product_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Product_ID"]);
            //                                    _M_Locator_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_Locator_ID"]);
            //                                    _M_AttributeSetInstance_ID = Util.GetValueOfInt(dsTransaction.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]);
            //                                    continue;
            //                                }
            //                            }
            //                        }
            //                    }
            //                }
            //                dsTransaction.Dispose();
            //            }
            //            catch
            //            {
            //                if (dsTransaction != null)
            //                {
            //                    dsTransaction.Dispose();
            //                }
            //                return Msg.GetMsg(GetCtx(), "NotCompleted");
            //            }
            //            finally
            //            {
            //                if (dsTransaction != null)
            //                {
            //                    dsTransaction.Dispose();
            //                }
            //            }
            //            return Msg.GetMsg(GetCtx(), "SucessfullyCompleted");
            #endregion
        }