Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
Приложение ⇐ ПредыдущаяСтр 7 из 7
BussinesProcess.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing.Drawing2D; using System.Drawing;
namespace Диплом { public struct Job { public String namePeople; public String nameOffice; public IList< String> funktion;
} public class BussinesProcess { public String nameProcess; public bool PrOrJob; public Job funk; public IList< BussinesProcess> neiboor; public bool fun; public BussinesProcess funktion; public Point m; } } 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 System.Drawing.Drawing2D;
namespace Диплом { public partial class Form1: Form { bool fl; /////////////////выбор диаграмм Graphics graphics; Bitmap B_map; IList< String> именаБлоковБизнесФункций = new List< String> (); IList< String> именаОтделов = new List< String> (); Rectangle[] Отделы = new Rectangle[4]; public int kef = 10; Rectangle[] бизнесФункции = new Rectangle[7]; Rectangle[] началоКонец = new Rectangle[2]; Rectangle[] бизнесФункции1 = new Rectangle[7]; public Form1() {
InitializeComponent(); B_map = new Bitmap(900, 700); graphics = Graphics.FromImage(B_map); graphics.Clear(Color.White); pictureBox1.Image = B_map; именаБлоковБизнесФункций.Add(" Принятие заявок"); именаБлоковБизнесФункций.Add(" Формирование задания для отгрузки"); именаБлоковБизнесФункций.Add(" Распределение транспортных средств"); именаБлоковБизнесФункций.Add(" Отгрузка"); именаБлоковБизнесФункций.Add(" Подготовка документов"); именаБлоковБизнесФункций.Add(" Экспедирование"); именаБлоковБизнесФункций.Add(" Контроль и анализ договоров"); именаОтделов.Add(" Логистика"); именаОтделов.Add(" Транспортная\nкомпания"); именаОтделов.Add(" Отдел обра-\nботки доку-\nментов"); именаОтделов.Add(" Склад"); richTextBox1.ReadOnly = true; button2.Enabled = false; for (int i = 0; i < 2; i++) { Point P1; if (i < 1) { P1 = new Point((900 / 2) + 30, 5); началоКонец[i].Location = P1; началоКонец[i].Width = 30; началоКонец[i].Height = 30; } else { P1 = new Point((900 / 2) + (900 / 3) + 30, 640); началоКонец[i].Location = P1; началоКонец[i].Width = 30; началоКонец[i].Height = 30; }
} for (int i = 0; i < 7; i++) { Point P1 = new Point((900 / 2) + (900 / 4) - 30, i * 100 + 5); бизнесФункции1[i].Location = P1; бизнесФункции1[i].Width = 30; бизнесФункции1[i].Height = 30; } for (int i = 0; i < 7; i++) { Point P1 = new Point(900 / 4 - 30, i * 100 + 5); бизнесФункции[i].Location = P1; бизнесФункции[i].Width = 30; бизнесФункции[i].Height = 30; }
for (int i = 0; i < 4; i++) { Point P1; if (i < 2) { P1 = new Point(20, 250 + i * 250); } else { P1 = new Point((900 / 3) + 30, 250 + (i - 2) * 250); } Отделы[i].Location = P1; Отделы[i].Width = 100; Отделы[i].Height = 50; }
}
public void RisArrow(Point X, Point Y) { Pen penLINE = new Pen(Color.Black, 2); graphics.DrawLine(penLINE, X, Y); double ugol = Math.Atan2(X.X - Y.X, X.Y - Y.Y);
graphics.DrawLine(penLINE, Y.X, Y.Y, Convert.ToInt32(Y.X + 15 * Math.Sin(0.3 + ugol)), Convert.ToInt32(Y.Y + 15 * Math.Cos(0.3 + ugol))); graphics.DrawLine(penLINE, Y.X, Y.Y, Convert.ToInt32(Y.X + 15 * Math.Sin(ugol - 0.3)), Convert.ToInt32(Y.Y + 15 * Math.Cos(ugol - 0.3))); pictureBox1.Image = B_map; }
private void button1_Click(object sender, EventArgs e) {
richTextBox1.Text = " "; for (int i = 0; i < именаБлоковБизнесФункций.Count; i++) { richTextBox1.Text += Convert.ToString(i + 1) + " - " + именаБлоковБизнесФункций[i] + " \n"; }
Pen pen = new Pen(Color.Black, 2); Point p1 = new Point(900/2, 0); Point p2 = new Point(900/2, 700);
graphics.DrawLine(pen, p1, p2);
pen.Color = Color.Red; pen.Width = 3; graphics.DrawRectangles(pen, бизнесФункции); graphics.DrawRectangles(pen, бизнесФункции1); pen.Color = Color.Green; pen.Width = 3; graphics.DrawRectangles(pen, Отделы); graphics.DrawRectangles(pen, началоКонец); for (int i = 0; i < 7; i++) { String Text = String.Format(" {0}", Convert.ToString(i+1)); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, бизнесФункции[i].Location.X + kef, бизнесФункции[i].Location.Y + kef);
}
for (int i = 0; i < 2; i++) { if (i < 1) { String Text = String.Format(" {0}", " Nо"); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, началоКонец[i].Location.X + kef, началоКонец[i].Location.Y + kef); } else { String Text = String.Format(" {0}", " Nф"); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, началоКонец[i].Location.X + kef, началоКонец[i].Location.Y + kef); } }
for (int i = 0; i < 7; i++) { String Text = String.Format(" {0}", Convert.ToString(i + 1)); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, бизнесФункции1[i].Location.X + kef, бизнесФункции1[i].Location.Y + kef);
}
for (int i = 0; i < 4; i++) { String Text = String.Format(" {0}", именаОтделов[i]); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, Отделы[i].Location.X + kef, Отделы[i].Location.Y + kef);
} ///////////////////////////////////////////Стрелки для 2 диаграммы for (int i = 0; i < 6; i++) { Point X = new Point(бизнесФункции1[i].Location.X + 30 / 2, бизнесФункции1[i].Location.Y + 30); Point Y = new Point(бизнесФункции1[i + 1].Location.X + 30 / 2, бизнесФункции1[i + 1].Location.Y); RisArrow(X, Y); } for (int i = 0; i < 2; i++) { Point X; Point Y; if (i < 1) { X = new Point(началоКонец[i].Location.X + 30, началоКонец[i].Location.Y + 30 / 2); Y = new Point(бизнесФункции1[i].Location.X, бизнесФункции1[i].Location.Y + 30 / 2); RisArrow(X, Y);
} else { X = new Point(бизнесФункции1[бизнесФункции1.Length - 1].Location.X + 30, бизнесФункции1[бизнесФункции1.Length - 1].Location.Y + 30 / 2); Y = new Point(началоКонец[i].Location.X, началоКонец[i].Location.Y + 30 / 2); RisArrow(X, Y); }
}
for (int i = 0; i < 3; i++) { pen.Width = 2; pen.Color = Color.Black; Point X; Point Y;
switch (i) { case 0: { X = new Point(бизнесФункции1[1].Location.X, бизнесФункции1[1].Location.Y + 30 / 2); Y = new Point(бизнесФункции1[1].Location.X - 60, бизнесФункции1[1].Location.Y + 30 / 2); graphics.DrawLine(pen, X, Y);
X = Y; Y.X = бизнесФункции1[бизнесФункции1.Length - 1].Location.X - 60; Y.Y = бизнесФункции1[бизнесФункции1.Length - 1].Location.Y + 30 / 2; graphics.DrawLine(pen, X, Y);
X = Y;
Y.X = бизнесФункции1[бизнесФункции1.Length - 1].Location.X; RisArrow(X, Y); break; }
case 1: { X = new Point(бизнесФункции1[2].Location.X + 30, бизнесФункции1[2].Location.Y + 30 / 2); Y = new Point(бизнесФункции1[2].Location.X + 60, бизнесФункции1[2].Location.Y + 30 / 2); graphics.DrawLine(pen, X, Y);
X = Y; Y.X = бизнесФункции1[1].Location.X + 60; Y.Y = бизнесФункции1[1].Location.Y + 30 / 2; graphics.DrawLine(pen, X, Y);
X = Y;
Y.X = бизнесФункции1[1].Location.X + 30; RisArrow(X, Y); break; }
case 2: { X = new Point(бизнесФункции1[3].Location.X, бизнесФункции1[3].Location.Y + 30 / 2); Y = new Point(бизнесФункции1[3].Location.X - 30, бизнесФункции1[3].Location.Y + 30 / 2); graphics.DrawLine(pen, X, Y);
X = Y; Y.X = бизнесФункции1[2].Location.X - 30; Y.Y = бизнесФункции1[2].Location.Y + 30 / 2; graphics.DrawLine(pen, X, Y);
X = Y;
Y.X = бизнесФункции1[1].Location.X; RisArrow(X, Y); break; } }
}
///////////////////////////////////////////Стрелки для 1 диаграммы Point X1 = new Point(бизнесФункции[0].Location.X, бизнесФункции[0].Location.Y + 30/2); Point Y1 = new Point(Отделы[0].Location.X + 100 / 4, Отделы[0].Location.Y); RisArrow(X1, Y1);
X1.X += 30; Y1.X = Отделы[2].Location.X + 100 / 4; Y1.Y = Отделы[2].Location.Y; RisArrow(X1, Y1);
X1.X -= 30; X1.Y = бизнесФункции[1].Location.Y + 30 / 2; Y1.X = Отделы[0].Location.X + (100/4) * 3; Y1.Y = Отделы[0].Location.Y; RisArrow(X1, Y1);
X1.Y = бизнесФункции[2].Location.Y + 30 / 2; Y1.X = Отделы[1].Location.X + 100 / 4; Y1.Y = Отделы[1].Location.Y; RisArrow(X1, Y1);
X1.Y = бизнесФункции[3].Location.Y + 30 / 2; Y1.X = Отделы[1].Location.X + (100 / 4) * 3; Y1.Y = Отделы[1].Location.Y; RisArrow(X1, Y1);
X1.X += 30; Y1.X = Отделы[3].Location.X + 100 / 4; Y1.Y = Отделы[3].Location.Y; RisArrow(X1, Y1);
X1.Y = бизнесФункции[4].Location.Y + 30 / 2; Y1.X = Отделы[2].Location.X + (100 / 4) * 3; Y1.Y = Отделы[2].Location.Y + 50; RisArrow(X1, Y1);
X1.X -= 30; X1.Y = бизнесФункции[5].Location.Y + 30 / 2; Y1.X = Отделы[0].Location.X + (100 / 4) * 3; Y1.Y = Отделы[0].Location.Y + 50; RisArrow(X1, Y1);
Y1.X = Отделы[1].Location.X + 100; Y1.Y = Отделы[1].Location.Y + 50 / 2; RisArrow(X1, Y1);
X1.X += 30; X1.Y = бизнесФункции[6].Location.Y + 30 / 2; Y1.X = Отделы[2].Location.X + 100 / 4; Y1.Y = Отделы[2].Location.Y + 50; RisArrow(X1, Y1);
pictureBox1.Image = B_map; fl = true; button2.Enabled = true; }
private void pictureBox1_Click(object sender, EventArgs e) {
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { if (fl == true) { int k = -1; for (int i = 0; i < Отделы.Length; i++) { if (e.Location.X > = Отделы[i].Location.X & & e.Location.X < = Отделы[i].Location.X + 100 & & e.Location.Y > = Отделы[i].Location.Y & & e.Location.Y < = Отделы[i].Location.Y + 50) k = i;
}
switch (k) { case 0: { Form2 f2 = new Form2(); f2.ShowDialog(); break; } case 1: { MessageBox.Show(" Форма ТК"); break; } case 2: { MessageBox.Show(" Форма ООД"); break; } case 3: { MessageBox.Show(" Форма Склад"); break; } default: break; } } }
private void button2_Click(object sender, EventArgs e) { Form3 f = new Form3(); f.ShowDialog(); } } }
Form1.Designer.cs namespace Диплом { partial class Form1 { /// < summary> /// Требуется переменная конструктора. /// < /summary> private System.ComponentModel.IContainer components = null;
/// < summary> /// Освободить все используемые ресурсы. /// < /summary> /// < param name=" disposing" > истинно, если управляемый ресурс должен быть удален; иначе ложно.< /param> protected override void Dispose(bool disposing) { if (disposing & & (components! = null)) { components.Dispose(); } base.Dispose(disposing); }
#region Код, автоматически созданный конструктором форм Windows
/// < summary> /// Обязательный метод для поддержки конструктора - не изменяйте /// содержимое данного метода при помощи редактора кода. /// < /summary> private void InitializeComponent() { this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(13, 13); this.pictureBox1.Name = " pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(900, 700); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(919, 224); this.richTextBox1.Name = " richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(419, 494); this.richTextBox1.TabIndex = 1; this.richTextBox1.Text = " "; // // button1 // this.button1.Location = new System.Drawing.Point(919, 179); this.button1.Name = " button1"; this.button1.Size = new System.Drawing.Size(116, 39); this.button1.TabIndex = 2; this.button1.Text = " Нарисовать диаграммы"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(919, 12); this.button2.Name = " button2"; this.button2.Size = new System.Drawing.Size(116, 39); this.button2.TabIndex = 3; this.button2.Text = " Построить бизнес-процесс"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1350, 730); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.richTextBox1); this.Controls.Add(this.pictureBox1); this.Name = " Form1"; this.Text = " Диплом"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; } }
Form2.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 Form2: Form {
BussinesProcess BP; Graphics graphics; Bitmap B_map; public int kef = 10;
public int kefX = 50 + 90; public int kefY = 50 + 40;
public int W = 90; public int H = 40;
public Form2() { int K = 10; BP = new BussinesProcess(); String NM; InitializeComponent(); B_map = new Bitmap(900, 700); graphics = Graphics.FromImage(B_map); graphics.Clear(Color.White); pictureBox1.Image = B_map;
BP.funk = new Job(); BP.neiboor = new List< BussinesProcess> (); BP.nameProcess = " Логистика"; BP.PrOrJob = false; BP.fun = false; ///////////////////////////////////////////////////////////////////// BussinesProcess b = new BussinesProcess(); b.PrOrJob = true; b.fun = false; b.funk = new Job(); b.funk.funktion = new List< String> (); b.neiboor = new List< BussinesProcess> (); b.nameProcess = " Начальник от-\nдела логистики"; ////////////////////////////////////////////////////////////////////// b.funk.namePeople = " Марья Ивановна"; b.funk.nameOffice = " Начальник отдела логистики"; NM = " Найм новых сотрудников"; b.funk.funktion.Add(NM); NM = " Распределение ресурсов"; b.funk.funktion.Add(NM); NM = " Контроль качества"; b.funk.funktion.Add(NM); ///////////////////////////////////////////////////////////////////// BussinesProcess b1 = new BussinesProcess(); b1.PrOrJob = true; b1.fun = false; b1.funk = new Job(); b1.funk.funktion = new List< String> (); b1.nameProcess = " Логист"; ///////////////////////////////////////////////////////////////////// b1.funk.nameOffice = " Логист"; b1.funk.namePeople = " Сидоров Петя"; NM = " Выбор типа транспортного средства."; b1.funk.funktion.Add(NM); NM = " Выбор вида транспортного средства."; b1.funk.funktion.Add(NM); NM = " Совместное планирование транспортных процессов со складскими и производственными операциями."; b1.funk.funktion.Add(NM); NM = " Совместное планирование транспортных процессов на различных видах транспорта."; b1.funk.funktion.Add(NM); NM = " Обеспечение технологического единства транспортно-складского процесса."; b1.funk.funktion.Add(NM); NM = " Определение рациональных маршрутов поставки."; b1.funk.funktion.Add(NM); ///////////////////////////////////////////////////////////////////// b.neiboor.Add(b1);
///////////////////////////////////////////////////////////////////// b1 = new BussinesProcess(); b1.PrOrJob = true; b1.fun = false; b1.funk = new Job(); b1.funk.funktion = new List< String> (); b1.nameProcess = " Отдел экспе-\nдирования"; ///////////////////////////////////////////////////////////////////// b1.funk.nameOffice = " Экспедитор"; b1.funk.namePeople = " Иванов Федька"; NM = " Доставка товара."; b1.funk.funktion.Add(NM); NM = " Получение денежных средств."; b1.funk.funktion.Add(NM); NM = " Доставка денежных средств на базу."; b1.funk.funktion.Add(NM); ///////////////////////////////////////////////////////////////////// b.neiboor.Add(b1);
BP.neiboor.Add(b);
}
public IList< Point> raspredY(int size, int Y) { IList< Point> arr = new List< Point> (size);
for (int i = 0; i < size; i++) { Point xy = new Point(); xy.Y = Y; xy.X = kefX + (i+1) * 500 / (size + 1); arr.Add(xy); }
return arr;
}
public void RisArrow(Point X, Point Y) { Pen penLINE = new Pen(Color.Black, 2); graphics.DrawLine(penLINE, X, Y); double ugol = Math.Atan2(X.X - Y.X, X.Y - Y.Y);
graphics.DrawLine(penLINE, Y.X, Y.Y, Convert.ToInt32(Y.X + 15 * Math.Sin(0.3 + ugol)), Convert.ToInt32(Y.Y + 15 * Math.Cos(0.3 + ugol))); graphics.DrawLine(penLINE, Y.X, Y.Y, Convert.ToInt32(Y.X + 15 * Math.Sin(ugol - 0.3)), Convert.ToInt32(Y.Y + 15 * Math.Cos(ugol - 0.3))); pictureBox1.Image = B_map; }
public void RisBlock(BussinesProcess a) {
Pen pen = new Pen(Color.Red, 3); graphics.DrawRectangle(pen, a.m.X, a.m.Y, W, H); String Text = String.Format(" {0}", a.nameProcess); Brush Кисть = new SolidBrush(Color.Black); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(Text, new System.Drawing.Font(" Times New Roman", 9, FontStyle.Bold), Кисть, a.m.X + kef, a.m.Y + kef);
pictureBox1.Image = B_map; }
private void Form2_Load(object sender, EventArgs e) { BP.m.Y = 10; int Y = kefY + BP.m.Y; BP.m.X = kefX + 500 / (1 + 1); IList< Point> arr = new List< Point> (); arr = raspredY(BP.neiboor.Count, Y); for (int i = 0; i < BP.neiboor.Count; i++) { BP.neiboor[i].m = arr[i]; } Y = Y + kefY;
RisBlock(BP);
for (int i = 0; i < BP.neiboor.Count; i++) { RisBlock(BP.neiboor[i]);
}
for (int i = 0; i < BP.neiboor.Count; i++) { arr = raspredY(BP.neiboor[i].neiboor.Count, Y); for (int j = 0; j < BP.neiboor[i].neiboor.Count; j++) { BP.neiboor[i].neiboor[j].m = arr[j]; RisBlock(BP.neiboor[i].neiboor[j]);
}
}
Point XX = new Point(); XX.X = BP.m.X + W / 2; XX.Y = BP.m.Y + H; for (int i = 0; i < BP.neiboor.Count; i++) {
Point YY = new Point(); YY.Y = BP.neiboor[i].m.Y; YY.X = BP.neiboor[i].m.X + W / 2; RisArrow(XX, YY); Point XYY = new Point(); XYY.X = YY.X; XYY.Y = YY.Y + H; for (int j = 0; j < BP.neiboor[i].neiboor.Count; j++) { Point YYY = new Point(); YYY.Y = BP.neiboor[i].neiboor[j].m.Y; YYY.X = BP.neiboor[i].neiboor[j].m.X + W / 2; RisArrow(XYY, YYY); }
}
}
private void pictureBox1_MouseClick(object sender, EventArgs e) {
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { for (int i = 0; i < BP.neiboor.Count; i++) { if (BP.neiboor[i].PrOrJob == true & & BP.neiboor[i].m.X < = e.Location.X & & BP.neiboor[i].m.X + W > = e.Location.X & & BP.neiboor[i].m.Y < = e.Location.Y & & BP.neiboor[i].m.Y + H > = e.Location.Y) { String Str = " "; Str = BP.neiboor[i].funk.nameOffice + " \n"; for (int j = 0; j < BP.neiboor[i].funk.funktion.Count; j++) { Str += Convert.ToString(j + 1) + " - " + BP.neiboor[i].funk.funktion[j] + " \n"; } MessageBox.Show(Str); } else { for (int j = 0; j < BP.neiboor[i].neiboor.Count; j++) { if (BP.neiboor[i].neiboor[j].PrOrJob == true & & BP.neiboor[i].neiboor[j].m.X < = e.Location.X & & BP.neiboor[i].neiboor[j].m.X + W > = e.Location.X & & BP.neiboor[i].neiboor[j].m.Y < = e.Location.Y & & BP.neiboor[i].neiboor[j].m.Y + H > = e.Location.Y) { String Str = " "; Str = BP.neiboor[i].neiboor[j].funk.nameOffice + " \n"; for (int j1 = 0; j1 < BP.neiboor[i].neiboor[j].funk.funktion.Count; j1++) { Str += Convert.ToString(j1 + 1) + " - " + BP.neiboor[i].neiboor[j].funk.funktion[j1] + " \n"; } MessageBox.Show(Str); }
}
} }
}
} }
Form2.Designer.cs namespace Диплом { partial class Form2 { /// < summary> /// Required designer variable. /// < /summary> private System.ComponentModel.IContainer components = null;
/// < summary> /// Clean up any resources being used. /// < /summary> /// < param name=" disposing" > true if managed resources should be disposed; otherwise, false.< /param> protected override void Dispose(bool disposing) { if (disposing & & (components! = null)) { components.Dispose(); } base.Dispose(disposing); }
#region Windows Form Designer generated code
/// < summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// < /summary> private void InitializeComponent() { this.pictureBox1 = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(12, 12); this.pictureBox1.Name = " pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(900, 700); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); // // Form2 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(924, 725); this.Controls.Add(this.pictureBox1); this.Name = " Form2"; this.Text = " Логистика"; this.Load += new System.EventHandler(this.Form2_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1; } }
Form3.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 Form3: Form { public struct El { public int numBP; public String nameBL; public bool fl; public bool Start; public int t; public int n; public int s; }
public struct StrGr { public El A; public IList< El> B;
}
public struct Variant { public IList< El> var; }
public struct Znach { public int t; public int n; public int s; }
IList< Znach> znach = new List< Znach> (); IList< Variant> varianty = new List< Variant> (); IList< StrGr> grammatik= new List< StrGr> (); public Form3() { InitializeComponent(); richTextBox2.ReadOnly = true; richTextBox1.ReadOnly = true; El Start = new El(); Start.fl = false; Start.Start = true; Start.nameBL = " "; Start.numBP = -1; Start.n = 0; Start.s = Start.t = -1;
El Finish = new El(); Finish.fl = false; Finish.Start = false; Finish.nameBL = " "; Finish.numBP = -1; Finish.n = 0; Finish.s = Finish.t = -1;
El l1 = new El(); l1.fl = true; l1.Start = true; l1.numBP = 1; l1.nameBL = " Логистика"; l1.n = 0; l1.s = l1.t = -1;
El o1 = new El(); o1.fl = true; o1.Start = true; o1.numBP = 1; o1.nameBL = " Отдел обработки документов"; o1.n = 0; o1.s = o1.t = -1;
El l2 = new El(); l2.fl = true; l2.Start = true; l2.numBP = 2; l2.nameBL = " Логистика"; l2.n = 0; l2.s = l2.t = -1;
El t3 = new El(); t3.fl = true; t3.Start = true; t3.numBP = 3; t3.nameBL = " Транспортная компания"; t3.n = 0; t3.s = t3.t = -1;
El t4 = new El(); t4.fl = true; t4.Start = true; t4.numBP = 4; t4.nameBL = " Транспортная компания"; t4.n = 0; t4.s = t4.t = -1;
El s4 = new El(); s4.fl = true; s4.Start = true; s4.numBP = 4; s4.nameBL = " Склад"; s4.n = 0; s4.s = s4.t = -1;
El o5 = new El(); o5.fl = true; o5.Start = true; o5.numBP = 5; o5.nameBL = " Отдел обработки документов"; o5.n = 0; o5.s = o5.t = -1;
El t6 = new El(); t6.fl = true; t6.Start = true; t6.numBP = 6; t6.nameBL = " Транспортная компания"; t6.n = 0; t6.s = t6.t = -1;
El l6 = new El(); l6.fl = true; l6.Start = true; l6.numBP = 6; l6.nameBL = " Логистика"; l6.n = 0; l6.s = l6.t = -1;
El o7 = new El(); o7.fl = true; o7.Start = true; o7.numBP = 7; o7.nameBL = " Отдел обработки документов"; o7.n = 0; o7.s = o7.t = -1;
StrGr g1 = new StrGr(); g1.A = Start; g1.B = new List< El> (); g1.B.Add(l1); g1.B.Add(o1);
StrGr g2 = new StrGr(); g2.A = l1; g2.B = new List< El> (); g2.B.Add(l2);
StrGr g3 = new StrGr(); g3.A = o1; g3.B = new List< El> (); g3.B.Add(l2);
StrGr g4 = new StrGr(); g4.A = l2; g4.B = new List< El> (); g4.B.Add(t3); g4.B.Add(o7);
StrGr g5 = new StrGr(); g5.A = t3; g5.B = new List< El> (); g5.B.Add(l2); g5.B.Add(t4); g5.B.Add(s4);
StrGr g6 = new StrGr(); g6.A = t4; g6.B = new List< El> (); g6.B.Add(t3); g6.B.Add(o5);
StrGr g7 = new StrGr(); g7.A = s4; g7.B = new List< El> (); g7.B.Add(t3); g7.B.Add(o5);
StrGr g8 = new StrGr(); g8.A = o5; g8.B = new List< El> (); g8.B.Add(t6); g8.B.Add(l6);
StrGr g9 = new StrGr(); g9.A = t6; g9.B = new List< El> (); g9.B.Add(o7);
StrGr g10 = new StrGr(); g10.A = l6; g10.B = new List< El> (); g10.B.Add(o7);
StrGr g11 = new StrGr(); g11.A = o7; g11.B = new List< El> (); g11.B.Add(Finish);
grammatik.Add(g1); grammatik.Add(g2); grammatik.Add(g3); grammatik.Add(g4); grammatik.Add(g5); grammatik.Add(g6); grammatik.Add(g7); grammatik.Add(g8); grammatik.Add(g9); grammatik.Add(g10); grammatik.Add(g11);
}
private void Form3_Load(object sender, EventArgs e) { PrintGrammatik(); }
void PrintGrammatikResurs() { richTextBox1.Text = " "; for (int i = 0; i < grammatik.Count; i++) { if (! grammatik[i].A.fl) { if (grammatik[i].A.Start) richTextBox1.Text += " No -> "; else richTextBox1.Text += " Nф -> "; } else { richTextBox1.Text += Convert.ToString(grammatik[i].A.numBP) + " {" + grammatik[i].A.nameBL[0] + " } -> "; }
for (int j = 0; j < grammatik[i].B.Count - 1; j++) { if (! grammatik[i].B[j].fl) { if (grammatik[i].B[j].Start) richTextBox1.Text += " No | "; else richTextBox1.Text += " Nф | "; } else { richTextBox1.Text += Convert.ToString(grammatik[i].B[j].numBP) + " {" + grammatik[i].B[j].nameBL[0] + " } t = " + grammatik[i].B[j].t + " n = " + grammatik[i].B[j].n + " s = " + grammatik[i].B[j].s + " | "; }
}
if (! grammatik[i].B[grammatik[i].B.Count - 1].fl) { if (grammatik[i].B[grammatik[i].B.Count - 1].Start) richTextBox1.Text += " No \n"; else richTextBox1.Text += " Nф \n"; } else { richTextBox1.Text += Convert.ToString(grammatik[i].B[grammatik[i].B.Count - 1].numBP) + " {" + grammatik[i].B[grammatik[i].B.Count - 1].nameBL[0] + " } t = " + grammatik[i].B[grammatik[i].B.Count - 1].t + " n = " + grammatik[i].B[grammatik[i].B.Count - 1].n + " s = " + grammatik[i].B[grammatik[i].B.Count - 1].s + " \n"; } } }
void PrintGrammatik() { richTextBox1.Text = " "; for (int i = 0; i < grammatik.Count; i++) { if (! grammatik[i].A.fl) { if (grammatik[i].A.Start) richTextBox1.Text += " No -> "; else richTextBox1.Text += " Nф -> "; } else { richTextBox1.Text += Convert.ToString(grammatik[i].A.numBP) + " {" + grammatik[i].A.nameBL[0] + " } -> "; }
for (int j = 0; j < grammatik[i].B.Count - 1; j++) { if (! grammatik[i].B[j].fl) { if (grammatik[i].B[j].Start) richTextBox1.Text += " No | "; else richTextBox1.Text += " Nф | "; } else { richTextBox1.Text += Convert.ToString(grammatik[i].B[j].numBP) + " {" + grammatik[i].B[j].nameBL[0] + " } | "; }
}
if (! grammatik[i].B[grammatik[i].B.Count - 1].fl) { if (grammatik[i].B[grammatik[i].B.Count - 1].Start) richTextBox1.Text += " No \n"; else richTextBox1.Text += " Nф \n"; } else { richTextBox1.Text += Convert.ToString(grammatik[i].B[grammatik[i].B.Count - 1].numBP) + " {" + grammatik[i].B[grammatik[i].B.Count - 1].nameBL[0] + " } \n"; } } }
private void button2_Click(object sender, EventArgs e) { Random rnd = new Random(); if (textBox34.Text == " " || textBox34.Text == " " || textBox35.Text == " " || textBox35.Text == " " || textBox36.Text == " " || textBox36.Text == " ") { MessageBox.Show(" Незаполнены диапазоны"); return; } int t = Convert.ToInt32(textBox34.Text); int n = Convert.ToInt32(textBox35.Text); int s = Convert.ToInt32(textBox36.Text);
for (int i = 0; i < grammatik.Count; i++) { switch (i) { case 0: { textBox1.Text = Convert.ToString(rnd.Next(1, t)); textBox11.Text = Convert.ToString(rnd.Next(1, n)); textBox21.Text = Convert.ToString(rnd.Next(1, s)); break; } case 1: { textBox2.Text = Convert.ToString(rnd.Next(1, t)); textBox12.Text = Convert.ToString(rnd.Next(1, n)); textBox22.Text = Convert.ToString(rnd.Next(1, s)); break; } case 2: { textBox3.Text = Convert.ToString(rnd.Next(1, t)); textBox13.Text = Convert.ToString(rnd.Next(1, n)); textBox23.Text = Convert.ToString(rnd.Next(1, s)); break; } case 3: { textBox4.Text = Convert.ToString(rnd.Next(1, t)); textBox14.Text = Convert.ToString(rnd.Next(1, n)); textBox24.Text = Convert.ToString(rnd.Next(1, s)); break; } case 4: { textBox5.Text = Convert.ToString(rnd.Next(1, t)); textBox15.Text = Convert.ToString(rnd.Next(1, n)); textBox25.Text = Convert.ToString(rnd.Next(1, s)); break; } case 5: { textBox6.Text = Convert.ToString(rnd.Next(1, t)); textBox16.Text = Convert.ToString(rnd.Next(1, n)); textBox26.Text = Convert.ToString(rnd.Next(1, s)); break; } case 6: { textBox7.Text = Convert.ToString(rnd.Next(1, t)); textBox17.Text = Convert.ToString(rnd.Next(1, n)); textBox27.Text = Convert.ToString(rnd.Next(1, s)); break; } case 7: { textBox8.Text = Convert.ToString(rnd.Next(1, t)); textBox18.Text = Convert.ToString(rnd.Next(1, n)); textBox28.Text = Convert.ToString(rnd.Next(1, s)); break; } case 8: { textBox9.Text = Convert.ToString(rnd.Next(1, t)); textBox19.Text = Convert.ToString(rnd.Next(1, n)); textBox29.Text = Convert.ToString(rnd.Next(1, s)); break; } case 9: { textBox10.Text = Convert.ToString(rnd.Next(1, t)); textBox20.Text = Convert.ToString(rnd.Next(1, n)); textBox30.Text = Convert.ToString(rnd.Next(1, s)); break; } } }
}
private void button1_Click(object sender, EventArgs e) { int maxT; int maxN; int maxS; if (textBox31.Text == " " || textBox31.Text == " " || textBox32.Text == " " || textBox32.Text == " " || textBox33.Text == " " || textBox33.Text == " ") { MessageBox.Show(" Незаполнены предпочтения по ресурсам"); return; } maxT = Convert.ToInt32(textBox31.Text); maxN = Convert.ToInt32(textBox32.Text); maxS = Convert.ToInt32(textBox33.Text);
for (int i = 0; i < grammatik.Count; i++) { for (int j = 0; j < grammatik[i].B.Count; j++) { if(grammatik[i].B[j].fl) { switch (grammatik[i].B[j].numBP) { case 1: { switch(grammatik[i].B[j].nameBL[0]) { case 'О': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox2.Text); a.n = Convert.ToInt32(textBox12.Text); a.s = Convert.ToInt32(textBox22.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } case 'Л': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox1.Text); a.n = Convert.ToInt32(textBox11.Text); a.s = Convert.ToInt32(textBox21.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 2: { switch (grammatik[i].B[j].nameBL[0]) { case 'Л': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox3.Text); a.n = Convert.ToInt32(textBox13.Text); a.s = Convert.ToInt32(textBox23.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 3: { switch (grammatik[i].B[j].nameBL[0]) { case 'Т': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox4.Text); a.n = Convert.ToInt32(textBox14.Text); a.s = Convert.ToInt32(textBox24.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 4: { switch (grammatik[i].B[j].nameBL[0]) { case 'Т': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox5.Text); a.n = Convert.ToInt32(textBox15.Text); a.s = Convert.ToInt32(textBox25.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } case 'С': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox6.Text); a.n = Convert.ToInt32(textBox16.Text); a.s = Convert.ToInt32(textBox26.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 5: { switch (grammatik[i].B[j].nameBL[0]) { case 'О': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox7.Text); a.n = Convert.ToInt32(textBox17.Text); a.s = Convert.ToInt32(textBox27.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 6: { switch (grammatik[i].B[j].nameBL[0]) { case 'Т': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox8.Text); a.n = Convert.ToInt32(textBox18.Text); a.s = Convert.ToInt32(textBox28.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } case 'Л': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox9.Text); a.n = Convert.ToInt32(textBox19.Text); a.s = Convert.ToInt32(textBox29.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; } case 7: { switch (grammatik[i].B[j].nameBL[0]) { case 'О': { El a = new El(); a = grammatik[i].B[j]; a.t = Convert.ToInt32(textBox10.Text); a.n = Convert.ToInt32(textBox20.Text); a.s = Convert.ToInt32(textBox30.Text); grammatik[i].B.RemoveAt(j); grammatik[i].B.Insert(j, a); break; } default: { MessageBox.Show(" Что то пошло не так в заполнении"); return; }
} break; }
} } } }
// PrintGrammatikResurs(); Variant X = new Variant(); X.var = new List< El> (); richTextBox2.Text = " "; rekObchod(X); for (int i = 0; i < varianty.Count; i++) { Znach A = new Znach(); A.n = 0; A.s = 0; A.t = 0; for (int j = 0; j < varianty[i].var.Count; j++) { A.t += varianty[i].var[j].t; A.n += varianty[i].var[j].n; A.s += varianty[i].var[j].s * A.n; } znach.Add(A); } if (maxN == -1) maxN = 99999999; if (maxT == -1) maxT = 99999999; if (maxS == -1) maxS = 99999999;
PrintVar(maxT, maxN, maxS);
}
void PrintVar(int t, int n, int s) { richTextBox2.Text = " Варианты которые вам подходят: \n"; for (int i = 0; i < varianty.Count; i++) { if (znach[i].t < t & & znach[i].n < n & & znach[i].s < s) { richTextBox2.Text += " No -> "; for (int j = 0; j < varianty[i].var.Count; j++) { richTextBox2.Text += varianty[i].var[j].numBP + " {" + varianty[i].var[j].nameBL[0] + " } -> "; } richTextBox2.Text += " Nф: " + " t = " + znach[i].t + "; n = " + znach[i].n + "; s = " + znach[i].s + " \n";
} } } void rekObchod(Variant a) { if (a.var.Count < = 0) { for (int i = 0; i < grammatik[0].B.Count; i++) { a.var.Add(grammatik[0].B[i]); rekObchod(a); a.var.RemoveAt(0); } } else { for (int i = 0; i < grammatik.Count; i++) { if (grammatik[i].A.nameBL == a.var[a.var.Count - 1].nameBL & & grammatik[i].A.numBP == a.var[a.var.Count - 1].numBP) { for (int j = 0; j < grammatik[i].B.Count; j++) { a.var.Add(grammatik[i].B[j]); if (a.var[a.var.Count - 1].fl == false) {
a.var.RemoveAt(a.var.Count - 1); Variant b = new Variant(); b.var = new List< El> (); for (int k = 0; k < a.var.Count; k++) b.var.Add(a.var[k]); varianty.Add(b); return; } else if (a.var[a.var.Count - 1].numBP! = grammatik[i].A.numBP + 1) { a.var.RemoveAt(a.var.Count - 1); continue; } else {
rekObchod(a); a.var.RemoveAt(a.var.Count - 1); } }
} } } } } }
Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms;
namespace Диплом { static class Program { /// < summary> /// Главная точка входа для приложения. /// < /summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }
|