public List <StocksIn> GetAllStocks(string size, string code, int Id)
        {
            var    _StocksInList = new List <StocksIn>();
            string query         = ("Select *From StockIn Where Size='" + size + "' And ItemCode='" + code + "' And CategoriesId='" + Id + "' And Date='" + DateTime.Now.ToShortDateString() + "'");
            var    reader        = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var _StocksIn = new StocksIn();

                    _StocksIn.Id       = Convert.ToInt32(reader["Id"].ToString());
                    _StocksIn.ItemCode = (reader["ItemCode"].ToString());
                    _StocksIn.Quantity = Convert.ToInt32(reader["Quantity"].ToString());
                    _StocksIn.UnitCost = Convert.ToDecimal(reader["UnitCost"].ToString());
                    _StocksIn.Mrp      = Convert.ToDecimal(reader["Mrp"].ToString());
                    _StocksIn.Date     = (reader["Date"].ToString());

                    _StocksInList.Add(_StocksIn);
                }
            }
            reader.Close();

            return(_StocksInList);
        }
Exemple #2
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (CategoriesDropDownList.SelectedIndex > 0)
                {
                    StocksIn _StocksIn = new StocksIn();
                    _StocksIn.Quantity     = Convert.ToInt32(txtQty.Text);
                    _StocksIn.Size         = SizeDropDownList.SelectedItem.ToString();
                    _StocksIn.UnitCost     = Convert.ToDecimal(txtCost.Text);
                    _StocksIn.Mrp          = Convert.ToDecimal(txtMrp.Text);
                    _StocksIn.ItemName     = ItemsDropDownList.SelectedItem.ToString();
                    _StocksIn.ItemCode     = (txtCode.Text);
                    _StocksIn.CategoriesId = Convert.ToInt32(CategoriesDropDownList.SelectedValue);

                    int SaveSuccess = _StocksInRepository.Add(_StocksIn);
                    if (SaveSuccess > 0)
                    {
                        ShowMessage("Successfully Add Stock....", MessageType.Success);
                        LoadStocks();
                        GetAllCategories();
                        Refresh();
                        //Response.Redirect(Request.Url.AbsoluteUri);
                    }
                    else
                    {
                        ShowMessage("Failed Stock Input....", MessageType.Success);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, MessageType.Success);
            }
        }
        private bool Add(StocksIn stocksIn)
        {
            bool isSucces = false;

            try
            {
                sqlConnection = new SqlConnection(connectionString);

                string query = @"INSERT INTO StockIn (ItemId, Quantity) VALUES ( " + stocksIn.ItemId + "," + stocksIn.Quantity + ")";

                //5
                SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
                //6
                sqlConnection.Open();
                //7
                int isExecuted = sqlCommand.ExecuteNonQuery();
                if (isExecuted > 0)
                {
                    isSucces = true;
                }
                else
                {
                    isSucces = false;
                }

                //8
                sqlConnection.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            return(isSucces);
        }
Exemple #4
0
        public bool Add(StocksIn stockIn, long availableQuantity)
        {
            SqlConnection con   = new SqlConnection(_conString);
            string        query = @"insert into Stocks values('" + stockIn.ItemId + "','" + availableQuantity + "')";
            SqlCommand    com   = new SqlCommand(query, con);

            con.Open();
            bool rowAffect = com.ExecuteNonQuery() > 0;

            con.Close();
            return(rowAffect);
        }
Exemple #5
0
        public DataTable LoadCompanyDropDown(StocksIn stocks)
        {
            SqlConnection con   = new SqlConnection(_conString);
            string        query = "SELECT * FROM Companies";
            SqlCommand    com   = new SqlCommand(query, con);

            con.Open();
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(com);

            da.Fill(dt);
            con.Close();
            return(dt);
        }
Exemple #6
0
        public StocksIn GetDataByCode(string code)
        {
            StocksIn _StocksIn = null;

            string query  = ("Select top 1 * from StockIn Where ItemCode = '" + code + "' order by Id desc");
            var    reader = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                reader.Read();
                _StocksIn          = new StocksIn();
                _StocksIn.ItemName = (reader["ItemName"].ToString());
                _StocksIn.Mrp      = Convert.ToDecimal(reader["Mrp"].ToString());
            }
            reader.Close();

            return(_StocksIn);
        }
        public StocksIn GetQtyByCode(string code)
        {
            StocksIn _StocksIn = null;

            string query  = ("Select top 1 *from StockIn Where ItemCode='" + code + "' And Date='" + DateTime.Now.ToShortDateString() + "' order by Quantity desc");
            var    reader = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                reader.Read();
                _StocksIn = new StocksIn();

                _StocksIn.Quantity = Convert.ToInt32(reader["Quantity"].ToString());
            }
            reader.Close();

            return(_StocksIn);
        }
Exemple #8
0
        public long availableQuantituLabel(long id1)
        {
            SqlConnection con = new SqlConnection(_conString);
            // string query = @"select StockIn from Stocks  where Id=( select max (Id) from Stocks) and ItemId='" +id1+ "'";
            string     query = @"select StockIn from Stocks  where ItemId='" + id1 + "' and Id=(select max (Id)from Stocks where ItemId='" + id1 + "');";
            SqlCommand com   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader dr = com.ExecuteReader();

            if (dr.HasRows)
            {
                StocksIn stocksIn = new StocksIn();
                if (dr.Read())
                {
                    stocksIn.StockIn = Convert.ToInt64(dr["StockIn"].ToString());
                }

                return(stocksIn.StockIn);
            }
            con.Close();
            return(0);
        }
        public int Add(StocksIn _StocksIn)
        {
            string query = "Insert Into StockIn(Quantity,Size,UnitCost,Mrp,ItemName,ItemCode,CategoriesId,Date) Values ('" + _StocksIn.Quantity + "','" + _StocksIn.Size + "','" + _StocksIn.UnitCost + "','" + _StocksIn.Mrp + "','" + _StocksIn.ItemName + "','" + _StocksIn.ItemCode + "','" + _StocksIn.CategoriesId + "','" + DateTime.Now.ToShortDateString() + "')";

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
Exemple #10
0
 public bool Add(StocksIn stockIn, long availableQuantity)
 {
     return(_stockInGetway.Add(stockIn, availableQuantity));
 }
Exemple #11
0
 public DataTable LoadCompanyDropDown(StocksIn stocks)
 {
     return(_stockInGetway.LoadCompanyDropDown(stocks));
 }