Автор: Пользователь скрыл имя, 14 Января 2013 в 12:36, курсовая работа
В любой спроектированной системе есть свои цели и задачи. В данной работе целью является автоматизация учёта продаж боевых единиц, на основе объектно-ориентированного подхода к разработке информационных систем. Основной целью курсового проекта является написание программы на языке программирования – C# -, освоение принципов объектно-ориентированного программирования, получение навыков работы с базой данных.
Введение…………………………………………………………………………...
4
Подготовительная работа……………..………………………………………….
5
Разработка требований пользователя к системе и ПО ………………………....
6
Сценарий работы системы………….……………………………………………
7
Проектирование архитектуры системы и анализ требований к ПО…………...
8
Детальное проектирование ПО. Характеристика компонентов системы……..
9
Тестирование……………………………………………………………………...
14
Модель базы данных……………………………..……………………….………
16
Описание выходных форм………………………..………………………………
18
Себестоимость…………………………………………………………………….
19
Код программы……………………………………………………………………
20
Заключение …………………………………………………………………........
35
Литература………………………………………………………………………..
Следовательно, стоимость данного программного продукта составила 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(o
{
Close();
}
private void видыОружияToolStripMenuItem_
{
Form2 f2 = new Form2();
f2.Show();
}
private void видыЛицензийToolStripMenuItem_
{
Form3 f3 = new Form3();
f3.Show();
}
private void необходимыеДокументыToolStripM
{
Form4 f4 = new Form4();
f4.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void характеристикаToolStripMenuIte
{
}
private void печатьToolStripMenuItem_Click(
{
}
private void прайслистToolStripMenuItem_
{
Form5 f5 = new Form5();
f5.Show();
}
private void соглашениеToolStripMenuItem_
{
Form6 f6 = new Form6();
f6.Show();
}
private void оПрограммеToolStripMenuItem_
{
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].
dataGridView1.Columns[1].
dataGridView1.Columns[2].
}
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].
dataGridView1.Columns[1].
dataGridView1.Columns[2].
dataGridView1.Columns[3].
}
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].
dataGridView1.Columns[1].
dataGridView1.Columns[2].
dataGridView1.Columns[3].
}
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).
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].
dataGridView1.Columns[1].
dataGridView1.Columns[2].
}
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(
// Запускаем Excel
object oExcel = Activator.CreateInstance(
object oWorkbooks = oExcel.GetType().InvokeMember(
//Создаем новую книгу
object[] args = new object[2];
args[0] = "d:\\1\\1.xls";
args[1] = true;
object oWorkbook = oWorkbooks.GetType().
object oWorksheets = oWorkbook.GetType().
//Задаем порядковый номер страницы - 1
object[] args1 = new object[1];
args1[0] = 1;
// Получаем ссылку на эту страницу
object oWorksheet = oWorksheets.GetType().
object oRange = oWorksheet.GetType().
int i = 0;
for (i = 0; i < dataGridView1.RowCount - 1; i++)