private void GenerateReport()
        {
            SqlConnection conn = new SqlConnection("Data Source=TAMEEMTTG;Initial Catalog=CableMDB;Integrated Security=True");

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("LOAD_HISTORY_BY_USERID", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@USERID", user_id));

                SqlDataReader reader;

                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    user.HistoryId  = int.Parse(reader["HISTORY_ID"].ToString());
                    user.UserId     = int.Parse(reader["USER_ID"].ToString());
                    user.Name       = reader["NAME"].ToString();
                    user.HouseNo    = reader["HOUSE"].ToString();
                    user.Payment    = int.Parse(reader["PAYMENT"].ToString());
                    user.ReceivedBy = reader["RECEIVED BY"].ToString();
                    user.Month      = reader["MONTH"].ToString();
                    //#    user.Status = int.Parse(reader["STATUS"].ToString());
                    usersHistory.Add(user);
                }

                // generate report from above information
                GenReport report = new GenReport();
                report.CreateDocument("Cable Coporation", "Billing History", usersHistory);

                conn.Close();
            }
            catch (Exception e) { MessageBox.Show(e.ToString()); }
        }
Exemplo n.º 2
0
        private void InventoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(ConnectionString.connectionString);
                conn.Open();
                SqlCommand    cmd    = new SqlCommand("SELECT * FROM INVENTORY", conn);
                SqlDataReader reader = cmd.ExecuteReader();

                string[]      colName = { "ITEM_NO", "ITEM", "QUANTITY" };
                string        data;
                List <string> inventoryItem = new List <string>();
                while (reader.Read())
                {
                    for (int i = 0; i < colName.Length; i++)
                    {
                        data = reader[colName[i]].ToString();
                        Console.WriteLine(data);
                        inventoryItem.Add(data);
                    }
                }


                GenReport.CreateDocumentInventory("Cable Co", "Inventory Report", inventoryItem);
                conn.Close();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        private void GenerateReport()
        {
            // column name for billing history
            // change this col names for your server
            string[] colName = { "HISTORY_ID", "USER_ID", "NAME", "HOUSE", "PAYMENT", "RECEIVED BY", "MONTH", "STATUS" };

            if (user_id == "")
            {
                MessageBox.Show("Please Select Row Of which you want to generate report");
            }
            else
            {
                int userId = int.Parse(user_id);

                try
                {
                    SqlConnection conn = new SqlConnection(ConnectionString.connectionString);

                    conn.Open();

                    /*only for testing use stored procedure*/
                    // change this for your revelant
                    SqlCommand cmd = new SqlCommand("LOAD_HISTORY_BY_USERID", conn);

                    /* uncommen for actual implementation  */

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@USERID", user_id));

                    SqlDataReader reader;
                    reader = cmd.ExecuteReader();

                    string data;

                    while (reader.Read())
                    {
                        // save all data into string array
                        for (int j = 0; j < colName.Length; j++)
                        {
                            data = reader[colName[j]].ToString();

                            dataUser.Add(data);
                        }
                    }

                    // generate report from above information
                    GenReport.CreateDocumentHistory("Cable Co", "Billing History", dataUser);

                    conn.Close();
                }
                catch (Exception e) { MessageBox.Show(e.ToString()); }
            } // end of else
        }