Example #1
0
        public bool SalesAdd(Model.StockOut stockOut)
        {
            string query = @"INSERT INTO StockOut VALUES('" + stockOut.CompanyId + "','"
                           + stockOut.CategoryId + "','" + stockOut.ItemId + "','"
                           + stockOut.StockOutQuantity + "','" + stockOut.StockOutDate + "','"
                           + stockOut.StockOutType + "')";

            SqlCommand command = new SqlCommand(query, _con);

            _con.Open();

            bool isRowAffectred = command.ExecuteNonQuery() > 0;

            _con.Close();
            /// *************************** //


            // Show Item Available Quantity
            string     queryItemAvailable = "SELECT * FROM ItemAvailableQuantity WHERE ItemId='" + stockOut.ItemId + "'";
            SqlCommand command_available  = new SqlCommand(queryItemAvailable, _con);

            _con.Open();
            SqlDataReader drAvailable = command_available.ExecuteReader();

            if (drAvailable.Read())
            {
                // student.Name = dr.GetValue(2).ToString();
                int stockInAvailableQty    = Convert.ToInt32(drAvailable["AvailableQuantity"]);
                int UpdateStockOutQuantity = stockInAvailableQty - stockOut.StockOutQuantity;

                _con.Close();
                // ******************
                string query_update = @"UPDATE ItemAvailableQuantity SET AvailableQuantity='" + UpdateStockOutQuantity + "' WHERE ItemId='" + stockOut.ItemId + "' ";

                SqlCommand command_update = new SqlCommand(query_update, _con);
                _con.Open();

                bool isRowAffectred1 = command_update.ExecuteNonQuery() > 0;

                _con.Close();

                // ************************ //
            }
            _con.Close();



            return(isRowAffectred);
        }
Example #2
0
        public bool LostAdd(Model.StockOut stockOut)
        {
            bool isAdded = _stockOutRepository.LostAdd(stockOut);

            return(isAdded);
        }
Example #3
0
        public bool DamageAdd(Model.StockOut stockOut)
        {
            bool isAdded = _stockOutRepository.DamageAdd(stockOut);

            return(isAdded);
        }