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();
        }
Esempio n. 2
0
        protected override EPV.DataItem.DataItem CreateNewDataItem()
        {
            PlanAppoint planAppoint = new PlanAppoint();

            planAppoint.Creator = Database.ConnectedUser;
            return(planAppoint);
        }
Esempio n. 3
0
        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));
     }
 }
Esempio n. 5
0
        private void EditCurrentAppoint(PlanAppoint appoint)
        {
            PlanAppointForm form = new PlanAppointForm(Database);

            form.PlanAppoint = appoint;
            form.ItemSaved  += new EventHandler(formItemSaved);
            form.Show();
        }
Esempio n. 6
0
        private void editCurrentTool_Click(object sender, EventArgs e)
        {
            PlanAppoint appoint = appointListTree.SelectedNode.Tag as PlanAppoint;

            if (appoint != null)
            {
                EditCurrentAppoint(appoint);
            }
        }
Esempio n. 7
0
        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();
        }
Esempio n. 9
0
 /// <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();
     }
 }
Esempio n. 10
0
 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();
     }
 }
Esempio n. 12
0
        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);
     }
 }
Esempio n. 14
0
 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;
         }
     }
 }
Esempio n. 15
0
 /// <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;
         }
     }
 }
Esempio n. 16
0
 /// <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, "Ошибка");
     }
 }
Esempio n. 17
0
        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);
            }
        }
Esempio n. 19
0
        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;
                }
            }
        }
Esempio n. 21
0
        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("");
         }
     }
 }
Esempio n. 23
0
        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();
                }
            }
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
 private void Delete(PlanAppoint appoint)
 {
     appoint.Delete();
     appoint.Save(Database);
 }
 private void RefreshPlanAppoints()
 {
     bsPlanAppoints.DataSource = PlanAppoint.LoadList(database);
 }
Esempio n. 30
0
 private void GetPlanAppointList()
 {
     bsList.DataSource = PlanAppoint.LoadList(Database, DateTime.Today.AddDays(-7));
 }