Exemple #1
0
        public void saveSaleInfo(StockManagement tempSale)
        {
            string        connect       = @"Server = DESKTOP-NRHJE6N\SQLEXPRESS; Database = Stock Management; Integrated Security = true";
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        query         = "INSERT INTO Sale (ItemName,Customer,Quantity, UnitPrice, TotalPrice) " +
                                          "VALUES('" + tempSale.itemName + "', '" + tempSale.customerName + "','" + tempSale.quantity + "', '" + tempSale.unitPrice + "','" + tempSale.totalPrice + "');";
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            int rowsAffected = sqlCommand.ExecuteNonQuery();

            sqlConnection.Close();

            if (rowsAffected > 0)
            {
                MessageBox.Show("Successfully Saved");
            }
            else
            {
                MessageBox.Show("Something went wrong");
            }

            //Data Grid View

            sqlConnection.Open();
            SqlDataAdapter purchaseView  = new SqlDataAdapter("SELECT * from Sale", sqlConnection);
            DataTable      purchaseTable = new DataTable();

            purchaseView.Fill(purchaseTable);
            saleDataGridView.DataSource = purchaseTable;

            populateComboBox();
            populateCustomerComboBox();
        }
        public void saveCustomer(StockManagement customerInfo)
        {
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        sqlQuery      = "INSERT INTO Customer(CustomerName,CustomerPhone)VALUES('" + customerInfo.customerName + "','" + customerInfo.customerPhone + "')";
            SqlCommand    sqlCommand    = new SqlCommand(sqlQuery, sqlConnection);

            sqlConnection.Open();
            int rowAffected = sqlCommand.ExecuteNonQuery();

            sqlConnection.Close();
            if (rowAffected >= 0)
            {
                MessageBox.Show("Data Save Successfully..!");
            }
            else
            {
                MessageBox.Show("Data not Saved");
            }

            sqlConnection.Open();
            SqlDataAdapter customerView  = new SqlDataAdapter("SELECT * from Customer", sqlConnection);
            DataTable      customerTable = new DataTable();

            customerView.Fill(customerTable);
            customerDataGridView.DataSource = customerTable;
        }
Exemple #3
0
        public void saveItem(StockManagement itemInfo)
        {
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        sqlQuery      = "INSERT INTO Items(itemName,itemCode)VALUES('" + itemInfo.itemName + "','" + itemInfo.itemCode + "')";
            SqlCommand    sqlCommand    = new SqlCommand(sqlQuery, sqlConnection);

            sqlConnection.Open();
            int rowAffected = sqlCommand.ExecuteNonQuery();

            sqlConnection.Close();
            if (rowAffected >= 0)
            {
                MessageBox.Show("Data Save Successfully..!");
            }
            else
            {
                MessageBox.Show("Data not Saved");
            }

            sqlConnection.Open();
            SqlDataAdapter itemView  = new SqlDataAdapter("SELECT * from Items", sqlConnection);
            DataTable      itemTable = new DataTable();

            itemView.Fill(itemTable);
            itemDataGridView.DataSource = itemTable;
        }
Exemple #4
0
        public List <StockManagement> GetAllItems()
        {
            string queryString = @"Server = DESKTOP-NRHJE6N\SQLEXPRESS; Database = Stock Management; Integrated Security = true";

            SqlConnection connection = new SqlConnection(queryString);
            string        query      = "SELECT * FROM Items;";
            SqlCommand    command    = new SqlCommand(query, connection);

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

            List <StockManagement> items = new List <StockManagement>();


            while (reader.Read())
            {
                StockManagement item = new StockManagement();
                item.itemName = reader["itemName"].ToString();
                item.itemCode = reader["itemCode"].ToString();
                items.Add(item);
            }


            return(items);
        }
        private void customerSaveButton_Click(object sender, EventArgs e)
        {
            StockManagement customer = new StockManagement();

            customer.customerName  = customerNametextBox.Text;
            customer.customerPhone = customerPhoneTextBox.Text;
            saveCustomer(customer);
        }
Exemple #6
0
        private void saveItemButton_Click(object sender, EventArgs e)
        {
            StockManagement items = new StockManagement();

            items.itemName = itemNameTextBox.Text;
            items.itemCode = itemCodeTextBox.Text;
            saveItem(items);
        }
Exemple #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            StockManagement sale = new StockManagement();

            sale.quantity     = saleQuantityTextBox.Text;
            sale.itemName     = saleItemNameComboBox.Text;
            sale.customerName = customerComboBox.Text;
            sale.unitPrice    = saleUnitPriceTextBox.Text;
            int total = Convert.ToInt32(saleQuantityTextBox.Text) * Convert.ToInt32(saleUnitPriceTextBox.Text);

            sale.totalPrice = saleTotalPriceTextBox.Text = total.ToString();
            saveSaleInfo(sale);
        }
Exemple #8
0
        private void savePurchaseButton_Click(object sender, EventArgs e)
        {
            StockManagement purchase = new StockManagement();

            purchase.itemName  = itemNameComboBox.Text;
            purchase.quantity  = purchaseQuantityTextBox.Text;
            purchase.unitPrice = purchaseUnitPriceTextBox.Text;
            int total = Convert.ToInt32(purchaseQuantityTextBox.Text) * Convert.ToInt32(purchaseUnitPriceTextBox.Text);

            //purchase.totalPrice = total.ToString();
            purchase.totalPrice = purchaseTotalPriceTextBox.Text = total.ToString();
            savePurchase(purchase);
            //populateComboBox();
        }
Exemple #9
0
        public List <StockManagement> GetAllICustomer()
        {
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        sqlQuery      = "SELECT * FROM Customer";
            SqlCommand    sqlCommand    = new SqlCommand(sqlQuery, sqlConnection);

            sqlConnection.Open();
            SqlDataReader          reader    = sqlCommand.ExecuteReader();
            List <StockManagement> customers = new List <StockManagement>();

            while (reader.Read())
            {
                StockManagement customerName = new StockManagement();
                customerName.customerName = reader["CustomerName"].ToString();
                customers.Add(customerName);
            }
            return(customers);
        }
Exemple #10
0
        public List <StockManagement> GetAllItems()
        {
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        sqlQuery      = "SELECT * FROM Items";
            SqlCommand    sqlCommand    = new SqlCommand(sqlQuery, sqlConnection);

            sqlConnection.Open();
            SqlDataReader          reader   = sqlCommand.ExecuteReader();
            List <StockManagement> purchase = new List <StockManagement>();

            while (reader.Read())
            {
                StockManagement purchaseItemName = new StockManagement();
                purchaseItemName.itemName = reader["itemName"].ToString();
                purchase.Add(purchaseItemName);
            }
            return(purchase);
        }
Exemple #11
0
        public List <StockManagement> GetAllIItem()
        {
            string        connect       = @"Server = DESKTOP-NRHJE6N\SQLEXPRESS; Database = Stock Management; Integrated Security = true";
            SqlConnection sqlConnection = new SqlConnection(connect);
            string        sqlQuery      = "SELECT * FROM Items";
            SqlCommand    sqlCommand    = new SqlCommand(sqlQuery, sqlConnection);

            sqlConnection.Open();
            SqlDataReader          reader = sqlCommand.ExecuteReader();
            List <StockManagement> sales  = new List <StockManagement>();

            while (reader.Read())
            {
                StockManagement saleItemName = new StockManagement();
                saleItemName.itemName = reader["itemName"].ToString();
                sales.Add(saleItemName);
            }
            return(sales);
        }