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); }