Exemplo n.º 1
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.º 2
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.º 3
0
    protected void btnSaveAdj_Click(object sender, EventArgs e)
    {
        try
        {
            if (seQuantity.Text == "0")
            {
                lblError.Visible = true;
                lblError.Text = "Invalid Quantity";
                return;
            }
            else
            {
                lblError.Visible = false;
                lblError.Text = "";
            }

            ItemStockAdjustment stock   = new ItemStockAdjustment();
            stock.Description           = txtDescription.Text.Trim();
            stock.Qty                   = Int32.Parse(seQuantity.Text);
            stock.ItemId                = ObjItem.ItemId;
            stock.UserId                = Master.LoggedUser.UserId;

            if (new ItemsDAO().AddItemsAdjustment(stock))
            {
                txtDescription.Text = string.Empty;
                seQuantity.Text = "0";

                LoadAlterations();
            }
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSaveAdj_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            else
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);

        }
    }