예제 #1
0
        public static void UpdateWardInventory(InventoryDbContext inventoryDbContext, List <DispatchItemsModel> dispatchItems)
        {
            try
            {
                if (dispatchItems != null)
                {
                    foreach (var stkItem in dispatchItems)
                    {
                        var wardItem = inventoryDbContext.WardStock.Where(i => i.ItemId == stkItem.ItemId && i.StockType == "inventory" && i.DepartmentId == stkItem.DepartmentId).FirstOrDefault();
                        if (wardItem != null)
                        {
                            wardItem.AvailableQuantity = wardItem.AvailableQuantity + Convert.ToInt32(stkItem.DispatchedQuantity);
                            inventoryDbContext.Entry(wardItem).State = EntityState.Modified;
                        }
                        else
                        {
                            var inventory = (from inv in inventoryDbContext.Stock
                                             join goods in inventoryDbContext.GoodsReceiptItems on inv.GoodsReceiptItemId equals goods.GoodsReceiptItemId
                                             where inv.ItemId == stkItem.ItemId
                                             select new
                            {
                                BatchNo = inv.BatchNO,
                                MRP = goods.ItemRate,
                                inv.ExpiryDate
                            }).FirstOrDefault();


                            WARDStockModel wardStock = new WARDStockModel();
                            wardStock.ItemId            = stkItem.ItemId;
                            wardStock.AvailableQuantity = Convert.ToInt32(stkItem.DispatchedQuantity);
                            wardStock.DepartmentId      = stkItem.DepartmentId;
                            wardStock.StockType         = "inventory";
                            if (inventory != null)
                            {
                                wardStock.BatchNo    = inventory.BatchNo;
                                wardStock.MRP        = Convert.ToDouble(inventory.MRP);
                                wardStock.ExpiryDate = inventory.ExpiryDate;
                            }
                            inventoryDbContext.WardStock.Add(wardStock);
                        }
                    }
                }

                //Update Stock records
                inventoryDbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static Boolean StockBreakage(WARDStockModel stkBreakage, WardSupplyDbContext wardSupplyDbContext, RbacUser currentUser)
        {
            //Transaction begins
            using (var dbContextTransaction = wardSupplyDbContext.Database.BeginTransaction())
            {
                try
                {
                    List <Boolean> flag = new List <bool>();

                    var            AvailableQuantity = (int)(Convert.ToDecimal(stkBreakage.AvailableQuantity)) - (int)(Convert.ToDecimal(stkBreakage.DispachedQuantity));
                    WARDStockModel stockDetail       = (from stock in wardSupplyDbContext.WARDStockModel
                                                        where stock.StockId == stkBreakage.StockId
                                                        select stock).FirstOrDefault();
                    stockDetail.AvailableQuantity = AvailableQuantity;
                    wardSupplyDbContext.Entry(stockDetail).Property(a => a.AvailableQuantity).IsModified = true;
                    //add to transaction table
                    var selectedstockTxnItm = new WARDTransactionModel();
                    selectedstockTxnItm.WardId          = stkBreakage.WardId;
                    selectedstockTxnItm.ItemId          = stkBreakage.ItemId;
                    selectedstockTxnItm.StockId         = stkBreakage.StockId;
                    selectedstockTxnItm.TransactionId   = 0;
                    selectedstockTxnItm.Quantity        = (int)(Convert.ToDecimal(stkBreakage.DispachedQuantity));
                    selectedstockTxnItm.TransactionType = "BreakageItem";
                    selectedstockTxnItm.Remarks         = stkBreakage.Remarks;
                    selectedstockTxnItm.CreatedBy       = currentUser.UserName;
                    selectedstockTxnItm.CreatedOn       = DateTime.Now;
                    selectedstockTxnItm.IsWard          = true;
                    wardSupplyDbContext.TransactionModel.Add(selectedstockTxnItm);
                    wardSupplyDbContext.SaveChanges();

                    dbContextTransaction.Commit();//Commit Transaction
                    return(true);
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
                //return false;
            }
        }
        public static Boolean StockTransfer(WARDStockModel stkTransferfromClient, WardSupplyDbContext wardSupplyDbContext, RbacUser currentUser)
        {
            //Transaction Begin
            using (var dbContextTransaction = wardSupplyDbContext.Database.BeginTransaction())
            {
                try
                {
                    List <Boolean> flag = new List <bool>(); //for checking all transaction status


                    var            AvailableQuantity = (int)(Convert.ToDecimal(stkTransferfromClient.AvailableQuantity)) - (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                    WARDStockModel stockDetail       = (from stock in wardSupplyDbContext.WARDStockModel
                                                        where stock.StockId == stkTransferfromClient.StockId
                                                        select stock
                                                        ).FirstOrDefault();
                    stockDetail.AvailableQuantity = AvailableQuantity;

                    wardSupplyDbContext.Entry(stockDetail).Property(a => a.AvailableQuantity).IsModified = true;
                    //add to transaction table
                    var selectedstockTxnItm = new WARDTransactionModel();
                    selectedstockTxnItm.WardId          = stkTransferfromClient.WardId;
                    selectedstockTxnItm.newWardId       = stkTransferfromClient.newWardId;
                    selectedstockTxnItm.ItemId          = stkTransferfromClient.ItemId;
                    selectedstockTxnItm.StockId         = stkTransferfromClient.StockId;
                    selectedstockTxnItm.TransactionId   = 0;
                    selectedstockTxnItm.Quantity        = (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                    selectedstockTxnItm.TransactionType = "WardtoWard";
                    selectedstockTxnItm.Remarks         = stkTransferfromClient.Remarks;
                    selectedstockTxnItm.CreatedBy       = currentUser.UserName;
                    selectedstockTxnItm.CreatedOn       = DateTime.Now;
                    selectedstockTxnItm.IsWard          = true;
                    wardSupplyDbContext.TransactionModel.Add(selectedstockTxnItm);
                    wardSupplyDbContext.SaveChanges();

                    //add stock to new ward
                    stkTransferfromClient.WardId = stkTransferfromClient.newWardId;
                    stockDetail = (from stock in wardSupplyDbContext.WARDStockModel
                                   where stock.WardId == stkTransferfromClient.WardId && stock.ItemId == stkTransferfromClient.ItemId && stock.BatchNo == stkTransferfromClient.BatchNo
                                   select stock
                                   ).FirstOrDefault();
                    if (stockDetail != null)
                    {
                        stockDetail.AvailableQuantity = stockDetail.AvailableQuantity + (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                        wardSupplyDbContext.Entry(stockDetail).Property(a => a.AvailableQuantity).IsModified = true;
                        wardSupplyDbContext.SaveChanges();
                    }
                    else
                    {
                        stkTransferfromClient.AvailableQuantity = (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                        wardSupplyDbContext.WARDStockModel.Add(stkTransferfromClient);
                        wardSupplyDbContext.SaveChanges();
                    }
                    dbContextTransaction.Commit();//Commit Transaction
                    return(true);
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
                //return false;
            }
        }
 public static Boolean StockTransferToPharmacy(List <WARDStockModel> stkTransfer, WardSupplyDbContext wardSupplyDbContext, PharmacyDbContext pharmacyDbContext, RbacUser currentUser)
 {
     //Transaction Begins
     using (var dbContextTransaction = wardSupplyDbContext.Database.BeginTransaction())
     {
         try
         {
             if (stkTransfer != null)
             {
                 for (int i = 0; i < stkTransfer.Count; i++)
                 {
                     var            stockId      = stkTransfer[i].StockId;
                     WARDStockModel updatedStock = (from stock in wardSupplyDbContext.WARDStockModel
                                                    where stock.StockId == stockId
                                                    select stock
                                                    ).FirstOrDefault();
                     updatedStock.AvailableQuantity = (int)(Convert.ToDecimal(stkTransfer[i].AvailableQuantity)) - (int)(Convert.ToDecimal(stkTransfer[i].DispachedQuantity));
                     wardSupplyDbContext.Entry(updatedStock).Property(a => a.AvailableQuantity).IsModified = true;
                     //transaction table
                     var selectedstockTxnItm = new WARDTransactionModel();
                     selectedstockTxnItm.WardId          = updatedStock.WardId;
                     selectedstockTxnItm.ItemId          = updatedStock.ItemId;
                     selectedstockTxnItm.StockId         = updatedStock.StockId;
                     selectedstockTxnItm.TransactionId   = 0;
                     selectedstockTxnItm.Quantity        = (int)(Convert.ToDecimal(stkTransfer[i].DispachedQuantity));
                     selectedstockTxnItm.TransactionType = "WardToPharmacy";
                     selectedstockTxnItm.Remarks         = "Sent From Ward To Pharmacy";
                     selectedstockTxnItm.CreatedBy       = currentUser.UserName;
                     selectedstockTxnItm.CreatedOn       = DateTime.Now;
                     selectedstockTxnItm.IsWard          = true;
                     wardSupplyDbContext.TransactionModel.Add(selectedstockTxnItm);
                     wardSupplyDbContext.SaveChanges();
                     //pharmacy stock changes
                     var            itemId  = stkTransfer[i].ItemId;
                     var            batchNo = stkTransfer[i].BatchNo;
                     PHRMStockModel updatedPharmacyStock = (from stock in pharmacyDbContext.PHRMStock
                                                            where stock.ItemId == itemId && stock.BatchNo == batchNo
                                                            select stock
                                                            ).FirstOrDefault();
                     updatedPharmacyStock.AvailableQuantity = (int)(Convert.ToDecimal(updatedPharmacyStock.AvailableQuantity)) + (int)(Convert.ToDecimal(stkTransfer[i].DispachedQuantity));
                     pharmacyDbContext.Entry(updatedPharmacyStock).Property(a => a.AvailableQuantity).IsModified = true;
                     //Pharmacy Transaction Table
                     var phrmStockTxn = new PHRMStockTransactionItemsModel();
                     phrmStockTxn.ItemId             = updatedPharmacyStock.ItemId;
                     phrmStockTxn.BatchNo            = updatedPharmacyStock.BatchNo;
                     phrmStockTxn.ExpiryDate         = stkTransfer[i].ExpiryDate;
                     phrmStockTxn.Quantity           = (int)(Convert.ToDecimal(stkTransfer[i].DispachedQuantity));
                     phrmStockTxn.FreeQuantity       = 0;
                     phrmStockTxn.Price              = (int)(Convert.ToDecimal(stkTransfer[i].MRP));
                     phrmStockTxn.DiscountPercentage = 0;
                     phrmStockTxn.VATPercentage      = 0;
                     phrmStockTxn.SubTotal           = (int)(Convert.ToDecimal(phrmStockTxn.Quantity)) * (int)(Convert.ToDecimal(phrmStockTxn.Price));
                     phrmStockTxn.TotalAmount        = phrmStockTxn.SubTotal;
                     phrmStockTxn.InOut              = "in";
                     phrmStockTxn.CreatedBy          = currentUser.UserId;
                     phrmStockTxn.CreatedOn          = DateTime.Now;
                     phrmStockTxn.MRP             = phrmStockTxn.Price;
                     phrmStockTxn.TransactionType = "WardToPharmacy";
                     pharmacyDbContext.PHRMStockTransactionModel.Add(phrmStockTxn);
                     pharmacyDbContext.SaveChanges();
                 }
             }
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
        public static Boolean BackToInventoryTransfer(WARDStockModel stkTransferfromClient, WardSupplyDbContext wardSupplyDbContext, RbacUser currentUser)
        {
            //Transaction Begin
            using (var dbContextTransaction = wardSupplyDbContext.Database.BeginTransaction())
            {
                try
                {
                    List <Boolean> flag = new List <bool>(); //for checking all transaction status


                    var            AvailableQuantity = (int)(Convert.ToDecimal(stkTransferfromClient.AvailableQuantity)) - (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                    WARDStockModel stockDetail       = (from stock in wardSupplyDbContext.WARDStockModel
                                                        where stock.StockId == stkTransferfromClient.StockId && stock.ItemId == stkTransferfromClient.ItemId && stock.DepartmentId == stkTransferfromClient.DepartmentId && stock.StockType == "inventory"
                                                        select stock
                                                        ).FirstOrDefault();
                    stockDetail.AvailableQuantity = AvailableQuantity;

                    wardSupplyDbContext.Entry(stockDetail).Property(a => a.AvailableQuantity).IsModified = true;
                    //add to transaction table
                    var selectedstockTxnItm = new WARDTransactionModel();
                    selectedstockTxnItm.WardId          = stkTransferfromClient.DepartmentId;
                    selectedstockTxnItm.newWardId       = stkTransferfromClient.newWardId;
                    selectedstockTxnItm.ItemId          = stkTransferfromClient.ItemId;
                    selectedstockTxnItm.StockId         = stkTransferfromClient.StockId;
                    selectedstockTxnItm.TransactionId   = 0;
                    selectedstockTxnItm.Quantity        = (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                    selectedstockTxnItm.TransactionType = "BackToInventory";
                    selectedstockTxnItm.Remarks         = stkTransferfromClient.Remarks;
                    selectedstockTxnItm.CreatedBy       = currentUser.UserName;
                    selectedstockTxnItm.CreatedOn       = DateTime.Now;
                    selectedstockTxnItm.IsWard          = false;
                    wardSupplyDbContext.TransactionModel.Add(selectedstockTxnItm);
                    wardSupplyDbContext.SaveChanges();

                    //add stock to inventory
                    var inventoryStock = new StockModel();
                    inventoryStock = (from stock in wardSupplyDbContext.INVStockMaster
                                      where stock.ItemId == stkTransferfromClient.ItemId && stock.BatchNO == stkTransferfromClient.BatchNo
                                      select stock).FirstOrDefault();
                    if (inventoryStock != null)
                    {
                        inventoryStock.AvailableQuantity = inventoryStock.AvailableQuantity + (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                        wardSupplyDbContext.Entry(inventoryStock).Property(a => a.AvailableQuantity).IsModified = true;
                        wardSupplyDbContext.SaveChanges();
                        var stockTransaction = new StockTransactionModel();
                        stockTransaction.StockId         = inventoryStock.StockId;
                        stockTransaction.Quantity        = (int)(Convert.ToDecimal(stkTransferfromClient.DispachedQuantity));
                        stockTransaction.InOut           = "in";
                        stockTransaction.ReferenceNo     = inventoryStock.GoodsReceiptItemId;
                        stockTransaction.CreatedBy       = currentUser.EmployeeId;
                        stockTransaction.CreatedOn       = DateTime.Now;
                        stockTransaction.TransactionType = "Sent From WardSupply";
                        wardSupplyDbContext.INVStockTransaction.Add(stockTransaction);
                        wardSupplyDbContext.SaveChanges();
                    }
                    //add to stock transaction in inventory
                    dbContextTransaction.Commit();//Commit Transaction
                    return(true);
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
                //return false;
            }
        }
예제 #6
0
        public string Post()
        {
            WardSupplyDbContext         wardSupplyDbContext = new WardSupplyDbContext(connString);
            DanpheHTTPResponse <object> responseData        = new DanpheHTTPResponse <object>();
            RbacUser          currentUser   = HttpContext.Session.Get <RbacUser>("currentuser");
            PharmacyDbContext phrmdbcontext = new PharmacyDbContext(connString);
            string            reqType       = this.ReadQueryStringData("reqType");
            string            str           = this.ReadPostData();

            try
            {
                if (!String.IsNullOrEmpty(str))
                {
                    #region Post:Ward Request
                    if (reqType == "ward-requistion")
                    {
                        WARDRequisitionModel WardReq = DanpheJSONConvert.DeserializeObject <WARDRequisitionModel>(str);
                        WardReq.CreatedOn = DateTime.Now.Date;
                        WardReq.CreatedBy = currentUser.EmployeeId;
                        WardReq.Status    = "pending";
                        wardSupplyDbContext.WARDRequisitionModel.Add(WardReq);
                        wardSupplyDbContext.SaveChanges();
                        responseData.Results = WardReq;
                        responseData.Status  = "OK";
                    }
                    #endregion
                    #region POST: Consumption
                    else if (reqType == "post-consumption")
                    {
                        PHRMInvoiceTransactionItemsModel invoice       = new PHRMInvoiceTransactionItemsModel();
                        List <WARDStockModel>            wardStockList = new List <WARDStockModel>();
                        WARDStockModel wardStock = new WARDStockModel();
                        List <WARDConsumptionModel>    consumptionList   = JsonConvert.DeserializeObject <List <WARDConsumptionModel> >(str);
                        PHRMStockTransactionItemsModel phrmStockTxnItems = new PHRMStockTransactionItemsModel();
                        foreach (var consmption in consumptionList)
                        {
                            //adding invoice in PHRM_TXN_Invoice
                            invoice.ItemId             = consmption.ItemId;
                            invoice.ItemName           = consmption.ItemName;
                            invoice.BatchNo            = consmption.BatchNo;
                            invoice.Quantity           = consmption.Quantity;
                            invoice.Price              = consmption.MRP;
                            invoice.MRP                = consmption.MRP;
                            invoice.SubTotal           = consmption.SubTotal;
                            invoice.TotalAmount        = consmption.SubTotal;
                            invoice.CreatedBy          = consmption.CreatedBy;
                            invoice.CreatedOn          = System.DateTime.Now;
                            invoice.CounterId          = consmption.CounterId;
                            invoice.BilItemStatus      = "wardconsumption";
                            invoice.ExpiryDate         = consmption.ExpiryDate;
                            invoice.PatientId          = consmption.PatientId;
                            invoice.VATPercentage      = 0;
                            invoice.DiscountPercentage = 0;
                            invoice.FreeQuantity       = 0;
                            phrmdbcontext.PHRMInvoiceTransactionItems.Add(invoice);
                            phrmdbcontext.SaveChanges();

                            //adding consumption in WARD_Consumption
                            consmption.InvoiceItemId = invoice.InvoiceItemId;
                            consmption.CreatedOn     = System.DateTime.Now;
                            wardSupplyDbContext.WARDConsumptionModel.Add(consmption);
                            wardSupplyDbContext.SaveChanges();

                            //adding record in list for updating stock available quantity
                            wardStock                   = new WARDStockModel();
                            wardStock.ItemId            = consmption.ItemId;
                            wardStock.MRP               = (float)consmption.MRP;
                            wardStock.ExpiryDate        = consmption.ExpiryDate;
                            wardStock.BatchNo           = consmption.BatchNo;
                            wardStock.WardId            = consmption.WardId;
                            wardStock.DispachedQuantity = consmption.Quantity;
                            wardStockList.Add(wardStock);

                            //adding record in the PHRM_StockTxnItems
                            phrmStockTxnItems.CreatedBy = currentUser.EmployeeId;
                            phrmStockTxnItems.CreatedOn = DateTime.Now;
                            phrmStockTxnItems.BatchNo   = consmption.BatchNo;
                            phrmStockTxnItems.ItemId    = consmption.ItemId;
                            phrmStockTxnItems.Price     = consmption.MRP;
                            phrmStockTxnItems.MRP       = consmption.MRP;
                            phrmStockTxnItems.ReferenceItemCreatedOn = DateTime.Now;
                            phrmStockTxnItems.ReferenceNo            = consmption.InvoiceItemId;
                            phrmStockTxnItems.GoodsReceiptItemId     = null;
                            phrmStockTxnItems.CCCharge           = null;
                            phrmStockTxnItems.Quantity           = consmption.Quantity;
                            phrmStockTxnItems.ExpiryDate         = consmption.ExpiryDate;
                            phrmStockTxnItems.FreeQuantity       = 0;
                            phrmStockTxnItems.DiscountPercentage = 0;
                            phrmStockTxnItems.VATPercentage      = 0;
                            phrmStockTxnItems.InOut           = "out";
                            phrmStockTxnItems.TransactionType = "wardsupply";
                            phrmStockTxnItems.SubTotal        = consmption.SubTotal;
                            phrmStockTxnItems.TotalAmount     = consmption.SubTotal;
                            phrmdbcontext.PHRMStockTransactionModel.Add(phrmStockTxnItems);
                            phrmdbcontext.SaveChanges();
                        }

                        if (WardSupplyBL.UpdateWardSockQuantity(wardStockList, wardSupplyDbContext))
                        {
                            responseData.Status  = "OK";
                            responseData.Results = consumptionList;
                        }
                        else
                        {
                            responseData.Status       = "Failed";
                            responseData.ErrorMessage = "Falied to update stock details.";
                        }
                    }
                    #endregion
                    #region POST: Inventory Consumption
                    else if (reqType == "post-inventory-consumption")
                    {
                        PHRMInvoiceTransactionItemsModel invoice       = new PHRMInvoiceTransactionItemsModel();
                        List <WARDStockModel>            wardStockList = new List <WARDStockModel>();
                        WARDStockModel wardStock = new WARDStockModel();
                        List <WARDInventoryConsumptionModel> consumptionList   = JsonConvert.DeserializeObject <List <WARDInventoryConsumptionModel> >(str);
                        PHRMStockTransactionItemsModel       phrmStockTxnItems = new PHRMStockTransactionItemsModel();
                        foreach (var consmption in consumptionList)
                        {
                            //adding record in list for updating stock available quantity
                            var            AvailableQuantity = consmption.Quantity - consmption.ConsumeQuantity;
                            WARDStockModel stockDetail       = (from stock in wardSupplyDbContext.WARDStockModel
                                                                where stock.ItemId == consmption.ItemId & stock.StockType == "inventory" && stock.DepartmentId == consmption.DepartmentId
                                                                select stock
                                                                ).FirstOrDefault();
                            stockDetail.AvailableQuantity = AvailableQuantity;
                            wardSupplyDbContext.Entry(stockDetail).Property(a => a.AvailableQuantity).IsModified = true;

                            //adding consumption in [WARD_INV_Consumption]
                            AvailableQuantity    = consmption.ConsumeQuantity;
                            consmption.Quantity  = AvailableQuantity;
                            consmption.CreatedOn = System.DateTime.Now;
                            wardSupplyDbContext.WARDInventoryConsumptionModel.Add(consmption);
                            wardSupplyDbContext.SaveChanges();
                        }
                        responseData.Status  = "OK";
                        responseData.Results = consumptionList;
                    }
                    #endregion
                    #region POST : update stock transaction, Post to Stock table and post to Transaction table
                    else if (reqType == "transfer-stock")
                    {
                        WARDStockModel stockManageData = DanpheJSONConvert.DeserializeObject <WARDStockModel>(str);
                        if (stockManageData != null)
                        {
                            Boolean flag = false;


                            flag = WardSupplyBL.StockTransfer(stockManageData, wardSupplyDbContext, currentUser);
                            if (flag)
                            {
                                responseData.Status  = "OK";
                                responseData.Results = 1;
                            }
                            else
                            {
                                responseData.ErrorMessage = "Transfer Item is null or failed to Save";
                                responseData.Status       = "Failed";
                            }
                        }
                    }
                    #endregion
                    #region POST : update stock transaction, Post to Stock table and post to Transaction table
                    else if (reqType == "transfer-inventory-stock")
                    {
                        WARDStockModel stockManageData = DanpheJSONConvert.DeserializeObject <WARDStockModel>(str);
                        if (stockManageData != null)
                        {
                            Boolean flag = false;


                            flag = WardSupplyBL.StockInventoryTransfer(stockManageData, wardSupplyDbContext, currentUser);
                            if (flag)
                            {
                                responseData.Status  = "OK";
                                responseData.Results = 1;
                            }
                            else
                            {
                                responseData.ErrorMessage = "Transfer Item is null or failed to Save";
                                responseData.Status       = "Failed";
                            }
                        }
                    }
                    #endregion
                    #region POST : delete from stock table in wardsupply. add stock in inventory and update in stock transaction
                    else if (reqType == "transfer-back-to-inventory")
                    {
                        WARDStockModel stockManageData = DanpheJSONConvert.DeserializeObject <WARDStockModel>(str);
                        if (stockManageData != null)
                        {
                            Boolean flag = false;


                            flag = WardSupplyBL.BackToInventoryTransfer(stockManageData, wardSupplyDbContext, currentUser);
                            if (flag)
                            {
                                responseData.Status  = "OK";
                                responseData.Results = 1;
                            }
                            else
                            {
                                responseData.ErrorMessage = "Transfer Item is null or failed to Save";
                                responseData.Status       = "Failed";
                            }
                        }
                    }
                    #endregion
                    #region POST : update stock tranaction, Post to Stock table and Transaction Table
                    else if (reqType == "breakage-stock")
                    {
                        WARDStockModel stockManageData = DanpheJSONConvert.DeserializeObject <WARDStockModel>(str);
                        if (stockManageData != null)
                        {
                            Boolean flag = false;

                            flag = WardSupplyBL.StockBreakage(stockManageData, wardSupplyDbContext, currentUser);
                            if (flag)
                            {
                                responseData.Status  = "OK";
                                responseData.Results = 1;
                            }
                            else
                            {
                                responseData.ErrorMessage = "Breakage item is null or failed to save";
                                responseData.Status       = "Failed";
                            }
                        }
                    }
                    #endregion
                    #region POST : Ward To Pharmacy Tranfer of Stock
                    else if (reqType == "returnStockToPharmacy")
                    {
                        List <WARDStockModel> stockManageData = DanpheJSONConvert.DeserializeObject <List <WARDStockModel> >(str);
                        if (stockManageData != null)
                        {
                            Boolean flag = false;

                            flag = WardSupplyBL.StockTransferToPharmacy(stockManageData, wardSupplyDbContext, phrmdbcontext, currentUser);
                            if (flag)
                            {
                                responseData.Status  = "OK";
                                responseData.Results = 1;
                            }
                            else
                            {
                                responseData.ErrorMessage = "Failed to save. Check the items.";
                                responseData.Status       = "Failed";
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    responseData.Status       = "Failed";
                    responseData.ErrorMessage = "Client Object is empty";
                }
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }

            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }