Exemplo n.º 1
0
        public bool AddItems(Item item)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Insert);

                db.AddInParameter(dbCommand, "@sItemCode", DbType.String, item.ItemCode);
                db.AddInParameter(dbCommand, "@sItemDescription", DbType.String, item.ItemDescription);
                db.AddInParameter(dbCommand, "@mCost", DbType.Currency, item.Cost);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, item.SellingPrice);
                db.AddInParameter(dbCommand, "@bIsActive", DbType.Boolean, item.IsActive);
                db.AddInParameter(dbCommand, "@iCategoryId", DbType.Int32, item.CategoryId);
                db.AddInParameter(dbCommand, "@iUpdatedUser", DbType.Int32, item.UpdatedUser);
                db.AddInParameter(dbCommand, "@biQuantityInHand", DbType.Int64, item.QuantityInHand);
                db.AddInParameter(dbCommand, "@biFreezedQty", DbType.Int64, item.FreezedQty);
                db.AddInParameter(dbCommand, "@iROL", DbType.Int32, item.ROL);
                db.AddInParameter(dbCommand, "@iBrandId", DbType.Int32, item.BrandId);
                db.AddInParameter(dbCommand, "@mMinSellingPrice", DbType.Currency, item.MinSellingPrice);
                db.AddInParameter(dbCommand, "@iInvoicedQty", DbType.Int32, item.InvoicedQty);

                if (item.IType.TypeId == -1)
                {
                    db.AddInParameter(dbCommand, "@iTypeId", DbType.Int32, DBNull.Value);
                }
                else
                {
                    db.AddInParameter(dbCommand, "@iTypeId", DbType.Int32, item.IType.TypeId);
                }

                db.AddOutParameter(dbCommand, "@iItemId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newItemID = (int)db.GetParameterValue(dbCommand, "@iItemId");

                    if (newItemID > 0)
                    {
                        success = true;
                        item.ItemId = newItemID;
                    }
                }

                if (success)
                {
                    ItemHistory itemHistory = new ItemHistory(item);
                    itemHistory.HistoryTypeId = Structures.ItemHistoryTypes.CreateItem;
                    AddItemsHistory(itemHistory, null);
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItems(Item item)");
                throw ex;
            }
            return success;
        }
Exemplo n.º 2
0
        public bool AddItems(Item item)
        {
            bool success = false;

            try
            {
                Database  db        = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Insert);

                db.AddInParameter(dbCommand, "@sItemCode", DbType.String, item.ItemCode);
                db.AddInParameter(dbCommand, "@sItemDescription", DbType.String, item.ItemDescription);
                db.AddInParameter(dbCommand, "@mCost", DbType.Currency, item.Cost);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, item.SellingPrice);
                db.AddInParameter(dbCommand, "@bIsActive", DbType.Boolean, item.IsActive);
                db.AddInParameter(dbCommand, "@iCategoryId", DbType.Int32, item.CategoryId);
                db.AddInParameter(dbCommand, "@iUpdatedUser", DbType.Int32, item.UpdatedUser);
                db.AddInParameter(dbCommand, "@biQuantityInHand", DbType.Int64, item.QuantityInHand);
                db.AddInParameter(dbCommand, "@biFreezedQty", DbType.Int64, item.FreezedQty);
                db.AddInParameter(dbCommand, "@iROL", DbType.Int32, item.ROL);
                db.AddInParameter(dbCommand, "@iBrandId", DbType.Int32, item.BrandId);
                db.AddInParameter(dbCommand, "@mMinSellingPrice", DbType.Currency, item.MinSellingPrice);
                db.AddInParameter(dbCommand, "@iInvoicedQty", DbType.Int32, item.InvoicedQty);

                if (item.IType.TypeId == -1)
                {
                    db.AddInParameter(dbCommand, "@iTypeId", DbType.Int32, DBNull.Value);
                }
                else
                {
                    db.AddInParameter(dbCommand, "@iTypeId", DbType.Int32, item.IType.TypeId);
                }

                db.AddOutParameter(dbCommand, "@iItemId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newItemID = (int)db.GetParameterValue(dbCommand, "@iItemId");

                    if (newItemID > 0)
                    {
                        success     = true;
                        item.ItemId = newItemID;
                    }
                }

                if (success)
                {
                    ItemHistory itemHistory = new ItemHistory(item);
                    itemHistory.HistoryTypeId = Structures.ItemHistoryTypes.CreateItem;
                    AddItemsHistory(itemHistory, null);
                }
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItems(Item item)");
                throw ex;
            }
            return(success);
        }
Exemplo n.º 3
0
        ///
        /// Item stock adjustment methods
        ///
        #region Add History

        public bool AddItemsHistory(ItemHistory itemAdj, DbTransaction transaction)
        {
            bool success = false;

            try
            {
                Database  db        = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand("SP_Items_InsItemsHistory");

                db.AddInParameter(dbCommand, "@iItemId", DbType.Int32, itemAdj.ItemId);
                db.AddInParameter(dbCommand, "@sDescription", DbType.String, itemAdj.Description);
                db.AddInParameter(dbCommand, "@iQty", DbType.Int32, itemAdj.Qty);
                db.AddInParameter(dbCommand, "@mCost", DbType.Currency, itemAdj.Cost);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, itemAdj.SellingPrice);
                db.AddInParameter(dbCommand, "@iUserId", DbType.Int32, itemAdj.UserId);
                db.AddInParameter(dbCommand, "@sRefNo", DbType.String, itemAdj.RefNo);
                db.AddInParameter(dbCommand, "@iHistoryTypeId", DbType.Int32, (int)itemAdj.HistoryTypeId);
                //db.AddInParameter(dbCommand, "@iCreatedBy", DbType.Int32, itemAdj.UserId);
//                db.AddOutParameter(dbCommand, "@iHistoryId", DbType.Int64, 16);

                int rowCount = 0;

                if (transaction == null)
                {
                    rowCount = db.ExecuteNonQuery(dbCommand);
                }
                else
                {
                    rowCount = db.ExecuteNonQuery(dbCommand, transaction);
                }

                if (rowCount > 0)
                {
                    //int newID = (int)db.GetParameterValue(dbCommand, "@iHistoryId");

                    //if (newID > 0)
                    //{
                    success = true;
                    //itemAdj.HistoryId = newID;
                    //}
                }
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItemsHistory(ItemHistory itemAdj)");
                throw ex;
            }
            return(success);
        }
Exemplo n.º 4
0
        ///
        /// Item stock adjustment methods
        ///
        #region Add Adjustment

        public bool AddItemsAdjustment(ItemStockAdjustment itemAdj)
        {
            bool success = false;

            try
            {
                Database  db        = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Adjustment_InsItems);

                db.AddInParameter(dbCommand, "@iItemId", DbType.Int32, itemAdj.ItemId);
                db.AddInParameter(dbCommand, "@sDescription", DbType.String, itemAdj.Description);
                db.AddInParameter(dbCommand, "@iQty", DbType.Int32, itemAdj.Qty);
                db.AddInParameter(dbCommand, "@iCreatedBy", DbType.Int32, itemAdj.UserId);
                db.AddOutParameter(dbCommand, "@iId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newID = (int)db.GetParameterValue(dbCommand, "@iId");

                    if (newID > 0)
                    {
                        success    = true;
                        itemAdj.Id = newID;
                    }
                }

                if (success)
                {
                    Item item = new Item();
                    item.ItemId = itemAdj.ItemId;
                    this.GetItemsByID(item);

                    ItemHistory itemHistory = new ItemHistory(item);
                    itemHistory.HistoryTypeId = Structures.ItemHistoryTypes.StockAdjustment;
                    itemHistory.UserId        = itemAdj.UserId;
                    itemHistory.Qty           = itemAdj.Qty;
                    itemHistory.RefNo         = itemAdj.Id.ToString();

                    AddItemsHistory(itemHistory, null);
                }
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItemsAdjustment(ItemStockAdjustment itemAdj)");
                throw ex;
            }
            return(success);
        }
Exemplo n.º 5
0
        public bool AddItemsAdjustment(ItemStockAdjustment itemAdj)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Items_Adjustment_InsItems);

                db.AddInParameter(dbCommand, "@iItemId", DbType.Int32, itemAdj.ItemId);
                db.AddInParameter(dbCommand, "@sDescription", DbType.String, itemAdj.Description);
                db.AddInParameter(dbCommand, "@iQty", DbType.Int32, itemAdj.Qty);
                db.AddInParameter(dbCommand, "@iCreatedBy", DbType.Int32, itemAdj.UserId);
                db.AddOutParameter(dbCommand, "@iId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newID = (int)db.GetParameterValue(dbCommand, "@iId");

                    if (newID > 0)
                    {
                        success = true;
                        itemAdj.Id = newID;
                    }
                }

                if (success)
                {
                    Item item = new Item();
                    item.ItemId = itemAdj.ItemId;
                    this.GetItemsByID(item);

                    ItemHistory itemHistory = new ItemHistory(item);
                    itemHistory.HistoryTypeId = Structures.ItemHistoryTypes.StockAdjustment;
                    itemHistory.UserId = itemAdj.UserId;
                    itemHistory.Qty = itemAdj.Qty;
                    itemHistory.RefNo = itemAdj.Id.ToString();

                    AddItemsHistory(itemHistory, null);
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItemsAdjustment(ItemStockAdjustment itemAdj)");
                throw ex;
            }
            return success;
        }
Exemplo n.º 6
0
        public bool AddItemsHistory(ItemHistory itemAdj, DbTransaction transaction)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand("SP_Items_InsItemsHistory");

                db.AddInParameter(dbCommand, "@iItemId", DbType.Int32, itemAdj.ItemId);
                db.AddInParameter(dbCommand, "@sDescription", DbType.String, itemAdj.Description);
                db.AddInParameter(dbCommand, "@iQty", DbType.Int32, itemAdj.Qty);
                db.AddInParameter(dbCommand, "@mCost", DbType.Currency, itemAdj.Cost);
                db.AddInParameter(dbCommand, "@mSellingPrice", DbType.Currency, itemAdj.SellingPrice);
                db.AddInParameter(dbCommand, "@iUserId", DbType.Int32, itemAdj.UserId);
                db.AddInParameter(dbCommand, "@sRefNo", DbType.String, itemAdj.RefNo);
                db.AddInParameter(dbCommand, "@iHistoryTypeId", DbType.Int32, (int)itemAdj.HistoryTypeId);
                //db.AddInParameter(dbCommand, "@iCreatedBy", DbType.Int32, itemAdj.UserId);
            //                db.AddOutParameter(dbCommand, "@iHistoryId", DbType.Int64, 16);

                int rowCount = 0;

                if (transaction == null)
                {
                    rowCount = db.ExecuteNonQuery(dbCommand);
                }
                else
                {
                    rowCount = db.ExecuteNonQuery(dbCommand, transaction);
                }

                if (rowCount > 0)
                {
                    //int newID = (int)db.GetParameterValue(dbCommand, "@iHistoryId");

                    //if (newID > 0)
                    //{
                        success = true;
                        //itemAdj.HistoryId = newID;
                    //}
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItemsHistory(ItemHistory itemAdj)");
                throw ex;
            }
            return success;
        }