Описание для программиста
Листинг программы:
Управляющий.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Reflection;
namespace курсовая
{
public class Управляющий
{
public курсовая_ддл.Zakazi Z = new курсовая_ддл.Zakazi();
public курсовая_ддл.SpisokZakazov SZ = new курсовая_ддл.SpisokZakazov();
public курсовая_ддл.Agents AG = new курсовая_ддл.Agents();
public курсовая_ддл.SpisokAgents SAG = new курсовая_ддл.SpisokAgents();
public XmlSerializer AgentX = new XmlSerializer(typeof(курсовая_ддл.SpisokAgents));
public XmlSerializer ZakazX = new XmlSerializer(typeof(курсовая_ддл.SpisokZakazov));
public decimal SumZakCur = 0;
public void save(string path)
{
FileStream f = new FileStream(path, FileMode.Create, FileAccess.Write);
StreamWriter kk = new StreamWriter(f);
kk.Flush();
f.Close();
kk.Close();
}
public void LoadUser(string s)
{
FileStream f = new FileStream(s, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(f);
SAG = (курсовая_ддл.SpisokAgents)AgentX.Deserialize(sr); // приведение типа
sr.Close();
f.Close();
}
public void SaveAgents(string s)
{
if (File.Exists(s)) File.Delete(s);
FileStream f = new FileStream(s, FileMode.CreateNew, FileAccess.Write);
StreamWriter sw = new StreamWriter(f);
AgentX.Serialize(sw, SAG);
sw.Close();
f.Close();
}
public void LoadAgents(string st)
{
FileStream ff = new FileStream(st, FileMode.Open, FileAccess.Read);
StreamReader sr1 = new StreamReader(ff);
SAG = (курсовая_ддл.SpisokAgents)AgentX.Deserialize(sr1); // приведение типа
sr1.Close();
ff.Close();
}
public void SaveZakazi(string st)
{
if (File.Exists(st)) File.Delete(st);
FileStream ff1 = new FileStream(st, FileMode.CreateNew, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(ff1);
ZakazX.Serialize(sw1, SZ);
sw1.Close();
ff1.Close();
}
public void LoadZakazi(string st)
{
FileStream ff2 = new FileStream(st, FileMode.Open, FileAccess.Read);
StreamReader sr2 = new StreamReader(ff2);
SZ = (курсовая_ддл.SpisokZakazov)ZakazX.Deserialize(sr2); // приведение типа
sr2.Close();
ff2.Close();
}
private static string PathConverter(string file)
{
try
{
file = file.Replace(@"\", "/");
return "file:///" + file;
}
catch (System.Exception ex)
{
throw ex;
}
}
}
}
log.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using курсовая_ддл;
using System.IO;
namespace курсовая
{
public partial class log : Form
{
public Управляющий Upr = new Управляющий();
string ag = "Агент";
string par_ag = "123";
string byh = "Бухгалтер";
string par_byh = "456";
string str1, str2;
public int nomer_agenta;
public log()
{
InitializeComponent();
}
private void log_Load(object sender, EventArgs e)
{
if (File.Exists("Agents.xml"))
Upr.LoadAgents("Agents.xml");
if (File.Exists("Zakazi.xml"))
Upr.LoadZakazi("Zakazi.xml");
this.Activate();
}
private void button1_Click(object sender, EventArgs e)
{
str1 = Convert.ToString(textBox1.Text);
str2 = Convert.ToString(textBox2.Text);
for (int i = 0; i < Upr.SAG.List.Count; i++)
{
if ((str1 == ag + i.ToString()) && (str2 == par_ag + i.ToString()))
{
nomer_agenta = i;
Program.Agentam.Show();
}
}
if ((str1 == byh) && (str2 == par_byh))
{
Program.f1.Show();
this.Hide();
}
if (((str1 != (ag+this.nomer_agenta.ToString())) || (str2 != par_ag+this.nomer_agenta.ToString())) && ((str1 != byh) || (str2 != par_byh)))
{ MessageBox.Show("НЕ правильно ввели логин/пароль!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void log_Closing(object sender, FormClosingEventArgs e)
{
Upr.SaveAgents("Agents.xml");
Upr.SaveZakazi("Zakazi.xml");
}
private void log_Closing(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Агентам.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using курсовая_ддл;
using System.IO;
namespace курсовая
{
public partial class Агентам : Form
{
public Агентам()
{
InitializeComponent();
}
public int[] m;
int nom,x,double_ukaz,sum_old,kolvo,index;
int ukaz = -1;
private void button2_Click(object sender, EventArgs e)
{
Program.DZakaz.ShowDialog();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
}
private void Агентам_Load(object sender, EventArgs e)
{
if (File.Exists("Zakazi.xml"))
Program.Activ.Upr.LoadZakazi("Zakazi.xml");
this.Activate();
listBox1.Items.Clear();
m = new int[Program.Activ.Upr.SZ.List.Count];
kolvo = 0;
foreach (курсовая_ддл.Zakazi Z in Program.Activ.Upr.SZ.List)
{
if ( Z.ID_agenta == Program.Activ.nomer_agenta)
{
listBox1.Items.Add(Z.naimenovanie);
m[kolvo] = Z.nomer;
kolvo++;
}
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
index = listBox1.SelectedIndex;
textBox1.Text = null;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox7.Text = null;
textBox8.Text = null;
textBox10.Text = null;
int y=0;
for (int i = 0; i <= m.Length; i++)
{
if (i == index)
{
y = m[i];
}
}
foreach(курсовая_ддл.Zakazi Z in Program.Activ.Upr.SZ.List)
{
if (y ==Z.nomer)
{
nom = Z.nomer;
}
}
foreach (курсовая_ддл.Zakazi Z2 in Program.Activ.Upr.SZ.List)
{
if (nom == Z2.nomer)
{
textBox1.SelectedText = Convert.ToString(Z2.nomer);
textBox2.SelectedText = Convert.ToString(Z2.naimenovanie);
textBox3.SelectedText = Convert.ToString(Z2.FIO_zakazchika);
textBox4.SelectedText = Convert.ToString(Z2.FIO_agenta);
textBox5.SelectedText = Convert.ToString(Z2.ID_agenta);
textBox6.SelectedText = Convert.ToString(Z2.oplata);
textBox7.SelectedText = Convert.ToString(Z2.kol_vo);
textBox8.SelectedText = Convert.ToString(Z2.summa_zakaza);
textBox10.SelectedText = Convert.ToString(Z2.month);
}
}
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox7.ReadOnly = true;
textBox8.ReadOnly = true;
}
private void Агентам_FormClosing(object sender, FormClosingEventArgs e)
{
Program.Activ.Upr.SaveZakazi("Zakazi.xml");
}
private void выходToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox6.Text == "не оплачено")
{
textBox2.ReadOnly = false;
textBox3.ReadOnly = false;
textBox7.ReadOnly = false;
textBox8.ReadOnly = false;
sum_old = Convert.ToInt32(textBox8.Text);
}
else
{
MessageBox.Show("Редактировать можно только не оплаченные заказы.", "Запрет редактирования", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button4_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
try
{
string poisk, lstr;
bool not_find = true;
poisk = Convert.ToString(textBox9.Text);
for (int i = 0; i < listBox1.Items.Count; i++)
{
lstr = listBox1.Items[i].ToString();
if ((lstr == poisk) & (not_find))
{
if (i > ukaz)
{
ukaz = i;
listBox1.SelectedIndex = i;
not_find = false;
}
}
if (lstr != poisk)
{
x++;
if (x == listBox1.Items.Count)
{
MessageBox.Show("Заказ не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
x = 0;
double_ukaz = ukaz;
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if (radioButton2.Checked)
{
try
{
int poisk_nom;
poisk_nom = Convert.ToInt32(textBox9.Text);
for (int i = 0; i < m.Length; i++)
{
if (m[i] == poisk_nom)
{
listBox1.SelectedIndex = i;
}
if (m[i] != poisk_nom)
{
x++;
if (x == m.Length)
{
MessageBox.Show("Заказ по данному номеру не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
x = 0;
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if ((!radioButton1.Checked) && (!radioButton2.Checked))
{
MessageBox.Show("Необходимо указать по какому критерию Вы осуществляет поиск: по наименованию заказа или по номеру заказа.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button5_Click(object sender, EventArgs e)
{
курсовая_ддл.Zakazi Z = new курсовая_ддл.Zakazi();
string naimenovanie, FIO_zakazchika;
int kol_vo, summa_zakaza;
naimenovanie = textBox2.Text;
FIO_zakazchika = textBox3.Text;
kol_vo = Convert.ToInt32(textBox7.Text);
summa_zakaza = Convert.ToInt32(textBox8.Text);
for (int i = 0; i <= m.Length; i++)
{
if (index == i)
{
Program.Activ.Upr.SZ.List[m[i]].naimenovanie = naimenovanie;
Program.Activ.Upr.SZ.List[m[i]].FIO_zakazchika = FIO_zakazchika;
Program.Activ.Upr.SZ.List[m[i]].kol_vo = kol_vo;
Program.Activ.Upr.SZ.List[m[i]].summa_zakaza = summa_zakaza;
}
}
Program.Activ.Upr.SaveZakazi("Zakazi.xml");
foreach (курсовая_ддл.Zakazi Z2 in Program.Activ.Upr.SZ.List)
{
if (Z2.summa_zakaza != sum_old)
{
foreach (курсовая_ддл.Agents AG2 in Program.Activ.Upr.SAG.List)
{
if (Z2.ID_agenta == AG2.id)
{
AG2.summa_ot_zakazov -= sum_old;
AG2.summa_ot_zakazov += Z2.summa_zakaza;
Program.Activ.Upr.SaveAgents("Agents.xml");
}
}
}
}
if (File.Exists("Zakazi.xml"))
Program.Activ.Upr.LoadZakazi("Zakazi.xml");
this.Activate();
listBox1.Items.Clear();
m = new int[Program.Activ.Upr.SZ.List.Count];
kolvo = 0;
foreach (курсовая_ддл.Zakazi Z4 in Program.Activ.Upr.SZ.List)
{
if (Z4.ID_agenta == Program.Activ.nomer_agenta)
{
listBox1.Items.Add(Z4.naimenovanie);
m[kolvo] = Z4.nomer;
kolvo++;
}
}
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox7.ReadOnly = true;
textBox8.ReadOnly = true;
}
}
}
Добавление заказа.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace курсовая
{
public partial class Добавление_заказа : Form
{
public Добавление_заказа()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
}
private void Добавление_заказа_Load(object sender, EventArgs e)
{
textBox1.Text = null;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox7.Text = null;
textBox8.Text = null;
textBox9.Text = null;
курсовая_ддл.Zakazi Z = new курсовая_ддл.Zakazi();
textBox1.SelectedText = Convert.ToString(Z.nomer);
textBox2.SelectedText = Convert.ToString(Z.naimenovanie);
foreach (курсовая_ддл.Agents Ag in Program.Activ.Upr.SAG.List)
{
if (Ag.id == Program.Activ.nomer_agenta)
{
textBox4.SelectedText = Ag.fio;
}
}
textBox3.SelectedText = Convert.ToString(Z.FIO_zakazchika);
textBox5.SelectedText = Convert.ToString(Program.Activ.nomer_agenta);
textBox4.SelectedText = Convert.ToString(Z.FIO_agenta);
textBox6.SelectedText = "не оплачено";
textBox7.SelectedText = Convert.ToString(Z.kol_vo);
textBox8.SelectedText = Convert.ToString(Z.summa_zakaza);
textBox9.SelectedText = Convert.ToString(Z.month);
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if ((textBox2.Text == "") || (textBox3.Text == "") || (textBox4.Text == "") || (textBox7.Text == "") || (textBox8.Text == "") || (textBox9.Text == "") || (Convert.ToInt32(textBox7.Text) <= 0) || (Convert.ToInt32(textBox8.Text) <= 0) || (Convert.ToInt32(textBox9.Text) <= 0))
{
MessageBox.Show("Поле осталось пустым!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
курсовая_ддл.Zakazi Z = new курсовая_ддл.Zakazi();
string naimenovanie, FIO_zakazchika, FIO_agenta, oplata;
int ID_agenta, kol_vo, summa_zakaza,month;
naimenovanie = textBox2.Text;
FIO_zakazchika = textBox3.Text;
FIO_agenta = textBox4.Text;
month = Convert.ToInt32(textBox9.Text);
ID_agenta = Program.Activ.nomer_agenta;
oplata = "не оплачено";
kol_vo = Convert.ToInt32(textBox7.Text);
summa_zakaza = Convert.ToInt32(textBox8.Text);
foreach (курсовая_ддл.Agents Ag in Program.Activ.Upr.SAG.List)
{
if (Program.Activ.nomer_agenta == Ag.id)
{
Ag.summa_ot_zakazov += summa_zakaza;
}
}
Program.Activ.Upr.SZ.Add(Z.naimenovanie = naimenovanie, Z.FIO_zakazchika = FIO_zakazchika, Z.FIO_agenta=FIO_agenta, Z.ID_agenta = ID_agenta, Z.oplata = oplata, Z.nomer, Z.kol_vo = kol_vo, Z.summa_zakaza = summa_zakaza,Z.month=month);
Program.Activ.Upr.SaveZakazi("Zakazi.xml");
Program.Agentam.listBox1.Items.Clear();
foreach (курсовая_ддл.Zakazi ZZ in Program.Activ.Upr.SZ.List)
{
Program.Agentam.listBox1.Items.Add(ZZ.naimenovanie);
}
Program.Activ.Upr.SaveAgents("Agents.xml");
Program.SpisAgent.listBox1.Items.Clear();
foreach (курсовая_ддл.Agents AGT in Program.Activ.Upr.SAG.List)
{
Program.SpisAgent.listBox1.Items.Add(AGT.fio);
}
Program.Agentam.listBox1.Items.Clear();
Program.Agentam.m = new int[Program.Activ.Upr.SZ.List.Count];
int kolvo = 0;
foreach (курсовая_ддл.Zakazi Z2 in Program.Activ.Upr.SZ.List)
{
if (Z2.ID_agenta == Program.Activ.nomer_agenta)
{
Program.Agentam.listBox1.Items.Add(Z2.naimenovanie);
Program.Agentam.m[kolvo] = Z2.nomer;
kolvo++;
}
}
this.Hide();
}
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void Добавление_заказа_FormClosing(object sender, EventArgs e)
{
}
}
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using курсовая_ддл;
using System.IO;
namespace курсовая
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
Program.Info.ShowDialog();
}
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists("Agents.xml"))
Program.Activ.Upr.LoadAgents("Agents.xml");
if (File.Exists("Zakazi.xml"))
Program.Activ.Upr.LoadZakazi("Zakazi.xml");
this.Activate();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
Program.SpisAgent.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
Program.SpisZakaz.ShowDialog();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Program.Activ.Upr.SaveAgents("Agents.xml");
Program.Activ.Upr.SaveZakazi("Zakazi.xml");
}
private void списокАгентовToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void просмотретьСписокToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.SpisAgent.ShowDialog();
}
private void просмотрСпискаToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.SpisZakaz.ShowDialog();
}
private void информацияToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.Information.ShowDialog();
}
private void авторыToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.Info.ShowDialog();
}
private void выходToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void button1_Click_1(object sender, EventArgs e)
{
//Program.Mail.ShowDialog();
}
private void добавитьАгентаToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.DAgent.ShowDialog();
}
private void заМесяцToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.Z_m.ShowDialog();
}
private void заКварталToolStripMenuItem_Click(object sender, EventArgs e)
{
Program.Z_k.ShowDialog();
}
}
}
Список агентов.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace курсовая
{
public partial class Список_агентов : Form
{
public int CurIndAG;
int x;
public Список_агентов()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = listBox1.SelectedIndex;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox12.Text = null;
textBox7.Text = null;
textBox9.Text = null;
textBox10.Text = null;
textBox11.Text = null;
foreach (курсовая_ддл.Agents AG in Program.Activ.Upr.SAG.List)
{
if (index == AG.id)
{
textBox2.SelectedText = Convert.ToString(AG.id);
textBox3.SelectedText = Convert.ToString(AG.fio);
textBox4.SelectedText = Convert.ToString(AG.statys);
textBox5.SelectedText = Convert.ToString(AG.age);
textBox6.SelectedText = Convert.ToString(AG.adress);
textBox12.SelectedText = Convert.ToString(AG.tel);
textBox7.SelectedText = Convert.ToString(AG.e_mail);
textBox9.SelectedText = Convert.ToString(AG.kolvo_zakazov_k);
textBox10.SelectedText = Convert.ToString(AG.kolvo_otrab_dnei_m);
textBox11.SelectedText = Convert.ToString(AG.summa_ot_zakazov);
}
}
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
textBox12.ReadOnly = true;
textBox7.ReadOnly = true;
textBox9.ReadOnly = true;
textBox10.ReadOnly = true;
}
private void Список_агентов_FormClosing(object sender, FormClosingEventArgs e)
{
Program.Activ.Upr.SaveAgents("Agents.xml");
}
private void Список_агентов_Load_1(object sender, EventArgs e)
{
listBox1.Items.Clear();
foreach (курсовая_ддл.Agents AG in Program.Activ.Upr.SAG.List)
{
listBox1.Items.Add(AG.fio);
AG.kolvo_zakazov_k = 0;
AG.summa_ot_zakazov = 0;
foreach (курсовая_ддл.Zakazi Z in Program.Activ.Upr.SZ.List)
{
if (Z.ID_agenta == AG.id)
{
AG.kolvo_zakazov_k++;
AG.summa_ot_zakazov += Z.summa_zakaza;
}
}
}
}
private void button5_Click(object sender, EventArgs e)
{
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox12.Text = null;
textBox7.Text = null;
textBox9.Text = null;
textBox10.Text = null;
textBox11.Text = null;
this.Hide();
}
private void button4_Click_1(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
try
{
string poisk, lstr;
poisk = Convert.ToString(textBox1.Text);
for (int i = 0; i < listBox1.Items.Count; i++)
{
lstr = listBox1.Items[i].ToString();
if (lstr == poisk)
{
listBox1.SelectedIndex = i;
}
if (lstr != poisk)
{
x++;
if (x == listBox1.Items.Count)
{
MessageBox.Show("Агент не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
} x = 0;
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if (radioButton2.Checked)
{
try
{
int p;
p = Convert.ToInt32(textBox1.Text);
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (i == p)
{
listBox1.SelectedIndex = i;
}
if (i != p)
{
x++;
if (x == listBox1.Items.Count)
{
MessageBox.Show("Агент по данному ID не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
x = 0;
}
catch { MessageBox.Show("Ошибка ввода! Для поиска введите ID агента.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if((!radioButton1.Checked)&&(!radioButton2.Checked))
{
MessageBox.Show("Необходимо указать по какому критерию Вы осуществляет поиск: по ФИО агента или по ID агента.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click_1(object sender, EventArgs e)
{
Program.DAgent.ShowDialog();
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.ReadOnly = false;
textBox4.ReadOnly = false;
textBox5.ReadOnly = false;
textBox6.ReadOnly = false;
textBox12.ReadOnly = false;
textBox7.ReadOnly = false;
textBox10.ReadOnly = false;
}
private void button6_Click(object sender, EventArgs e)
{
курсовая_ддл.Agents AG = new курсовая_ддл.Agents();
string FIO_agenta, statys, adres, e_mail;
int age, tel, kolvo_dnei;
FIO_agenta=textBox3.Text;
statys=textBox4.Text;
age=Convert.ToInt32(textBox5.Text);
adres=textBox6.Text;
tel=Convert.ToInt32(textBox12.Text);
e_mail=textBox7.Text;
kolvo_dnei=Convert.ToInt32(textBox10.Text);
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].fio =FIO_agenta ;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].statys = statys;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].age = age;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].adress = adres;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].tel = tel;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].e_mail = e_mail;
Program.Activ.Upr.SAG.List[listBox1.SelectedIndex].kolvo_otrab_dnei_m = kolvo_dnei;
Program.Activ.Upr.SaveAgents("Agents.xml");
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
textBox12.ReadOnly = true;
textBox7.ReadOnly = true;
textBox10.ReadOnly = true;
}
}
}
Добавление агента.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace курсовая
{
public partial class Добавление_агента : Form
{
public Добавление_агента()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
}
private void Добавление_агента_Load(object sender, EventArgs e)
{
textBox1.Text = null;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox7.Text = null;
textBox9.Text = null;
textBox10.Text = null;
textBox11.Text = null;
курсовая_ддл.Agents AG = new курсовая_ддл.Agents();
textBox1.SelectedText = Convert.ToString(AG.id);
textBox2.SelectedText = Convert.ToString(AG.fio);
textBox3.SelectedText = "агент";
textBox4.SelectedText = Convert.ToString(AG.age);
textBox5.SelectedText = Convert.ToString(AG.adress);
textBox6.SelectedText = Convert.ToString(AG.tel);
textBox7.SelectedText = Convert.ToString(AG.e_mail);
textBox9.SelectedText = Convert.ToString(AG.kolvo_zakazov_k);
textBox10.SelectedText = Convert.ToString(AG.kolvo_otrab_dnei_m);
textBox11.SelectedText = Convert.ToString(AG.summa_ot_zakazov);
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if ((textBox2.Text == "") || (textBox4.Text == "") || (textBox5.Text == "") || (textBox6.Text == "") || (textBox7.Text == "") || (textBox9.Text == "") || (textBox10.Text == "")||(Convert.ToInt32(textBox4.Text)<=0)||(Convert.ToInt32(textBox6.Text)<=0))
{
MessageBox.Show("Поле осталось пустым!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string fio, statys, adress, e_mail;
int age, tel, kolvo_zakazov_k, kolvo_otrab_dnei_m, summa_ot_zakazov;
fio = textBox2.Text;
statys = textBox3.Text;
age = Convert.ToInt32(textBox4.Text);
adress = textBox5.Text;
tel = Convert.ToInt32(textBox6.Text);
e_mail = textBox7.Text;
kolvo_zakazov_k = Convert.ToInt32(textBox9.Text);
kolvo_otrab_dnei_m = Convert.ToInt32(textBox10.Text);
summa_ot_zakazov = Convert.ToInt32(textBox11.Text);
курсовая_ддл.Agents AG = new курсовая_ддл.Agents();
Program.Activ.Upr.SAG.Add(AG.fio = fio, AG.statys = statys, AG.age = age, AG.adress = adress, AG.tel = tel, AG.e_mail = e_mail, AG.kolvo_zakazov_k = kolvo_zakazov_k, AG.kolvo_otrab_dnei_m = kolvo_otrab_dnei_m, AG.summa_ot_zakazov = summa_ot_zakazov, AG.id);
Program.Activ.Upr.SaveAgents("Agents.xml");
Program.SpisAgent.listBox1.Items.Clear();
foreach (курсовая_ддл.Agents AGT in Program.Activ.Upr.SAG.List)
{
Program.SpisAgent.listBox1.Items.Add(AGT.fio);
}
this.Hide();
}
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void Добавление_агента_FormClosing(object sender, EventArgs e)
{
}
}
}
Список заказов.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using курсовая_ддл;
using System.IO;
namespace курсовая
{
public partial class Список_заказов : Form
{
int x;
int ukaz = -1;
public Список_заказов()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox9.Text = null;
textBox7.Text = null;
textBox8.Text = null;
textBox10.Text = null;
this.Hide();
}
private void Список_заказов_Load(object sender, EventArgs e)
{
if (File.Exists("Zakazi.xml"))
Program.Activ.Upr.LoadZakazi("Zakazi.xml");
this.Activate();
listBox1.Items.Clear();
foreach (курсовая_ддл.Zakazi Z in Program.Activ.Upr.SZ.List)
{
listBox1.Items.Add(Z.naimenovanie);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = listBox1.SelectedIndex;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox9.Text = null;
textBox7.Text = null;
textBox8.Text = null;
textBox10.Text = null;
foreach (курсовая_ддл.Zakazi Z2 in Program.Activ.Upr.SZ.List)
{
if (index==Z2.nomer)
{
textBox2.SelectedText = Convert.ToString(Z2.nomer);
textBox3.SelectedText = Convert.ToString(Z2.naimenovanie);
textBox4.SelectedText = Convert.ToString(Z2.FIO_zakazchika);
textBox5.SelectedText = Convert.ToString(Z2.FIO_agenta);
textBox6.SelectedText = Convert.ToString(Z2.ID_agenta);
textBox9.SelectedText = Convert.ToString(Z2.oplata);
textBox7.SelectedText = Convert.ToString(Z2.kol_vo);
textBox8.SelectedText = Convert.ToString(Z2.summa_zakaza);
textBox10.SelectedText = Convert.ToString(Z2.month);
}
}
}
private void Список_заказов_FormClosing(object sender, FormClosingEventArgs e)
{
//Program.Activ.Upr.SaveZakazi("Zakazi.xml");
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox9.Text == "не оплачено")
{
DialogResult dr = MessageBox.Show("Заказ оплачен?", "Фиксирование оплаты", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch (dr)
{
case DialogResult.Yes: textBox9.Text = null; textBox9.Text = "оплачено";
курсовая_ддл.Zakazi Z = new курсовая_ддл.Zakazi();
string oplata;
oplata = Convert.ToString(textBox9.Text);
Program.Activ.Upr.SZ.List[listBox1.SelectedIndex].oplata = oplata;
Program.Activ.Upr.SaveZakazi("Zakazi.xml");
break;
case DialogResult.No: break;
}
}
else //(textBox9.Text == "оплачено")
{
MessageBox.Show("Фиксировать оплату можно только у не оплаченных заказов.", "Не соответствие", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button4_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
try
{
string poisk, lstr;
bool not_find = true;
poisk = Convert.ToString(textBox1.Text);
for (int i = 0; i < listBox1.Items.Count; i++)
{
lstr = listBox1.Items[i].ToString();
if ((lstr == poisk) & (not_find))
{
if (i > ukaz)
{
ukaz = i;
listBox1.SelectedIndex = i;
not_find = false;
}
}
if (lstr != poisk)
{
x++;
if (x == listBox1.Items.Count)
{
MessageBox.Show("Заказ не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
x = 0;
}
catch { MessageBox.Show("Ошибка ввода!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if (radioButton2.Checked)
{
try
{
int p;
p = Convert.ToInt32(textBox1.Text);
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (i == p)
{
listBox1.SelectedIndex = i;
}
if (i != p)
{
x++;
if (x == listBox1.Items.Count)
{
MessageBox.Show("Заказ по данному номеру не найден.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
x = 0;
}
catch { MessageBox.Show("Ошибка ввода! Для поиска введите номер заказа.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
if ((!radioButton1.Checked) && (!radioButton2.Checked))
{
MessageBox.Show("Необходимо указать по какому критерию Вы осуществляет поиск: по наименованию заказа или по номеру заказа.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Почта.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net;
using System.Net.Mime;
namespace курсовая
{
public partial class Почта : Form
{
public Почта()
{
InitializeComponent();
}
public string file;
private void button1_Click(object sender, EventArgs e)
{
//Авторизация на SMTP сервере
SmtpClient Smtp = new SmtpClient("smtp.mail.ru", 25);
//Smtp.Credentials = new NetworkCredential("elena94024", textBox3.Text.Trim());
Smtp.Credentials = new NetworkCredential("didi17@bk.ru", textBox3.Text.Trim());
Smtp.EnableSsl = false;
bool checkaddr = false;
bool checksubj = false;
bool checksubp = false;
if (textBox1.TextLength > 0) checkaddr = true;
if (checkaddr == false) MessageBox.Show("Введите адрес получателя!");
if (textBox2.TextLength > 0) checksubj = true;
if (checksubj == false) MessageBox.Show("Введите тему сообщения!");
if (textBox3.TextLength > 0) checksubp = true;
if (checksubp == false) MessageBox.Show("Введите пароль!");
if (checkaddr == true & checksubj == true & checksubp == true)
{
MailMessage Msg = new MailMessage();
//Msg.From = new MailAddress("elena94024@mail.ru");
Msg.From = new MailAddress("didi17@bk.ru");
Msg.To.Add(new MailAddress(textBox1.Text.ToString()));
Msg.Subject = textBox2.Text.ToString();
Msg.Body = richTextBox1.Text;
string file = openFileDialog1.FileName.ToString(); ;
Attachment attach = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition disposition = attach.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
Msg.Attachments.Add(attach);
try
{
Smtp.Send(Msg);//!!!отправка
MessageBox.Show("Сообщение отправлено!");
}
catch
{ MessageBox.Show("Неправильный ввод!"); }
}
else
{ MessageBox.Show("Некоторые поля остались незаполнеными!"); }
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Почта_Load(object sender, EventArgs e)
{
}
}
}
Информация.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace курсовая
{
public partial class Информация : Form
{
public Информация()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void Информация_Load(object sender, EventArgs e)
{
}
}
}
Информация о проекте.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace курсовая
{
public partial class Авторы : Form
{
public Авторы()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
}
private void Авторы_Load(object sender, EventArgs e)
{
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace курсовая
{
static class Program
{
public static Form1 f1;
public static Добавление_агента DAgent;
public static Добавление_заказа DZakaz;
public static Авторы Info;
public static Почта Mail;
public static Управляющий_2 Upr2;
public static Список_агентов SpisAgent;
public static Список_заказов SpisZakaz;
public static Информация Information;
public static Зарплата_за_месяц Z_m;
public static Параметры_зарплаты Zarp_Param;
public static Зарплата_за_квартал Z_k;
public static Параметры_премии Premia_Param;
public static log Activ;
public static Агентам Agentam;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
f1 = new Form1();
DAgent = new Добавление_агента();
DZakaz = new Добавление_заказа();
Info = new Авторы();
Mail = new Почта();
Upr2 = new Управляющий_2();
SpisAgent = new Список_агентов();
SpisZakaz = new Список_заказов();
Information = new Информация();
Z_m = new Зарплата_за_месяц();
Zarp_Param = new Параметры_зарплаты();
Z_k = new Зарплата_за_квартал();
Premia_Param = new Параметры_премии();
Activ = new log();
Agentam = new Агентам();
Application.Run(Activ);
}
}
}
курсовая DLL
Agents.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace курсовая_ддл
{
public class Agents
{
public int id;
public int ID
{
get
{ return id; }
//set
//{ number = value; }
}
public string fio;
public string Fio
{
get
{ return fio; }
set
{ fio = value; }
}
public string statys;
public string Statys
{
get
{ return statys; }
set
{ statys = value; }
}
public int age;
public int Age
{
get
{ return age; }
set
{ age = value; }
}
public string adress;
public string Adress
{
get
{ return adress; }
set
{ adress = value; }
}
public int tel;
public int Tel
{
get
{ return tel; }
set
{ tel = value; }
}
public string e_mail;
public string E_mail
{
get
{ return e_mail; }
set
{ e_mail = value; }
}
public int kolvo_zakazov_k;
public int Kolvo_zakazov_k
{
get
{ return kolvo_zakazov_k; }
set
{ kolvo_zakazov_k = value; }
}
public int kolvo_otrab_dnei_m;
public int Kolvo_otrab_dnei_m
{
get
{ return kolvo_otrab_dnei_m; }
set
{ kolvo_otrab_dnei_m = value; }
}
public decimal summa_ot_zakazov;
public decimal Summa_ot_zakazov
{
get
{ return summa_ot_zakazov; }
set
{ summa_ot_zakazov = value; }
}
public Agents()
{ }
public Agents(string f,string s,int a,string ads,int t,string e_m,int k_z_k,int k_d_m,decimal sum,int id)
{
this.fio = f;
this.statys = s;
this.age = a;
this.adress = ads;
this.tel = t;
this.e_mail = e_m;
this.kolvo_zakazov_k = k_z_k;
this.kolvo_otrab_dnei_m = k_d_m;
this.summa_ot_zakazov = sum;
this.id = id;
}
}
public class SpisokAgents
{
public SpisokAgents()
{ }
public List<Agents> List = new List<Agents>();
public void Add( string f, string s, int a, string ads, int t, string e_m, int k_z_k, int k_d_m, decimal sum,int id)
{
Agents obj = new Agents(f, s, a, ads, t, e_m, k_z_k, k_d_m, sum,List.Count);
List.Add(obj);
}
}
}
Zakazi.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace курсовая_ддл
{
public class Zakazi
{
public int nomer;
public int Nomer
{
get
{ return nomer; }
//set
//{ index = value; }
}
public string naimenovanie;
public string Naimenovanie
{
get
{ return naimenovanie; }
set
{ naimenovanie = value; }
}
public int kol_vo;
public int Kol_vo
{
get
{ return kol_vo; }
set
{ kol_vo = value; }
}
public decimal summa_zakaza;
public decimal Summa_zakaza
{
get
{ return summa_zakaza; }
set
{ summa_zakaza = value; }
}
public string FIO_zakazchika;
public string Fio_zakazchika
{
get
{ return FIO_zakazchika; }
set
{ FIO_zakazchika = value; }
}
public string FIO_agenta;
public string Fio_agenta
{
get
{ return FIO_agenta; }
set
{ FIO_agenta = value; }
}
public int ID_agenta;
public int id_agenta
{
get
{ return ID_agenta; }
set
{ ID_agenta = value; }
}
public string oplata;
public string Oplata
{
get
{ return oplata; }
set
{ oplata = value; }
}
public int month;
public int Month
{
get { return month; }
set { month = value; }
}
public Zakazi()
{ }
public Zakazi( string naim, int kol, decimal sum, string fio_z, string fio_ag, int id_agenta, string opl,int n,int month)
{
this.naimenovanie = naim;
this.kol_vo = kol;
this.summa_zakaza = sum;
this.FIO_zakazchika = fio_z;
this.FIO_agenta = fio_ag;
this.ID_agenta = id_agenta;
this.oplata = opl;
this.nomer = n;
this.month = month;
}
}
public class SpisokZakazov
{
public SpisokZakazov()
{ }
public List<Zakazi> List = new List<Zakazi>();
public void Add(string naim, string fio_z, string fio_ag, int id_agenta, string opl, int n, int kol, decimal sum,int month)
{
Zakazi obj = new Zakazi(naim, kol, sum, fio_z, fio_ag, id_agenta, opl, List.Count, month);
List.Add(obj);
}
}
}
Вывод
Данная программа может быть использована на предприятие для учёта заработной платы агентов по продажам. Это может быть продажа интернета, кабельного TV, недвижимости, косметики, или оформления заказов на услуги. В данной программе я брала за пример работу агентов по продажам компьютерной техники.
Особенностью программы, является то, что она не только ведёт учёт заработной платы агентов, но и даёт возможность посмотреть наименее и наиболее результативных, и по результатам их работы назначить повышение.
В программе предусмотрены основные функции агентов по продажам, и обязанности бухгалтера.