private void MenuClick(object sender, EventArgs e) { Button but = sender as Button; foreach (Control menbut in MenuMarkup.Controls) { if (menbut is Button) { menbut.BackColor = DefaultBackColor; } } but.BackColor = Color.LightGray; MainTabs.SelectedIndex = but.TabIndex; if (MainTabs.SelectedIndex == 2) { SaveDirectoryInp.Text = ConfigWorksService.getValue(ConfigWorksService.Options.ReportDirectory); if (ConfigWorksService.getValue(ConfigWorksService.Options.Units) == "sm") { cmRadio.Checked = true; } else { mRadio.Checked = true; } RepotRooms.Checked = Convert.ToBoolean(ConfigWorksService.getValue(ConfigWorksService.Options.ReportRooms)) ? true:false; Help.Checked = Convert.ToBoolean(ConfigWorksService.getValue(ConfigWorksService.Options.Hints)) ? true : false; } }
public NewForm() { JSONSerializeService.ReadInput("works.json"); ConfigWorksService.CheckSettings(); InitializeComponent(); MainForm = this; MainTabs.ItemSize = new Size(0, 1); Rooms.Add(roomTabContent1.Room); roomTabContent1.worktable.RowsAdded += Refresh; roomTabContent1.worktable.RowsRemoved += Refresh; Functions.ContextMenu(RoomTabs, new List <string>() { "Удалить" }, new List <EventHandler>() { DeleteTab } ); Functions.ContextMenu(AdminWorks.WorksList, new List <string>() { "Добавить", "Редактировать", "Удалить" }, new List <EventHandler>() { Add, Edit, Remove }); Functions.ContextMenu(finaltable, new List <string>() { "Обновить" }, new List <EventHandler>() { Refresh }); AdminWorks.Title.Text = "Настройка работ"; roomTabContent1.Room.CheckedWorks = roomTabContent1.worksTypeTree1.CheckedWorks; roomTabContent1.Room.Title = "Комната"; TipsService.AddTip(roomTabContent1.worksTypeTree1, "Выберите работы, которые нужно добавить в смету"); TipsService.AddTip(roomTabContent1.worktable, "Здесь находятся те работы, которые вы добавили к данной комнате, чтобы изменить параметр кликните дважды на серой строке"); TipsService.AddTip(finaltable, "Так будет выглядеть таблица в отчёте"); TipsService.AddTip(RefreshTable, "Обновить таблицы, для внесения изменений"); TipsService.AddTip(Units, "Выберите единицы измерения, они будут применятся ко всем параметрам "); TipsService.AddTip(RepotRooms, "Создать смету по каждой комнате"); TipsService.AddTip(SaveSetBut, "Чтобы изменения вступили в силу, нажмите сохранить"); TipsService.AddTip(Help, "Включить режим обучения(требуется перезапуск)"); if (ConfigWorksService.getValue(ConfigWorksService.Options.Remebered) == "false") { TipsService.AddTip(splitContainer2.Panel2, "Кликните для того, чтобы авторизоваться и редактировать список работ"); } TipsService.AddTip(DownloadfromExcel, "Загрузить работы из Excel шаблона"); TipsService.AddTip(AdminWorks, "Нажмите правой кнопкой мыши, чтобы увидеть список действий, для того, чтобы удалить работу выберите её"); }
public static void SetToolTip(string text, Control control) { if (Convert.ToBoolean(ConfigWorksService.getValue(ConfigWorksService.Options.Hints))) { ToolTip hint = new ToolTip(); hint.InitialDelay = 10; //hint.ReshowDelay = 1; hint.ShowAlways = true; hint.Active = true; hint.UseAnimation = true; hint.UseFading = true; hint.SetToolTip(control, text); } }
public SelectDoorsWindows() { InitializeComponent(); Doors.Controls.Add(CreateTable(doors)); Windows.Controls.Add(CreateTable(windows)); if (ConfigWorksService.getValue(ConfigWorksService.Options.Units) == "sm") { foreach (var elem in doors) { elem.Params[Entity.ParamName.Height] *= 100; elem.Params[Entity.ParamName.Width] *= 100; } foreach (var elem in windows) { elem.Params[Entity.ParamName.Height] *= 100; elem.Params[Entity.ParamName.Width] *= 100; } } }
private void splitContainer2_Panel2_MouseClick(object sender, MouseEventArgs e) { if (AdminTable.ClientRectangle.Contains(e.Location)) { if (!LoginClass.IsLoged && !Convert.ToBoolean(ConfigWorksService.getValue(ConfigWorksService.Options.Remebered))) { Form lf = LoginClass.SignIn(); Functions.CenterForm(lf, this); lf.Show(); if (LoginClass.IsLoged) { AdminTable.Enabled = true; } } else { AdminTable.Enabled = true; } } }
private void SaveSetBut_Click(object sender, EventArgs e) { ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.Hints), Help.Checked.ToString()); if (cmRadio.Checked) { ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.Units), "sm"); } if (mRadio.Checked) { ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.Units), "m"); } if (RepotRooms.Checked) { ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.ReportRooms), "true"); } else { ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.ReportRooms), "false"); } ConfigWorksService.ChangeValue(ConfigWorksService.getKey(ConfigWorksService.Options.ReportDirectory), SelectReportDirDialog.SelectedPath); }
private void Create_Report(object sender, EventArgs e) { if (finaltable.RowCount != 1) { string[,] content = new string[finaltable.RowCount, finaltable.ColumnCount]; string[] headers = new string[finaltable.ColumnCount]; for (int i = 0; i < finaltable.ColumnCount; i++) { headers[i] = finaltable.Columns[i].HeaderText; } for (int i = 0; i < finaltable.RowCount; i++) { for (int j = 0; j < finaltable.ColumnCount; j++) { if (finaltable.Rows[i].Cells[j].Value != null) { content[i, j] = finaltable.Rows[i].Cells[j].Value.ToString(); } else { content[i, j] = ""; } } } string path = ""; if (!Directory.Exists(ConfigWorksService.getValue(ConfigWorksService.Options.ReportDirectory))) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowDialog(); path = dialog.SelectedPath + "\\Отчёт"; dialog.Dispose(); } else { path = ConfigWorksService.getValue(ConfigWorksService.Options.ReportDirectory) + "\\Отчёт" + PDFWriteService.CurrentDocumentsCount; } int k; for (k = 0; File.Exists(path + "(" + k + ").pdf"); k++) { ; } if (File.Exists(path + ".pdf")) { path += "(" + k + ")"; } PDFWriteService.CreateNewDocument(path); PDFWriteService.AddTable(path, content, headers, new MigraDoc.DocumentObjectModel.ParagraphAlignment[] { MigraDoc.DocumentObjectModel.ParagraphAlignment.Left, MigraDoc.DocumentObjectModel.ParagraphAlignment.Center, MigraDoc.DocumentObjectModel.ParagraphAlignment.Center, MigraDoc.DocumentObjectModel.ParagraphAlignment.Center }, new bool[] { false, false, false, false }); PDFWriteService.RenderDocToPdf(path); MessageBox.Show("Отчёт создан"); } else { MessageBox.Show("Отчёт не создан, пустая таблица"); } }
private void Refresh(object sender, EventArgs e) { Regex reg = new Regex(@"[0-9]+"); finaltable.Rows.Clear(); RoomResT.Text = ""; double[] results = new double[4]; foreach (Room room in Rooms) { RoomResT.Text += room.Title + "\n" + "Периметр пола: " + room.BottomPerimeter.ToString("#.##") + "\n" + "Площадь потолка и пола: " + room.Area.ToString("#.##") + "\n" + "Периметр потолка: " + room.Perimeter.ToString("#.##") + "\n" + "Площадь стен: " + room.CommonArea.ToString("#.##") + "\n"; results[0] += room.BottomPerimeter; results[1] += room.Area; results[2] += room.Perimeter; results[3] += room.CommonArea; } RoomResT.Text += "==Общее==" + "\n" + "Периметр пола:" + results[0].ToString("#.##") + "\n" + "Площадь потолка и пола: " + results[1].ToString("#.##") + "\n" + "Периметр потолка: " + results[2].ToString("#.##") + "\n" + "Площадь стен:" + results[3].ToString("#.##"); SummT.Text = "========\n"; double commonsumm = 0; for (int i = 0; i < Rooms.Count; i++) { SummT.Text += Rooms[i].Title + "\nСумма:" + Rooms[i].Summ.ToString("#.##") + "\n"; commonsumm += Rooms[i].Summ; } SummT.Text += "========" + "\nОбщая сумма:" + commonsumm.ToString("#.##"); if (Convert.ToBoolean(ConfigWorksService.getValue(ConfigWorksService.Options.ReportRooms))) { double commonsum = 0; foreach (Room room in Rooms) { double sum = 0; finaltable.Rows.Add(new string[] { room.Title, "", "", "" }); finaltable.Rows.Add(new string[] { "Площадь стен", room.CommonArea.ToString("#.##"), "", "" }); finaltable.Rows.Add(new string[] { "Площадь пола", room.Area.ToString("#.##"), "", "" }); finaltable.Rows.Add(new string[] { "Периметр пола", room.BottomPerimeter.ToString("#.##"), "", "" }); foreach (WorkTypeClass work in room.CheckedWorks) { finaltable.Rows.Add(new string[] { work.Article, work.Quantity, reg.Match(work.Formula, 0).Value, work.Price }); sum += work.GetPrice(); } finaltable.Rows.Add(new string[] { "", "", "Сумма", sum.ToString("#.##") }); commonsum += sum; } finaltable.Rows.Add(new string[] { "", "", "Общая сумма", commonsum.ToString("#.##") }); foreach (DataGridViewRow row in finaltable.Rows) { row.ReadOnly = true; } finaltable.Rows[finaltable.RowCount - 1].ReadOnly = false; } else { //сумма для каждой работы Dictionary <WorkTypeClass, double> everyworksumm = new Dictionary <WorkTypeClass, double>(); //сумма параметров Dictionary <WorkTypeClass, double[]> paramssumm = new Dictionary <WorkTypeClass, double[]>(); double commonsum = 0; for (int i = 0; i < Rooms.Count; i++) { for (int j = 0; j < Rooms[i].CheckedWorks.Count; j++) { WorkTypeClass work = Rooms[i].CheckedWorks[j]; if (work.ParametersValue.Length == 0) { work.ParametersValue = new double[work.parametrs.Count]; } //проверяем содержит if (everyworksumm.FirstOrDefault(x => x.Key.Article == work.Article && x.Key.category == work.category).Key == null) { everyworksumm.Add(work, 0); paramssumm.Add(work, new double[work.ParametersValue.Length]); } if (work.ParametersValue.Length == 0) { work.ParametersValue = new double[work.parametrs.Count]; } for (int k = 0; k < Rooms[i].CheckedWorks[j].parametrs.Count; k++) { paramssumm.First(x => x.Key.Article == work.Article && x.Key.category == work.category).Value[k] += work.ParametersValue[k]; } everyworksumm[everyworksumm.First(x => x.Key.Article == work.Article && x.Key.category == work.category).Key] += work.GetPrice(); commonsum += work.GetPrice(); } } foreach (var pair in everyworksumm) { string quantity = ""; for (int i = 0; i < paramssumm[pair.Key].Length; i++) { quantity += paramssumm[pair.Key][i] + " " + pair.Key.parametrs[i] + "\n"; } finaltable.Rows.Add(new string[] { pair.Key.Article, quantity, reg.Match(pair.Key.Formula, 0).Value, pair.Value.ToString("#.##") }); finaltable.Rows[finaltable.RowCount - 2].ReadOnly = true; } DataGridViewRow row = new DataGridViewRow(); finaltable.Rows.Add(new string[] { "", "", "Сумма", commonsum.ToString("#.##") }); finaltable.Rows[finaltable.RowCount - 2].ReadOnly = false; } }