Пример #1
0
        public override void EditObject()
        {
            DataGridViewRow dgvRow = base.getSelectedDataRow();

            if (dgvRow != null)
            {
                int          editId = (int)dgvRow.Cells["Id"].Value;
                NoteTemplate note   = new NoteTemplate(editId);

                NoteTemplateForm frm    = new NoteTemplateForm(note);
                DialogResult     result = frm.ShowDialog();
                AppFuncs.dialogCloseResult(frm.GetType().Name, result);
                if (result == DialogResult.OK)
                {
                    bool dbResult = DBContext.UpdateEntity(note);
                    if (dbResult)
                    {
                        this.LoadDataToGrid();
                        base.selectGridRowById(editId);
                        MessageBox.Show("Шаблон службової оновлен", "Оновлення шаблону службової", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    AppFuncs.saveToDBResult(dbResult);
                }
                base.EditObject();
            }
        }
Пример #2
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="noteTemplateId">The care worker identifier</param>
        public void ShowDetail(int noteTemplateId)
        {
            NoteTemplate        noteTemplate        = null;
            var                 rockContext         = new RockContext();
            NoteTemplateService noteTemplateService = new NoteTemplateService(rockContext);

            if (!noteTemplateId.Equals(0))
            {
                noteTemplate = noteTemplateService.Get(noteTemplateId);
                pdAuditDetails.SetEntity(noteTemplate, ResolveRockUrl("~"));
            }

            if (noteTemplate == null)
            {
                noteTemplate = new NoteTemplate {
                    Id = 0
                };
                pdAuditDetails.Visible = false;
                cbActive.Checked       = true;
            }
            else
            {
                cbActive.Checked = noteTemplate.IsActive;
            }

            tbIcon.Text = noteTemplate.Icon;
            tbNote.Text = noteTemplate.Note;

            noteTemplate.LoadAttributes();
            Helper.AddEditControls(noteTemplate, phAttributes, true, BlockValidationGroup, 2);

            hfNoteTemplateId.Value = noteTemplate.Id.ToString();
        }
Пример #3
0
 void mrsClient_AdditionalNotesTemplateAndProductsByRegionCompleted(object sender, GetAdditionalNotesTemplateAndProductsByRegionCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         RadWindow.Alert(e.Error.Message);
     }
     else
     {
         if (e.Result.Count > 0 && e.Result[0].ProductAreaGroupID == -1)
         {
             RadWindow.Alert(e.Result[0].ProductDescription.ToString());
         }
         else
         {
             ManagerNotesTemplate.Clear();
             foreach (var item in e.Result)
             {
                 bool exists = false;
                 foreach (var header in ManagerNotesTemplate)
                 {
                     if (header.TemplateID.ToString() == item.TemplateID)
                     {
                         exists = true;
                         if (!header.NoteTemplateItem.Contains(item) && item.ProductAreaGroupID > 0)
                         {
                             header.NoteTemplateItem.Add(item);
                         }
                         break;
                     }
                 }
                 if (!exists)
                 {
                     NoteTemplate note = new NoteTemplate();
                     note.RegionName   = item.RegionName;
                     note.TemplateID   = int.Parse(item.TemplateID);
                     note.TemplateName = item.TemplateName;
                     note.Active       = item.TemplateActive;
                     note.OwnerName    = item.OwnerName;
                     if ((App.Current as App).CurrentUserRoleId == 6)// if estimate manager, it's open
                     {
                         note.IsReadOnly = false;
                     }
                     else
                     {
                         note.IsReadOnly = (App.Current as App).CurrentUserFullName == item.OwnerName ? false : true;
                     }
                     note.IsEnabled = !note.IsReadOnly;
                     note.IsPrivate = item.IsPrivate;
                     if (item.ProductAreaGroupID > 0)
                     {
                         note.NoteTemplateItem.Add(item);
                     }
                     ManagerNotesTemplate.Add(note);
                 }
             }
         }
     }
 }
Пример #4
0
        public void RemoveNoteTemplate(NoteTemplate template)
        {
            mrsClient = new RetailSystemClient();
            mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl());

            mrsClient.RemoveNotesTemplateCompleted += new EventHandler <RemoveNotesTemplateCompletedEventArgs>(mrsClient_RemoveNotesTemplateCompleted);
            mrsClient.RemoveNotesTemplateAsync(template.TemplateID.ToString(), userid);
            mrsClient = null;
        }
Пример #5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            AppFuncs.WriteLogTraceMessage("   - press button 'Зберегти'");

            if (isValidInput())
            {
                if (_isNew || isUpdate())
                {
                    if (_currentTemplate == null)
                    {
                        _currentTemplate = new NoteTemplate();
                    }

                    _currentTemplate.Name     = tbxTplName.Text;
                    _currentTemplate.Help     = tbxHelp.Text;
                    _currentTemplate.HeadDir  = tbxHeadDir.Text;
                    _currentTemplate.HeadNach = tbxTableColums.Text;
                    _currentTemplate.BodyUp   = tbxBodyUp.Text;
                    _currentTemplate.BodyDown = tbxBodyDown.Text;

                    _currentTemplate.TableColums  = tbxTableColums.Text.ToInt();
                    _currentTemplate.ColumName1   = tbxColumnName1.Text;
                    _currentTemplate.ColumName2   = tbxColumnName2.Text;
                    _currentTemplate.ColumName3   = tbxColumnName3.Text;
                    _currentTemplate.ColumName4   = tbxColumnName4.Text;
                    _currentTemplate.ColumName5   = tbxColumnName5.Text;
                    _currentTemplate.ColumName6   = tbxColumnName6.Text;
                    _currentTemplate.ColumName7   = tbxColumnName7.Text;
                    _currentTemplate.ColumName8   = tbxColumnName8.Text;
                    _currentTemplate.ColumName9   = tbxColumnName9.Text;
                    _currentTemplate.ColumName10  = tbxColumnName10.Text;
                    _currentTemplate.ApprASU      = cbxApprASU.Checked;
                    _currentTemplate.ApprBuh      = cbxApprBuh.Checked;
                    _currentTemplate.ApprComdir   = cbxApprComdir.Checked;
                    _currentTemplate.ApprDir      = cbxApprDir.Checked;
                    _currentTemplate.ApprDostavka = cbxApprDostavka.Checked;
                    _currentTemplate.ApprEnerg    = cbxApprEnerg.Checked;
                    _currentTemplate.ApprFin      = cbxApprFin.Checked;
                    _currentTemplate.ApprKasa     = cbxApprKasa.Checked;
                    _currentTemplate.ApprNach     = cbxApprNach.Checked;
                    _currentTemplate.ApprSB       = cbxApprSB.Checked;
                    _currentTemplate.ApprSBNach   = cbxApprSBNach.Checked;
                    _currentTemplate.ApprSklad    = cbxApprSklad.Checked;

                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                }
            }
            else
            {
                _currentTemplate = null;
            }
        }
Пример #6
0
 public NoteTemplateViewModel(string id, string text, string dockColor, NotesStackPanelViewModel notesStack)
 {
     this.id = id;
     if (!string.IsNullOrEmpty(text))
     {
         NoteText = text;
     }
     this.notesStack = notesStack;
     this.dockColor  = dockColor;
     noteTemplate    = new NoteTemplate(this);
 }
Пример #7
0
        /// <summary>
        /// Handles the Delete event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gList_Delete(object sender, RowEventArgs e)
        {
            var rockContext                  = new RockContext();
            NoteTemplateService service      = new NoteTemplateService(rockContext);
            NoteTemplate        noteTemplate = service.Get(e.RowKeyId);

            if (noteTemplate != null)
            {
                service.Delete(noteTemplate);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #8
0
        public NoteTemplateForm(NoteTemplate pTemplate)
        {
            _isNew = (pTemplate == null);
            AppFuncs.openEditForm(this.GetType().Name, _isNew);

            InitializeComponent();

            // подписаться на события фокуса
            //FormsHelper.SetFocusEventHandlers(this, Color.Yellow, Color.White);
            if (_isNew)
            {
                this.Text = "Створення нового шаблону службової записки";
            }
            else
            {
                this.Text        = "Редагування існуючого шаблону";
                _currentTemplate = pTemplate;
                #region заполнение полей
                tbxTplName.Text         = _currentTemplate.Name;
                tbxHelp.Text            = _currentTemplate.Help;
                tbxHeadDir.Text         = _currentTemplate.HeadDir;
                tbxBodyUp.Text          = _currentTemplate.BodyUp;
                tbxHeadNach.Text        = _currentTemplate.HeadNach;
                tbxTableColums.Text     = _currentTemplate.TableColums.ToString();
                tbxColumnName1.Text     = _currentTemplate.ColumName1;
                tbxColumnName2.Text     = _currentTemplate.ColumName2;
                tbxColumnName3.Text     = _currentTemplate.ColumName3;
                tbxColumnName4.Text     = _currentTemplate.ColumName4;
                tbxColumnName5.Text     = _currentTemplate.ColumName5;
                tbxColumnName6.Text     = _currentTemplate.ColumName6;
                tbxColumnName7.Text     = _currentTemplate.ColumName7;
                tbxColumnName8.Text     = _currentTemplate.ColumName8;
                tbxColumnName9.Text     = _currentTemplate.ColumName9;
                tbxColumnName10.Text    = _currentTemplate.ColumName10;
                tbxBodyDown.Text        = _currentTemplate.BodyDown;
                cbxApprASU.Checked      = _currentTemplate.ApprASU;
                cbxApprBuh.Checked      = _currentTemplate.ApprBuh;
                cbxApprComdir.Checked   = _currentTemplate.ApprComdir;
                cbxApprDir.Checked      = _currentTemplate.ApprDir;
                cbxApprDostavka.Checked = _currentTemplate.ApprDostavka;
                cbxApprEnerg.Checked    = _currentTemplate.ApprEnerg;
                cbxApprFin.Checked      = _currentTemplate.ApprFin;
                cbxApprKasa.Checked     = _currentTemplate.ApprKasa;
                cbxApprNach.Checked     = _currentTemplate.ApprNach;
                cbxApprSB.Checked       = _currentTemplate.ApprSB;
                cbxApprSBNach.Checked   = _currentTemplate.ApprSBNach;
                cbxApprSklad.Checked    = _currentTemplate.ApprSklad;
                #endregion
            }
        }
Пример #9
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            TableRow row = new TableRow();

            TableCell cell = new TableCell();

            cell.ApplyStyle(this.NoteStyle);
            NoteTemplate.InstantiateIn(cell);
            row.Cells.Add(cell);
            _tbl.Rows.Add(row);

            _tbl.ID = this.ClientID + "_NoteContainerRow";
        }
Пример #10
0
 /// <summary>
 /// Handles the RowDataBound event of the gList control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param>
 public void gList_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         NoteTemplate noteTemplate = e.Row.DataItem as NoteTemplate;
         if (noteTemplate != null)
         {
             Literal lIcon = e.Row.FindControl("lIcon") as Literal;
             if (lIcon != null)
             {
                 lIcon.Text = string.Format("<i class=\"{0}\"></i>", noteTemplate.Icon);
             }
         }
     }
 }
Пример #11
0
        private void ShowPreview()
        {
            documentViewer.Visibility = Visibility.Collapsed;

            FlowDocument doc = null;

            switch (_args.DocumentType)
            {
            case EditType.Appointment:
                doc = new AppointmentTemplate((Appointment)_args.DatabaseObject).GetFlowDocument();
                break;

            case EditType.Contact:
                doc = new ContactTemplate((Contact)_args.DatabaseObject).GetFlowDocument();
                break;

            case EditType.Note:
                doc = new NoteTemplate((NotebookPage)_args.DatabaseObject).GetFlowDocument();
                break;

            case EditType.Task:
                doc = new TaskTemplate((UserTask)_args.DatabaseObject).GetFlowDocument();
                break;

            default:
                break;
            }

            FlowDocument copy = doc.Copy();

            Size size = ((PaperSize)((FrameworkElement)paperSizeCombo.SelectedItem).Tag).Size;

            if ((size.Width < size.Height && orientationCombo.SelectedIndex == 1) ||
                (size.Width > size.Height && orientationCombo.SelectedIndex == 0))
            {
                size = new Size(size.Height, size.Width);
            }

            documentViewer.Document = FlowPaginator.ConvertFrom(
                copy, size,
                ((PageMargin)((FrameworkElement)marginCombo.SelectedItem).Tag).Margin
                );

            documentViewer.Visibility = Visibility.Visible;
            documentViewer.FadeIn(AnimationHelpers.AnimationDuration);

            documentViewer.FitToWidth();
        }
Пример #12
0
        private void cbNoteTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            dtpDateCreate.Value        = DateTime.Now;
            cbDepartment.SelectedValue = Program.User.Department;

            _note.Templates = cbNoteTemplate.SelectedValue.ToInt();
            _note.Approvers = null;
            _template       = new NoteTemplate(_note.Templates);

            this.tbHeadDir.Text  = _template.HeadDir;
            this.tbHeadNach.Text = _template.HeadNach + Program.User.HeadNach;
            this.tbBodyUp.Text   = _template.BodyUp;
            this.tbBodyDown.Text = _template.BodyDown;
            this.tbAvtor.Text    = Program.User.Name;

            setControlForTemplate();
        }
Пример #13
0
        private static void SaveNote(Window owner, StatusStrip statusStrip, NotebookPage page, string filename)
        {
            try
            {
                switch (Path.GetExtension(filename).ToLower())
                {
                case ".rtf":
                    FlowDocument doc     = new NoteTemplate(page).GetFlowDocument();
                    TextRange    range   = new TextRange(doc.ContentStart, doc.ContentEnd);
                    FileStream   fStream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
                    range.Save(fStream, DataFormats.Rtf);
                    fStream.Close();

                    statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL");
                    break;

                case ".txt":
                    string[] filecontents = new NoteTemplate(page).GetTextDocument();
                    File.WriteAllLines(filename, filecontents);

                    statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL");
                    break;

                default:
                    statusStrip.UpdateMainStatus("ERROR: REQUESTED FILE TYPE UNAVAILABLE");

                    TaskDialog dialog = new TaskDialog(owner,
                                                       "Error Saving File", "The requested file type is not available.",
                                                       MessageType.Error);
                    dialog.ShowDialog();
                    break;
                }
            }
            catch (Exception exc)
            {
                statusStrip.UpdateMainStatus("ERROR: " + exc.Message.ToUpper());

                TaskDialog dialog = new TaskDialog(owner,
                                                   "Error Saving File", exc.Message, MessageType.Error);
                dialog.ShowDialog();

                ExportNote(owner, statusStrip, page, Path.GetDirectoryName(saveDialog.SelectedFile));
            }
        }
Пример #14
0
        // настройка контролов для редактирования
        private void setControlsForEdit()
        {
            this.Text = "Редагувати рядок";

            // установить значения контролов
            cbNoteTemplate.SelectedValue = _note.Templates;
            cbDepartment.SelectedValue   = _note.IdDepartment;
            dtpDateCreate.Value          = _note.Date;
            this.tbHeadDir.Text          = _note.HeadDir;
            this.tbHeadNach.Text         = _note.HeadNach;
            this.tbNumber.Text           = _note.Id.ToString();
            this.tbBodyUp.Text           = _note.BodyUp;
            this.tbBodyDown.Text         = _note.BodyDown;
            this.tbAvtor.Text            = _note.NameAvtor;

            // закрыть для доступа все TextBox/ComboBox контролы
            bool isEnable = (Program.User.ApprAvtor && (Program.User.Department == _note.IdDepartment));

            // если это автор, проверить, утвердил ли он служебку
            if (isEnable)
            {
                isEnable = !_note.ApprAvtor;
            }
            foreach (Control ctl in this.Controls)
            {
                if ((ctl is TextBox) && (ctl is ComboBox))
                {
                    ctl.Enabled = isEnable;
                }
            }
            // текст служебки
            setBodyControlsEnable(isEnable);

            // группа кнопок согласователей
            this.grpApprove.Enabled = true;

            _template = _note.Template;
            setControlForTemplate();
        }
        /// <summary>
        /// Checkin two NoteTemplate objects used in this example.
        /// </summary>
        /// <param name="ix">IX connection object</param>
        /// <returns>IDs of NoteTemplate objects</returns>
        private int[] InternalCreateNoteTemplates(IXConnection ix)
        {
            // Try to find the note templates in the archive database
            try
            {
                NoteTemplate[] existingNoteTemplates = ix.Ix.checkoutNoteTemplates(ix.UserId.ToString(),
                                                                                   new string[] { "Text Template ACCEPTED", "Image Template Stempel1.jpg" }, NoteTemplateC.mbMin, LockC.NO);
                return(new int[] { existingNoteTemplates[0].id, existingNoteTemplates[1].id });
            }
            catch (Exception) { }

            List <NoteTemplate> noteTemplates = new List <NoteTemplate>();

            // Create a NoteTemplate with text "ACCEPTED"
            {
                NoteTemplate noteTemplate = ix.Ix.createNoteTemplate(ix.UserId.ToString());
                noteTemplate.name                        = "Text Template ACCEPTED";
                noteTemplate.noteText                    = new NoteText();
                noteTemplate.noteText.text               = "ACCEPTED";
                noteTemplate.noteText.fontInfo           = new FontInfo();
                noteTemplate.noteText.fontInfo.underline = true;
                noteTemplate.noteText.fontInfo.height    = 30;
                noteTemplates.Add(noteTemplate);
            }

            // Create a NoteTemplate with an image
            {
                NoteTemplate noteTemplate = ix.Ix.createNoteTemplate(ix.UserId.ToString());
                noteTemplate.name                           = "Image Template Stempel1.jpg";
                noteTemplate.noteImage                      = new NoteImage();
                noteTemplate.noteImage.fileName             = "Stempel1.jpg";
                noteTemplate.noteImage.fileData             = new FileData();
                noteTemplate.noteImage.fileData.contentType = "image/jpeg";
                noteTemplate.noteImage.fileData.data        = System.IO.File.ReadAllBytes(@"..\..\Stempel1.jpg");
                noteTemplates.Add(noteTemplate);
            }

            return(ix.Ix.checkinNoteTemplates(noteTemplates.ToArray(), NoteTemplateC.mbAll, LockC.NO));
        }
Пример #16
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                BindAttributes();
                AddDynamicControls();
                BindGrid();
            }
            else
            {
                var          rockContext = new RockContext();
                NoteTemplate item        = new NoteTemplateService(rockContext).Get(hfNoteTemplateId.ValueAsInt());
                if (item == null)
                {
                    item = new NoteTemplate();
                }
                item.LoadAttributes();

                phAttributes.Controls.Clear();
                Helper.AddEditControls(item, phAttributes, false, BlockValidationGroup, 2);
            }
        }
Пример #17
0
 internal void RemoveNote(NoteTemplate noteTemplate)
 {
     notesStackPanel.NotesList.Children.Remove(noteTemplate);
 }
Пример #18
0
 public NoteTemplateViewModel()
 {
     noteTemplate = new NoteTemplate(this);
 }
Пример #19
0
        /// <summary>
        /// Adds the New Worker
        /// </summary>
        private bool AddNote(int noteTemplateId)
        {
            if (Page.IsValid)
            {
                RockContext         rockContext         = new RockContext();
                NoteTemplateService noteTemplateService = new NoteTemplateService(rockContext);

                NoteTemplate noteTemplate = null;

                if (!noteTemplateId.Equals(0))
                {
                    noteTemplate = noteTemplateService.Get(noteTemplateId);
                }

                if (noteTemplate == null)
                {
                    noteTemplate = new NoteTemplate {
                        Id = 0
                    };
                }

                noteTemplate.Icon = tbIcon.Text;

                noteTemplate.Note = tbNote.Text;

                noteTemplate.IsActive = cbActive.Checked;

                NoteTemplate lastNoteTemplate = noteTemplateService.Queryable().OrderByDescending(b => b.Order).FirstOrDefault();

                if (lastNoteTemplate != null)
                {
                    noteTemplate.Order = lastNoteTemplate.Order + 1;
                }
                else
                {
                    noteTemplate.Order = 0;
                }

                if (noteTemplate.IsValid)
                {
                    if (noteTemplate.Id.Equals(0))
                    {
                        noteTemplateService.Add(noteTemplate);
                    }

                    // get attributes
                    noteTemplate.LoadAttributes();
                    Helper.GetEditValues(phAttributes, noteTemplate);

                    rockContext.WrapTransaction(() =>
                    {
                        rockContext.SaveChanges();
                        noteTemplate.SaveAttributeValues(rockContext);
                    });

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }