コード例 #1
0
        public static string PMSaveCycleCount(object cyclecount)
        {
            string            result = "";
            CustomProfile     profile = CustomProfile.GetProfile();
            iCycleCountClient cycleclient = new iCycleCountClient();
            tCycleCountDetail cycledetail = new tCycleCountDetail();
            DataSet           ds = new DataSet();
            string            ContBasis = "", SessionID = "";
            decimal           DiffQuantity = 0;
            long LocationID = 0, SKUID = 0;

            try
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary = (Dictionary <string, object>)cyclecount;

                cycledetail.CountHeadID = long.Parse(dictionary["CycleheadID"].ToString());
                long CycleHeadId = long.Parse(dictionary["CycleheadID"].ToString());
                SKUID      = long.Parse(dictionary["hdnProductID"].ToString());
                LocationID = long.Parse(dictionary["locationID"].ToString());
                string  SKUCode      = dictionary["txtproduct"].ToString();
                string  LocationCode = dictionary["txtlocationCode"].ToString();
                long    WarehouseID  = long.Parse(dictionary["WarehouseID"].ToString());
                decimal Quantity     = decimal.Parse(dictionary["Quantity"].ToString());
                cycledetail.BatchCode = dictionary["BatchCode"].ToString();
                string BatchCode = dictionary["BatchCode"].ToString();
                if (LocationID == 0 || LocationID == null)
                {
                    LocationID = cycleclient.GetLocationID(LocationCode.Trim(), WarehouseID, profile.DBConnection._constr);
                }
                if (SKUID == 0 || SKUID == null)
                {
                    SKUID = cycleclient.GetSKUID(SKUCode.Trim(), WarehouseID, profile.DBConnection._constr);
                }
                cycledetail.ProductCode  = SKUCode;
                cycledetail.LocationCode = LocationCode;
                cycledetail.SKUID        = SKUID;
                cycledetail.LocationID   = LocationID;
                cycledetail.CreatedBy    = profile.Personal.UserID.ToString();
                cycledetail.CreationDate = DateTime.Now;


                decimal SystemQty = cycleclient.GetSystemQtyByBatch(SKUID, LocationID, BatchCode, profile.DBConnection._constr);
                cycledetail.QtyBalance = SystemQty;

                ds = cycleclient.GetRepeatedCycleCountData(CycleHeadId, SKUID, LocationID, BatchCode, profile.DBConnection._constr);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    DiffQuantity          = SystemQty - Quantity;
                    cycledetail.ActualQty = Quantity;
                    cycledetail.DiffQty   = DiffQuantity;
                    long CycleDetailID = cycleclient.SaveCycleCount(cycledetail, profile.DBConnection._constr);
                }
                else
                {
                    long    DetailID  = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                    decimal ActualQty = decimal.Parse(ds.Tables[0].Rows[0]["ActualQty"].ToString());
                    decimal DiffQty   = decimal.Parse(ds.Tables[0].Rows[0]["DiffQty"].ToString());
                    cycledetail.ActualQty = Quantity + ActualQty;
                    cycledetail.ID        = DetailID;
                    DiffQuantity          = DiffQty - Quantity;
                    cycledetail.DiffQty   = DiffQuantity;
                    long CycleDetailID = cycleclient.SaveCycleCount(cycledetail, profile.DBConnection._constr);
                }
            }
            catch
            {
                result = "Some error occurred";
            }
            finally
            {
            }

            return(result);
        }
コード例 #2
0
        public static string GetlocationQty(object objReq)
        {
            iCycleCountClient Cycle   = new iCycleCountClient();
            CustomProfile     profile = CustomProfile.GetProfile();
            tCycleCountDetail Dcycle  = new tCycleCountDetail();
            string            result  = "";

            try
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary = (Dictionary <string, object>)objReq;

                string  ProductCode   = dictionary["ProductCode"].ToString();
                string  locationcode  = dictionary["Location"].ToString();
                long    ProductID     = long.Parse(dictionary["ProductID"].ToString());
                long    LocationID    = long.Parse(dictionary["FromLocID"].ToString());
                string  BatchCode     = dictionary["BatchCode"].ToString();
                decimal SystemQty     = decimal.Parse(dictionary["SystemQty"].ToString());
                decimal ActualQty     = decimal.Parse(dictionary["ActualQty"].ToString());
                decimal AjustmentQty  = decimal.Parse(dictionary["AjustmentQty"].ToString());
                string  Remark        = dictionary["Remark"].ToString();
                string  AdjustLoc     = dictionary["AdjustmentLocIds"].ToString();
                long    CycleHeadID   = long.Parse(dictionary["CycleHeadID"].ToString());
                long    CycleDetailID = long.Parse(dictionary["CycleDetailID"].ToString());

                string[] ToLocIds     = AdjustLoc.Split(',');
                decimal  calculateQty = AjustmentQty;



                Cycle.UpdateStockSkuTransForFromLoc(ProductID, BatchCode, LocationID, AjustmentQty, profile.DBConnection._constr);

                for (int i = 0; i < ToLocIds.Length; i++)
                {
                    long    ToLocID  = long.Parse(ToLocIds[i].ToString());
                    decimal availQty = Cycle.getLocationRemainingQty(ToLocID, profile.DBConnection._constr);       // need to craete sp add in domain ninterface and build
                    if (calculateQty > availQty)
                    {
                        calculateQty = calculateQty - availQty;
                        Cycle.UpdateStocktransToLoc(ProductID, BatchCode, calculateQty, ToLocID, profile.Personal.UserID, CycleHeadID, profile.DBConnection._constr);    // need to Add CompanyID,CustomerID and UserID
                    }
                    else
                    {
                        Cycle.UpdateStocktransToLoc(ProductID, BatchCode, calculateQty, ToLocID, profile.Personal.UserID, CycleHeadID, profile.DBConnection._constr);     // need to Add CompanyID,CustomerID and UserID
                        calculateQty = 0;
                    }
                }

                Dcycle.ID             = CycleDetailID;
                Dcycle.CountHeadID    = CycleHeadID;
                Dcycle.QtyBalance     = SystemQty;
                Dcycle.ActualQty      = ActualQty;
                Dcycle.DiffQty        = AjustmentQty;
                Dcycle.AdjustmentQty  = AjustmentQty;
                Dcycle.Remark         = Remark;
                Dcycle.AdjustLocation = AdjustLoc;
                Dcycle.ProductCode    = ProductCode;
                Dcycle.LocationCode   = locationcode;
                Dcycle.SKUID          = ProductID;
                Dcycle.LocationID     = LocationID;
                Dcycle.BatchCode      = BatchCode;
                Dcycle.CreatedBy      = profile.Personal.UserID.ToString();
                Dcycle.CreationDate   = DateTime.Now;
                long CycleDtailID = Cycle.SaveCycleCount(Dcycle, profile.DBConnection._constr);



                /*decimal ClosingBalOutProd = Cycle.GetClosingBalance(Parameter, AjustmentQty, ProductID, LocationID);
                 * decimal ClosingBalInProd = Cycle.GetClosingBalance(param, AjustmentQty, ProductID, AdjustLoc);
                 * decimal AdjustmentSUMOut = Cycle.GetAdjustmentSUM(AjustmentQty, ProductID, LocationID);
                 * decimal AdjustmentSUMIN = Cycle.GetAdjustmentSUM(AjustmentQty, ProductID, AdjustLoc);*/

                // Cycle.UpdateCycleCountDetail(AjustmentQty, Remark, CreatedBy, DateTime.Now.Date, ProductCode, CycleHeadID, AdjstmentLoc);
                // // write method for transaction Entries One for out product and one for In product
                // Cycle.InsertTransactionAdjustment("Cycle Count", CycleHeadID, ProductID, LocationID, AdjustLoc, Remark, CreatedBy, DateTime.Now.Date, DateTime.Now.Date, AjustmentQty);

                // // update tinventry AdjustmentQty & QtyBalance for Out transaction
                // Cycle.UpdateInventryForOut(AdjustmentSUMOut, ClosingBalOutProd, ProductID, LocationID);


                // if records of ClosingBalIn product Is not inserted then we have to insert that and if present then update that

                /*   long CheckEntry = Cycle.GetCountTOCheckEntryInInventry(AdjustLoc, ProductID);
                 * if (CheckEntry > 0)
                 * {
                 *     Cycle.UpdateInventryForOut(AdjustmentSUMIN, ClosingBalInProd, ProductID, AdjustLoc);
                 * }
                 * else
                 * {
                 *     Cycle.InsertInventryCycleCount(ProductID, AdjustLoc, "Secondary", AjustmentQty, AjustmentQty, AjustmentQty, CreatedBy, DateTime.Now.Date, "Inventory_Inventory");
                 * }*/


                result = "Adjustment successful";
            }
            catch { result = "Some error occurred"; }
            finally
            {
                Cycle.Close();
            }
            return(result);
        }