public bool Update(StockInClass stockIn)
        {
            bool       isUpdated;
            SqlCommand command = new SqlCommand(@"SELECT * FROM Transanction
INNER JOIN Item On Item.ItemId=Transanction.ItemId
 WHERE Item.ItemName='" + stockIn.ItemName + "'", connection);

            connection.Open();
            //  SqlDataAdapter da = new SqlDataAdapter(command);
            SqlDataReader dr = command.ExecuteReader();

            if (dr.HasRows)
            {
                connection.Close();
                connection.Open();
                SqlCommand command2 = new SqlCommand(@"Update Transanction Set AvailableQuantity='" + stockIn.AvailableQuantity + "'Where ItemId='" + stockIn.ItemId + "'", connection);
                isUpdated = command2.ExecuteNonQuery() > 0;
            }
            else
            {
                connection.Close();
                connection.Open();
                SqlCommand command2 = new SqlCommand(@"INSERT INTO Transanction(ItemId,AvailableQuantity) values('" + stockIn.ItemId + "','" + stockIn.AvailableQuantity + "')", connection);
                isUpdated = command2.ExecuteNonQuery() > 0;
            }
            connection.Close();
            return(isUpdated);
        }
        //*****************************************************************//



        private void SaveButton_Click(object sender, EventArgs e)
        {
            StockInClass stockIn = new StockInClass();

            if (itemComboBox.SelectedItem == null)
            {
                MessageBox.Show("Plaease select an Item");
                return;
            }
            if (categoryComboBox.SelectedItem == null)
            {
                MessageBox.Show("Plaease select an Category");
                return;
            }
            if (companyComboBox.SelectedItem == null)
            {
                MessageBox.Show("Plaease select an Company");
                return;
            }
            stockIn.ItemName = itemComboBox.Text;

            stockIn.ItemId = stockInManager.GetItemId(stockIn);


            stockIn.AvailableQuantity = Convert.ToInt32(availableQuantityLabel.Text);
            bool isTrue = stockInManager.Validation(quantityTextBox.Text);

            if (!isTrue)
            {
                MessageBox.Show("Please Enter a Valid Number!");
                return;
            }
            stockIn.StockInQuantity    = Convert.ToInt32(quantityTextBox.Text);
            stockIn.AvailableQuantity += stockIn.StockInQuantity;
            bool isAdded = stockInManager.Update(stockIn);

            if (isAdded)
            {
                MessageBox.Show("Stock In Succesful!");
                quantityTextBox.Text = String.Empty;
            }
            else
            {
                MessageBox.Show("Stock In Failed!");
            }
            categoryComboBox.Text       = "------Select--------";
            companyComboBox.Text        = "------Select--------";
            itemComboBox.Text           = "------Select--------";
            reorderLevelLabel.Text      = String.Empty;
            availableQuantityLabel.Text = String.Empty;
        }
        public int GetItemId(StockInClass stockIn)
        {
            int        itemId  = 0;
            SqlCommand command = new SqlCommand(@"Select ItemId From Item WHERE ItemName='" + stockIn.ItemName + "'", connection);

            connection.Open();
            SqlDataReader dr = command.ExecuteReader();

            if (dr.Read())
            {
                itemId = (int)dr["ItemId"];
            }
            connection.Close();
            return(itemId);
        }
        public int GetItemId(StockInClass stockIn)
        {
            int itemId = stockInRepository.GetItemId(stockIn);

            return(itemId);
        }
        public bool Update(StockInClass stockIn)
        {
            bool isAdded = stockInRepository.Update(stockIn);

            return(isAdded);
        }