114 lines
4.6 KiB
C#
114 lines
4.6 KiB
C#
using System.Windows.Forms;
|
|
using ComponentsLibrary.entities;
|
|
|
|
namespace ComponentsView
|
|
{
|
|
public partial class FormComponents : Form
|
|
{
|
|
public FormComponents()
|
|
{
|
|
InitializeComponent();
|
|
testComponent.FileName = "2.txt";
|
|
}
|
|
|
|
private void buttonSaveText_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
testComponent.SaveToFile(richTextBoxTest.Lines);
|
|
MessageBox.Show("Ñîõàðíåíî óñïåøíî", "Ðåçóëüòàò",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Îøèáêà!",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
|
|
private void buttonSaveTextWord_Click(object sender, EventArgs e)
|
|
{
|
|
using var dialog = new SaveFileDialog
|
|
{
|
|
Filter = "docx|*.docx"
|
|
};
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
DocumentSymple doc = new(dialog.FileName, "Êàêîé-òî çàãîëîâîê?", richTextBoxWord.Lines);
|
|
componentBigText.CreateWordText(doc);
|
|
MessageBox.Show("Ñîõàðíåíî óñïåøíî", "Ðåçóëüòàò",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Îøèáêà!",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonSaveTable_Click(object sender, EventArgs e)
|
|
{
|
|
List<int[]> mergedColumns = new()
|
|
{
|
|
new int[] { 1, 5 },
|
|
new int[] { 6, 7 },
|
|
};
|
|
|
|
var columns = new List<ColumnParams>
|
|
{
|
|
new() { FirstRowHeader = "Ñòàòóñ", SecondRowHeader = "", PropertyName = "Status", Width = 1 },
|
|
new() { FirstRowHeader = "Ëè÷íûå äàííûå", SecondRowHeader = "Èìÿ",PropertyName = "Name", Width = 1 },
|
|
new() { FirstRowHeader = "Ëè÷íûå äàííûå", SecondRowHeader = "Ôàìèëèÿ", PropertyName = "Surname", Width = 1 },
|
|
new() { FirstRowHeader = "Ëè÷íûå äàííûå", SecondRowHeader = "Âîçðàñò", PropertyName = "Age", Width = 0.1 },
|
|
new() { FirstRowHeader = "Ëè÷íûå äàííûå", SecondRowHeader = "Äåòè", PropertyName = "Childrens", Width = 0.1 },
|
|
new() { FirstRowHeader = "Ëè÷íûå äàííûå", SecondRowHeader = "Ìàøèíà", PropertyName = "Car", Width = 1 },
|
|
new() { FirstRowHeader = "Ðàáîòà", SecondRowHeader = "Äîëæíîñòü", PropertyName = "Post", Width = 1 },
|
|
new() { FirstRowHeader = "Ðàáîòà", SecondRowHeader = "Ñòàæ", PropertyName = "Experience", Width = 1 },
|
|
new() { FirstRowHeader = "Ïðåìèÿ", SecondRowHeader = "", PropertyName = "Prize", Width = 1 },
|
|
};
|
|
|
|
var employees = new List<Employee>
|
|
{
|
|
new() { Status = "Active", Name = "John", Surname = "Doe", Age = "35", Childrens = "2", Car = "Toyota", Post = "Manager", Experience = "10 years", Prize = "5000" },
|
|
new() { Status = "On Leave", Name = "Alice", Surname = "Smith", Age = "28", Childrens = "1", Car = "Honda", Post = "Developer", Experience = "5 years", Prize = "3000" },
|
|
new() { Status = "Active", Name = "Bob", Surname = "Brown", Age = "40", Childrens = "3", Car = "Ford", Post = "Team Lead", Experience = "15 years", Prize = "7000" },
|
|
new() { Status = "Retired", Name = "Carol", Surname = "Johnson", Age = "65", Childrens = "4", Car = "None", Post = "Accountant", Experience = "30 years", Prize = "10000" },
|
|
new() { Status = "Active", Name = "David", Surname = "Wilson", Age = "45", Childrens = "2", Car = "Chevrolet", Post = "Designer", Experience = "20 years", Prize = "4000" },
|
|
new() { Status = "Active", Name = "Eve", Surname = "Davis", Age = "32", Childrens = "0", Car = "Tesla", Post = "Data Scientist", Experience = "8 years", Prize = "6000" },
|
|
new() { Status = "On Leave", Name = "Frank", Surname = "Miller", Age = "38", Childrens = "2", Car = "BMW", Post = "Product Manager", Experience = "12 years", Prize = "5500" },
|
|
new() { Status = "Active", Name = "Grace", Surname = "Taylor", Age = "29", Childrens = "1", Car = "Mercedes", Post = "QA Engineer", Experience = "6 years", Prize = "3500" },
|
|
new() { Status = "Resigned", Name = "Henry", Surname = "Anderson", Age = "50", Childrens = "3", Car = "Audi", Post = "CTO", Experience = "25 years", Prize = "12000" },
|
|
new() { Status = "Active", Name = "Ivy", Surname = "Thomas", Age = "27", Childrens = "0", Car = "Volkswagen", Post = "Intern", Experience = "1 year", Prize = "1000" }
|
|
};
|
|
|
|
|
|
using var dialog = new SaveFileDialog
|
|
{
|
|
Filter = "docx|*.docx"
|
|
};
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
DocumentTable<Employee> info = new(dialog.FileName, "Çàäàíèå 2", columns, employees, mergedColumns);
|
|
componentTable.CreateTable(info);
|
|
|
|
MessageBox.Show("Ñîõðàíåíî óñïåøíî", "Ðåçóëüòàò",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Îøèáêà!",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|