Оружейный магазин

Автор: Пользователь скрыл имя, 14 Января 2013 в 12:36, курсовая работа

Описание работы

В любой спроектированной системе есть свои цели и задачи. В данной работе целью является автоматизация учёта продаж боевых единиц, на основе объектно-ориентированного подхода к разработке информационных систем. Основной целью курсового проекта является написание программы на языке программирования – C# -, освоение принципов объектно-ориентированного программирования, получение навыков работы с базой данных.

Содержание

Введение…………………………………………………………………………...

4

Подготовительная работа……………..………………………………………….

5

Разработка требований пользователя к системе и ПО ………………………....

6

Сценарий работы системы………….……………………………………………

7

Проектирование архитектуры системы и анализ требований к ПО…………...

8

Детальное проектирование ПО. Характеристика компонентов системы……..

9

Тестирование……………………………………………………………………...

14

Модель базы данных……………………………..……………………….………

16

Описание выходных форм………………………..………………………………

18

Себестоимость…………………………………………………………………….

19

Код программы……………………………………………………………………

20

Заключение …………………………………………………………………........

35

Литература………………………………………………………………………..

Работа содержит 1 файл

Курсовая_Малый.doc

— 315.50 Кб (Скачать)

Следовательно, стоимость  данного программного продукта составила  14200 рублей.

 

 

 

 

 

 

 

 

 

 

 

Код программы

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        public static string strcon = "Data Source=COMP910-79;Initial Catalog=or_lavka;Integrated Security=false; User ID = student; Password = student;";

 

 

        private void выходToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Close();

        }

 

        private void видыОружияToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Form2 f2 = new Form2();

            f2.Show();

        }

 

        private void видыЛицензийToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Form3 f3 = new Form3();

            f3.Show();

        }

 

        private void необходимыеДокументыToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Form4 f4 = new Form4();

            f4.Show();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

        }

 

        private void характеристикаToolStripMenuItem_Click(object sender, EventArgs e)

        {

 

        }

 

        private void печатьToolStripMenuItem_Click(object sender, EventArgs e)

        {

 

        }

 

        private void прайслистToolStripMenuItem_Click(object sender, EventArgs e)

        {

 

            Form5 f5 = new Form5();

            f5.Show();

        }

 

        private void соглашениеToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Form6 f6 = new Form6();

            f6.Show();

        }

 

        private void оПрограммеToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Form7 f7 = new Form7();

            f7.Show();

        }

 

     

    }

}namespace Kursovik

{

    public partial class Form2 : Form

    {

SqlConnection conn = new SqlConnection();

        SqlCommand cmd = new SqlCommand();

        SqlDataReader rdr;

        public void tablica()

        {

            conn.ConnectionString = Form1.strcon;

            SqlDataAdapter da = new SqlDataAdapter("select * from vidor", conn);

            DataTable dt = new DataTable();

 

            da.Fill(dt);

            dataGridView1.DataSource = dt.DefaultView;

            dataGridView1.Columns[0].HeaderText = "Тип оружия";

            dataGridView1.Columns[1].HeaderText = "Номер";

            dataGridView1.Columns[2].HeaderText = "Колибр";

           

        }

        public Form2()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

          

            cmd.CommandText = "insert into vidor (tip,nomer,kalibr) values('" + textBox1.Text + "'," + textBox2.Text + "," + textBox3.Text + ")";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

            cmd.ExecuteNonQuery();

            conn.Close();

            tablica();

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

            cmd.CommandText = "select * from vidor where nomer= " + textBox2.Text + "";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

            rdr = cmd.ExecuteReader();

            rdr.Read();

            textBox1.Text = rdr.GetString(0);

            textBox3.Text = rdr.GetDecimal(2).ToString();

 

            conn.Close();

 

            tablica();

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

           

            cmd.CommandText = "select * from vidor where nomer=" + textBox2.Text;

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

 

            rdr = cmd.ExecuteReader();

 

 

            if (rdr.Read())

            {

 

                conn.Close();

                cmd.CommandText = "delete from vidor where nomer= " + textBox2.Text;

                cmd.CommandType = CommandType.Text;

                cmd.Connection = conn;

                conn.Open();

                cmd.ExecuteNonQuery();

                conn.Close();

                tablica();

            }

           else MessageBox.Show("Запись с таким кодом не существует");

        }

 

        private void Form2_Load(object sender, EventArgs e)

        {

 

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

 

            conn.ConnectionString = Form1.strcon;

 

 

 

            cmd.CommandText = "select * from vidor";

 

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

 

            cmd.ExecuteReader();

 

 

            conn.Close();

 

            tablica();

        }

    }

}

namespace Kursovik

{

    public partial class Form3 : Form

    {

SqlConnection conn = new SqlConnection();

        SqlCommand cmd = new SqlCommand();

        SqlDataReader rdr;

 

        public void tablica()

        {

 

            conn.ConnectionString = Form1.strcon;

            SqlDataAdapter da = new SqlDataAdapter("select * from vidlic", conn);

            DataTable dt = new DataTable();

 

            da.Fill(dt);

            dataGridView1.DataSource = dt.DefaultView;

            dataGridView1.Columns[0].HeaderText = "ФИО";

            dataGridView1.Columns[1].HeaderText = "Тип оружия";

            dataGridView1.Columns[2].HeaderText = "Тип лицензии";

            dataGridView1.Columns[3].HeaderText = "Срок действия";

        }

        public Form3()

        {

            InitializeComponent();

        }

 

        private void Form3_Load(object sender, EventArgs e)

        {

 

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

            cmd.CommandText = "insert into vidlic (FIO,tipor,tiplic, srok) values('" + textBox1.Text + "','" + comboBox1.Text + "','" + textBox4.Text + "'," + textBox3.Text + ")";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

            cmd.ExecuteNonQuery();

            conn.Close();

 

            tablica();

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

                    

            cmd.CommandText = "select * from vidlic where FIO='" + textBox1.Text + "'";

 

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

            rdr = cmd.ExecuteReader();

            rdr.Read();

            comboBox1.Text = rdr.GetString(1);

            textBox4.Text = rdr.GetString(2);

            textBox3.Text = rdr.GetInt32(3).ToString();

        

 

            conn.Close();

 

            tablica();

 

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

 

            conn.ConnectionString = Form1.strcon;

            cmd.CommandText = "delete from vidlic where FIO = '" + textBox1.Text + "'";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

            conn.Open();

            cmd.ExecuteNonQuery();

            conn.Close();

            tablica();

            }

 

        private void button4_Click(object sender, EventArgs e)

        {

 

            conn.ConnectionString = Form1.strcon;

 

 

 

            cmd.CommandText = "select * from vidlic";

 

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

 

            cmd.ExecuteReader();

 

 

            conn.Close();

 

            tablica();

        }

    }

}namespace Kursovik

{

    public partial class Form4 : Form

    {  

   SqlConnection conn = new SqlConnection();

        SqlCommand cmd = new SqlCommand();

        SqlDataReader rdr;

        public void tablica()

        {

            conn.ConnectionString = Form1.strcon;

            SqlDataAdapter da = new SqlDataAdapter("select * from neodok", conn);

            DataTable dt = new DataTable();

 

            da.Fill(dt);

            dataGridView1.DataSource = dt.DefaultView;

            dataGridView1.Columns[0].HeaderText = "ФИО";

            dataGridView1.Columns[1].HeaderText = "Мед. Заключение";

            dataGridView1.Columns[2].HeaderText = "Фотографии";

            dataGridView1.Columns[3].HeaderText = "Дата сдачи";

        }

        public Form4()

        {

            InitializeComponent();

        }

 

        private void Form4_Load(object sender, EventArgs e)

        {

 

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

 

            cmd.CommandText = "insert into neodok (FIO,medzak,foto,datasdachi) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox3.Text + "')";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

            cmd.ExecuteNonQuery();

            conn.Close();

            tablica();

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

            cmd.CommandText = "select * from neodok where FIO= '" + textBox1.Text + "'";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

            rdr = cmd.ExecuteReader();

            rdr.Read();

            textBox2.Text = rdr.GetString(1);

            textBox4.Text = rdr.GetString(2);

            textBox3.Text = rdr.GetDateTime(3).ToLongDateString();

 

            conn.Close();

 

            tablica();

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

 

            cmd.CommandText = "select * from neodok where FIO='" + textBox1.Text+"'";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

 

            rdr = cmd.ExecuteReader();

 

 

            if (rdr.Read())

            {

 

                conn.Close();

 

                cmd.CommandText = "delete from neodok where FIO = '" + textBox1.Text+"'";

                cmd.CommandType = CommandType.Text;

                cmd.Connection = conn;

                conn.Open();

                cmd.ExecuteNonQuery();

                conn.Close();

                tablica();

            }

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

 

            conn.ConnectionString = Form1.strcon;

 

 

 

            cmd.CommandText = "select * from neodok";

 

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

 

            cmd.ExecuteReader();

 

 

            conn.Close();

 

            tablica();

        }

    }

}         }

namespace Kursovik

{

    public partial class Form5 : Form

    {  

SqlConnection conn = new SqlConnection();

        SqlCommand cmd = new SqlCommand();

        SqlDataReader rdr;

        public void tablica()

        {

            conn.ConnectionString = Form1.strcon;

            SqlDataAdapter da = new SqlDataAdapter("select * from prayslist", conn);

            DataTable dt = new DataTable();

 

            da.Fill(dt);

            dataGridView1.DataSource = dt.DefaultView;

            dataGridView1.Columns[0].HeaderText = "Орудие";

            dataGridView1.Columns[1].HeaderText = "Характеристика";

            dataGridView1.Columns[2].HeaderText = "Цена";

        }

        public Form5()

        {

            InitializeComponent();

        }

 

        private void Form5_Load(object sender, EventArgs e)

        {

 

        }

 

        private void label3_Click(object sender, EventArgs e)

        {

 

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

 

            cmd.CommandText = "insert into prayslist (oru,xar,cena) values('" + textBox1.Text + "','" + textBox2.Text + "'," + textBox3.Text + ")";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

            cmd.ExecuteNonQuery();

            conn.Close();

            tablica();

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

         

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            conn.ConnectionString = Form1.strcon;

 

            cmd.CommandText = "select * from prayslist where oru= '" + textBox1.Text + "'";

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

            conn.Open();

 

            rdr = cmd.ExecuteReader();

 

 

            if (rdr.Read())

            {

 

                conn.Close();

                cmd.CommandText = "delete from prayslist where oru= '" + textBox1.Text + "'";

                cmd.CommandType = CommandType.Text;

                cmd.Connection = conn;

                conn.Open();

                cmd.ExecuteNonQuery();

                conn.Close();

                tablica();

            }

            else MessageBox.Show("Запись с таким кодом не существует");

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

 

            conn.ConnectionString = Form1.strcon;

 

 

 

            cmd.CommandText = "select * from prayslist";

 

            cmd.CommandType = CommandType.Text;

            cmd.Connection = conn;

 

 

            conn.Open();

 

 

 

            cmd.ExecuteReader();

 

 

            conn.Close();

 

            tablica();

        }

 

        private void button5_Click(object sender, EventArgs e)

        {

            string k = "";

            string val;

            string sAppProgID = "Excel.Application";

            // Получаем ссылку на интерфейс IDispatch

            Type tExcelObj = Type.GetTypeFromProgID(sAppProgID);

            // Запускаем Excel

            object oExcel = Activator.CreateInstance(tExcelObj);

            object oWorkbooks = oExcel.GetType().InvokeMember("Workbooks", BindingFlags.GetProperty, null, oExcel, null);

            //Создаем новую книгу

            object[] args = new object[2];

            args[0] = "d:\\1\\1.xls";

            args[1] = true;

            object oWorkbook = oWorkbooks.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, oWorkbooks, args);

            object oWorksheets = oWorkbook.GetType().InvokeMember("Worksheets", BindingFlags.GetProperty, null, oWorkbook, null);

 

            //Задаем порядковый номер страницы - 1

            object[] args1 = new object[1];

            args1[0] = 1;

            // Получаем ссылку на эту страницу

            object oWorksheet = oWorksheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, oWorksheets, args1);

            object oRange = oWorksheet.GetType().InvokeMember("Range", BindingFlags.GetProperty, null, oWorksheet, new object[] { "A1" });

 

            int i = 0;

            for (i = 0; i < dataGridView1.RowCount - 1; i++)

Информация о работе Оружейный магазин