2024-09-30 23:54:03 +04:00
|
|
|
|
using System.Windows.Forms;
|
2024-10-28 20:23:38 +04:00
|
|
|
|
using ComponentsLibrary.entities;
|
2024-09-30 23:54:03 +04:00
|
|
|
|
|
2024-09-30 22:43:40 +04:00
|
|
|
|
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("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSaveTextWord_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
using var dialog = new SaveFileDialog
|
2024-09-30 23:54:03 +04:00
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
Filter = "docx|*.docx"
|
|
|
|
|
};
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
2024-09-30 23:54:03 +04:00
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DocumentSymple doc = new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?", richTextBoxWord.Lines);
|
|
|
|
|
componentBigText.CreateWordText(doc);
|
|
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
2024-09-30 23:54:03 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSaveTable_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
List<int[]> mergedColumns = new()
|
2024-09-30 23:54:03 +04:00
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
new int[] { 1, 5 },
|
|
|
|
|
new int[] { 6, 7 },
|
|
|
|
|
};
|
2024-09-30 23:54:03 +04:00
|
|
|
|
|
2024-10-28 20:23:38 +04:00
|
|
|
|
var columns = new List<ColumnParams>
|
|
|
|
|
{
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "", PropertyName = "Status", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD>",PropertyName = "Name", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Surname", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Age", Width = 0.1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD>", PropertyName = "Childrens", Width = 0.1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Car", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Post", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD>", PropertyName = "Experience", Width = 1 },
|
|
|
|
|
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 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" }
|
|
|
|
|
};
|
2024-09-30 23:54:03 +04:00
|
|
|
|
|
|
|
|
|
|
2024-10-28 20:23:38 +04:00
|
|
|
|
using var dialog = new SaveFileDialog
|
2024-09-30 23:54:03 +04:00
|
|
|
|
{
|
2024-10-28 20:23:38 +04:00
|
|
|
|
Filter = "docx|*.docx"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DocumentTable<Employee> info = new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2", columns, employees, mergedColumns);
|
|
|
|
|
componentTable.CreateTable(info);
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
2024-09-30 23:54:03 +04:00
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2024-10-28 20:23:38 +04:00
|
|
|
|
}
|
2024-09-30 23:54:03 +04:00
|
|
|
|
}
|
2024-09-30 22:43:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|