コード例 #1
0
        public int SetStockIn(StockInQuantity stockInQuantity)
        {
            query = "INSERT INTO StockIn (CompanyId,ItemId,Quantity,ReorderLevel,Date) VALUES ('" +
                    stockInQuantity.CompanyId + "','" + stockInQuantity.ItemId + "','" + stockInQuantity.StockQuantity +
                    "','" + stockInQuantity.ReorderLevel + "','" + stockInQuantity.Date + "')";
            command = new SqlCommand(query, connection);
            connection.Open();
            int rowAffect = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffect);
        }
コード例 #2
0
        public bool IsItemExist(StockInQuantity stockInQuantity)
        {
            query               = "SELECT * FROM StockIn WHERE CompanyId='" + stockInQuantity.CompanyId + "' AND ItemId='" + stockInQuantity.ItemId + "'";
            command             = new SqlCommand();
            command.CommandText = query;
            command.Connection  = connection;
            command.Connection.Open();
            reader = command.ExecuteReader();
            bool IsExist = reader.HasRows;

            reader.Close();
            connection.Close();
            return(IsExist);
        }
コード例 #3
0
        public string SetStockIn(StockInQuantity stockInQuantity)
        {
            if (stockInQuantityGeteway.IsItemExist(stockInQuantity))
            {
                stockInQuantityGeteway.SetStockIn(stockInQuantity);
                return("Update Successfully");
            }

            int rowAffect = stockInQuantityGeteway.SetStockIn(stockInQuantity);

            if (rowAffect > 0)
            {
                return("Store Successfully");
            }
            return("Store Failed");
        }
コード例 #4
0
        private void saveQuantityButton_Click(object sender, EventArgs e)
        {
            if ((int)companyNameComboBox.SelectedValue == -1)
            {
                MessageBox.Show("Please Select a Company");
                return;
            }
            if ((int)itemComboBox.SelectedValue == -1)
            {
                MessageBox.Show("Please Select a Item");
                return;
            }
            StockInQuantity stockInQuantity = new StockInQuantity();

            stockInQuantity.CompanyId         = (int)companyNameComboBox.SelectedValue;
            stockInQuantity.ItemId            = (int)itemComboBox.SelectedValue;
            stockInQuantity.ReorderLevel      = Convert.ToInt32(reorderlevelTextBox.Text);
            stockInQuantity.AvailableQuantity = Convert.ToInt32(availableQuantityTextBox.Text);
            int Quantity;

            if (int.TryParse(stockInQuantityTextBox.Text, out Quantity))
            {
                if (Quantity > 0)
                {
                    int availableQuantity = Convert.ToInt32(availableQuantityTextBox.Text);
                    stockInQuantity.StockQuantity = Quantity + availableQuantity;
                }
                else
                {
                    MessageBox.Show("Please Enter Amount for Stock");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Invalid Value");
                return;
            }
            stockInQuantity.Date = DateTime.Now;
            MessageBox.Show(stockInQuantityManager.SetStockIn(stockInQuantity));
            companyNameComboBox.SelectedValue = -1;
            itemComboBox.SelectedValue        = -1;
            reorderlevelTextBox.Clear();
            availableQuantityTextBox.Clear();
            stockInQuantityTextBox.Clear();
        }
コード例 #5
0
        public StockInQuantity GetAvailableQuantity(int itemId)
        {
            query   = "SELECT Quantity,ReorderLevel FROM StockIn WHERE ItemId='" + itemId + "'";
            command = new SqlCommand(query, connection);
            connection.Open();
            StockInQuantity stockIn = null;

            reader = command.ExecuteReader();
            while (reader.Read())
            {
                stockIn = new StockInQuantity();
                stockIn.AvailableQuantity = (int)reader["Quantity"];
                stockIn.ReorderLevel      = (int)reader["ReorderLevel"];
            }
            reader.Close();
            connection.Close();
            return(stockIn);
        }
コード例 #6
0
        private void itemNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Item item = itemNameComboBox.SelectedItem as Item;

            reorderlevelTextBox.Text = item.Reorderlevel.ToString();
            StockInQuantity newQuantity = new StockInQuantity();
            int             itemId;

            int.TryParse(itemNameComboBox.SelectedValue.ToString(), out itemId);
            StockInQuantity stockIn = stockInQuantityManager.GetAvailableQuantity(itemId);

            if (stockIn != null)
            {
                availableQuantityTextBox.Text = stockIn.AvailableQuantity.ToString();
            }
            else
            {
                availableQuantityTextBox.Text = newQuantity.Quantity.ToString();
            }
        }