public Appoint(PlanAppoint plan) { if (plan.Vehicle.VehicleMark != null) { trackMark = plan.Vehicle.VehicleMark.ToString(); } else { trackMark = ""; } licensePlate = plan.Vehicle.LicensePlate; trailer = ""; driverName = plan.DriverName; driverPhone = plan.Contact; warrant = ""; whereTo = plan.WhereTo; cargo = plan.Cargo.ToString(); docStateDate = DateTime.Now; dateComing = DateTime.Now; point = null; dateToPoint = new DateTime(2100, 12, 31); unit = Unit.Empty; citizen = DispatcherService.State.Empty; docState = new EnumerationItem("docState", 0, "ожидает обработки"); PlanAppoint = plan; HasPermit = PlanAppoint.HasPermit; permitId = PlanAppoint.PermitId; Insert(); }
protected override EPV.DataItem.DataItem CreateNewDataItem() { PlanAppoint planAppoint = new PlanAppoint(); planAppoint.Creator = Database.ConnectedUser; return(planAppoint); }
private void DrawAppointNode(DrawTreeNodeEventArgs e) { PlanAppoint appoint = (PlanAppoint)e.Node.Tag; Font font = appointListTree.Font; if (appoint.IsUpdated) { font = new Font(font, FontStyle.Bold); } e.Node.NodeFont = font; Brush foreBrush = new SolidBrush(e.Node.ForeColor), backBrush = new SolidBrush(appointListTree.BackColor); if ((e.State & TreeNodeStates.Selected) > 0) { e.Graphics.FillRectangle(foreBrush, NodeBounds(e.Node)); e.Graphics.DrawString(appoint.ToString(), font, backBrush, NodeBounds(e.Node)); } else { e.Graphics.DrawString(appoint.ToString(), font, foreBrush, NodeBounds(e.Node)); } }
private void OnItemSelected(PlanAppoint appoint) { if (onItemSelected != null) { onItemSelected(this, new ItemEventArgs(appoint)); } }
private void EditCurrentAppoint(PlanAppoint appoint) { PlanAppointForm form = new PlanAppointForm(Database); form.PlanAppoint = appoint; form.ItemSaved += new EventHandler(formItemSaved); form.Show(); }
private void editCurrentTool_Click(object sender, EventArgs e) { PlanAppoint appoint = appointListTree.SelectedNode.Tag as PlanAppoint; if (appoint != null) { EditCurrentAppoint(appoint); } }
private void ShowPlanAppointControl(PlanAppoint planAppoint) { PlanAppointViewControl control = new PlanAppointViewControl(Database); control.PlanAppoint = planAppoint; control.ItemSeen += new EventHandler(planAppointItemSeen); splitContainer1.Panel2.Controls.Add(control); control.Dock = DockStyle.Fill; }
public PlanAppointControl(EPVDatabase database, PlanAppoint planAppoint) : this() { Database = database; PreloadData(); planAppoint.PropertyChanged += planAppointPropertyChanged; PlanAppoint = planAppoint; AddBindings(); }
/// <summary> /// формирует отказ в удовлетворении заявки /// </summary> /// <param name="planAppoint"></param> private void LockPlanAppoint(PlanAppoint planAppoint) { if (MessageBox.Show("Отказать в проезде транспорта на территорию?", planAppoint.ToString(), MessageBoxButtons.YesNo) == DialogResult.Yes) { string query = EntryControl.Resources.Doc.PlanAppoint.SetPermitLocked; QueryParameters parameters = new QueryParameters("planAppoint", planAppoint.Id); Database.ExecuteQuery(query, parameters); ForceRefreshData(); } }
private void SelectNode(TreeNode parentNode, PlanAppoint appoint) { foreach (TreeNode node in parentNode.Nodes) { PlanAppoint nodeAppoint = (PlanAppoint)node.Tag; if (nodeAppoint.Equals(appoint)) { appointListTree.SelectedNode = node; break; } } }
private void CloseCurrentPlan() { if (bsPlanAppoints.Current != null && MessageBox.Show("Отменить указанный план", ((PlanAppoint)bsPlanAppoints.Current).ToString(), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { PlanAppoint planAppoint = (PlanAppoint)bsPlanAppoints.Current; planAppoint.Close(); planAppoint.Save(database); RefreshData(); } }
private void bgRefreshPlanAppointList_DoWork(object sender, DoWorkEventArgs e) { RefreshParams args = (RefreshParams)e.Argument; Database database = args.database; RefreshResult result = new RefreshResult(); result.totalPages = PlanAppoint.GetNumberWOPermit(database, args.dateStart); result.List = PlanAppoint.LoadWoPermit(database, args.dateStart, args.pageNumber); e.Result = result; }
private void DeleteCurrentPlan() { if (bsList.Current != null && ((PlanAppoint)bsList.Current).DateAppoint.Equals(DateTime.MaxValue) && MessageBox.Show("Удалить текущий план?", "Внимание", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { PlanAppoint plan = (PlanAppoint)bsList.Current; bsList.Remove(plan); plan.Delete(); plan.Save(database); } }
private void SelectNode(PlanAppoint appoint) { SelectNode(appoint.DateFrom); appointListTree.SelectedNode.Expand(); foreach (TreeNode node in appointListTree.SelectedNode.Nodes) { if (appoint.Equals((PlanAppoint)node.Tag)) { appointListTree.SelectedNode = node; break; } } }
/// <summary> /// перед отрисовкой списка заявок - раскрашивает заявки с отказом /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPlanAppointList_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { if (e.RowIndex >= 0) { PlanAppoint appoint = (PlanAppoint)bsPlanAppointList[e.RowIndex]; if (appoint.IsLocked) { dgvPlanAppointList.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red; dgvPlanAppointList.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.Red; } } }
/// <summary> /// создает пропуск на основе заявки /// </summary> /// <param name="planAppoint">Заявка на пропуск</param> private void CreatePermitForPlanAppoint(PlanAppoint planAppoint) { try { PermitItemForm form = new PermitItemForm(Database); form.PlanAppoint = planAppoint; form.ItemSaved += new EventHandler(form_ItemSaved); form.Show(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Ошибка"); } }
private void deleteCurrentTool_Click(object sender, EventArgs e) { string message = EntryControl.Resources.Message.Question.Delete; if (SelectedPlanAppoint != null && MessageBox.Show(message, SelectedPlanAppoint.ToString(), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { PlanAppoint appoint = SelectedPlanAppoint; Delete(SelectedPlanAppoint); } ForceRefreshData(); }
private void RefreshList(object sender, EventArgs e) { try { BindingList <PlanAppoint> list = PlanAppoint.LoadList(database, pickPlan.Value); bsList.DataSource = list; if (sender is PlanAppoint) { bsList.Position = list.IndexOf((PlanAppoint)sender); } } catch (Exception exc) { MessageBox.Show(exc.Message); } }
void formItemSaved(object sender, EventArgs e) { PlanAppoint appoint = (PlanAppoint)sender; ForceRefreshData(); foreach (TreeNode parentNode in appointListTree.Nodes) { KeyValuePair <DateTime, List <PlanAppoint> > pair = (KeyValuePair <DateTime, List <PlanAppoint> >)parentNode.Tag; DateTime date = pair.Key; if (date == appoint.DateFrom) { parentNode.Expand(); SelectNode(parentNode, appoint); break; } } }
private void dgvList_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { if (e.RowIndex >= 0) { PlanAppoint planAppoint = (PlanAppoint)bsList[e.RowIndex]; if (!planAppoint.DateAppoint.Equals(DateTime.MaxValue)) { dgvList.Rows[e.RowIndex].DefaultCellStyle.ForeColor = SystemColors.GrayText; dgvList.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = SystemColors.GrayText; } if (planAppoint.IsClosed) { dgvList.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red; dgvList.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.LightSalmon; } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { StopTimer(); PlanAppoint planAppoint = e.Node.Tag as PlanAppoint; if (planAppoint != null) { ShowPlanAppointControl(planAppoint); editCurrentTool.Enabled = !planAppoint.HasPermit; deleteCurrentTool.Enabled = !planAppoint.HasPermit; } else { editCurrentTool.Enabled = false; deleteCurrentTool.Enabled = false; } }
private void bsPlanAppoint_CurrentChanged(object sender, EventArgs e) { createPermitTool.Enabled = (bsPlanAppoint.Current != null); if (panelPlanAppoints.Visible) { if (bsPlanAppoint.Current != null) { PlanAppoint appoint = (PlanAppoint)bsPlanAppoint.Current; ShowComment(appoint.GetComment(Database)); ShowCreator(appoint.CreationInfo); } else { ShowComment(""); ShowCreator(""); } } }
private void AddBindings() { if (PlanAppoint.IsUpdated) { timer.Start(); } lblCargo.Text = PlanAppoint.Cargo.ToString(); lblVehicleMark.Text = PlanAppoint.Vehicle.ToString(); lblDriver.Text = PlanAppoint.DriverName + " (" + PlanAppoint.Contact + ")"; lblCreation.Text = PlanAppoint.CreationInfo; PlanAppoint.GetComment(Database); tboxComment.DataBindings.Add("Text", bsItem, "Comment"); if (PlanAppoint.HasPermit) { Permit permit = PlanAppoint.LoadPermit(Database); lblPermit.Text = permit.ToString(); switch (permit.PermitState.Id) { case 4: lblPermit.Text += " (закрыт)"; break; case 3: lblPermit.Text += " (заблокирован)"; break; case 2: lblPermit.Text += " (постоянный)"; break; } lboxPermitMoving.DataSource = permit.GetMovingList(Database); lboxPointList.DataSource = permit.GetAllowedPointList(Database); } else { lblPermit.Text = "не выдан"; } }
private bool SavePlanAppoint() { try { if (CheckRequiredProperties()) { PlanAppoint.Save(Database, ((FormStart)FindForm().MdiParent).User); return(true); } else { return(false); } } catch (Exception exc) { MessageBox.Show("Ошибка сохранения объекта: " + exc.Message, "Ошибка сохранения"); return(false); } }
private void FillLastAppointData() { PlanAppoint lastPlanAppoint = PlanAppoint.Vehicle.GetLastPlanAppoint(Database); if (lastPlanAppoint != null) { PlanAppoint.Cargo = lastPlanAppoint.Cargo; rboxCargo.Refresh(); PlanAppoint.DriverName = lastPlanAppoint.DriverName; PlanAppoint.Contact = lastPlanAppoint.Contact; PlanAppoint.WhereTo = lastPlanAppoint.WhereTo; string query = DispatcherService.Resources.Doc.PlanAppoint.GetTrailer; QueryParameters parameters = new QueryParameters("id", lastPlanAppoint.Id); using (DbDataReader reader = Database.ExecuteReader(query, parameters)) { if (reader.Read()) { if (!DBNull.Value.Equals(reader["trailer"])) { tboxTrailer.Text = (string)reader["trailer"]; } if (!DBNull.Value.Equals(reader["state"])) { cboxCountry.SelectedItem = ((States)cboxCountry.DataSource).Find((int)reader["state"]); } if (!DBNull.Value.Equals(reader["idUnit"])) { cboxUnit.SelectedItem = ((Units)cboxUnit.DataSource).Find((int)reader["idUnit"]); } } reader.Close(); } } }
private TreeNode CreateNode(PlanAppoint appoint) { TreeNode node = new TreeNode(""); node.Tag = appoint; if (appoint.IsUpdated) { node.NodeFont = new Font(appointListTree.Font, FontStyle.Bold); } node.ForeColor = appointListTree.ForeColor; node.ImageKey = "Empty"; if (appoint.HasPermit) { node.ForeColor = Color.Green; node.ImageKey = "Check"; } if (appoint.PermitIsClosed) { node.ForeColor = SystemColors.GrayText; node.ImageKey = "Closed"; } if (appoint.IsLocked || appoint.PermitState == 3) { node.ForeColor = Color.Red; node.ImageKey = "Lock"; } node.Text = appoint.ToString(); return(node); }
private void bgRefreshAppointList_DoWork(object sender, DoWorkEventArgs e) { LoadParameters parameters = (LoadParameters)e.Argument; Database database = parameters.Database; DateTime DateStart = parameters.DateStart; string searchingText = parameters.SearchingText; List <PlanAppoint> planAppointList = PlanAppoint.LoadListForTree(database, DateStart); List <PlanAppoint> resultList = planAppointList; if (searchingText.Length > 0) { resultList = new List <PlanAppoint>(); foreach (PlanAppoint planAppoint in planAppointList) { if (planAppoint.ToString().ToLower().Contains(searchingText.ToLower())) { resultList.Add(planAppoint); } } } e.Result = CreateDictionary(resultList); }
private void Delete(PlanAppoint appoint) { appoint.Delete(); appoint.Save(Database); }
private void RefreshPlanAppoints() { bsPlanAppoints.DataSource = PlanAppoint.LoadList(database); }
private void GetPlanAppointList() { bsList.DataSource = PlanAppoint.LoadList(Database, DateTime.Today.AddDays(-7)); }