/// <summary>
 /// The open workstation.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 public void OpenWorkstation(WorkstationGridRow row)
 {
     if (EnabledGrid != null)
     {
         EnabledGrid(false);
     }
     SetWorkstationDetailCaption("Редактирование рабочего места");
     SetWorkstationViewStateValues(row.Id, row.IsNew);
     AssignControlValuesFromWorkstation(row);
     SetEnableControls(true);
     tbName.Focus();
 }
        /// <summary>
        /// The delete workstation.
        /// </summary>
        /// <param name="row">
        ///   The row.
        /// </param>
        /// <param name="gridView">
        ///   The grid view.
        /// </param>
        /// <param name="currentPdpId">
        ///   The current pdp id.
        /// </param>
        public void DeleteWorkstation(WorkstationGridRow row, GridView gridView, Guid?currentPdpId)
        {
            if (currentPdpId == null)
            {
                return;
            }

            var dict = (Dictionary <Guid, IList <WorkstationGridRow> >)Session[SessionConsts.CWorkstationDict];
            var list = dict[(Guid)currentPdpId];

            list.Remove(row);
            Session[SessionConsts.CWorkstationDict] = dict;
            gridView.SelectedIndex = -1;
            gridView.DataSource    = list;
            gridView.DataBind();
            ClearControlValues();
        }
 /// <summary>
 /// The assign control values from workstation.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 public void AssignControlValuesFromWorkstation(WorkstationGridRow row)
 {
     tbName.Text         = row.Name;
     readerName.Value    = row.UecReaderName;
     readerSmcName.Value = row.SmardCardReaderName;
     //comboReaderName.Text = row.UecReaderName;
     if (row.UecCerticateType == null || row.UecCerticateType == (int)CryptographyType.GOST)
     {
         rblCrypto.SelectedValue = "GOST";
     }
     else
     {
         rblCrypto.SelectedValue = "RSA";
     }
     uTerminalGOST.LoadedEarlierText        = UtilsHelper.GetLoadedSertificateText(TypeSertificate.TerminalGOST, row.SertificateUecs);
     uTerminalRSA.LoadedEarlierText         = UtilsHelper.GetLoadedSertificateText(TypeSertificate.TerminalRSA, row.SertificateUecs);
     uPrivateTerminalGOST.LoadedEarlierText = UtilsHelper.GetLoadedSertificateText(TypeSertificate.PrivateTerminalGOST, row.SertificateUecs);
 }
        // сохранение рабочего места
        /// <summary>
        /// The btn save_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ViewState["workstationId"] == null)
            {
                return;
            }

            if (!ValidateWorkstation())
            {
                return;
            }

            var addNew = (bool)ViewState["workstationIsNew"];
            var w      = new Workstation();

            if (!addNew)
            {
                // нам нужен объект который не будет привязан к сессии, так как при endrequest session.Flush() в Global.asax изменения попадают в базу
                // все остальные поля присвоятся в AssignWorkstationValuesFromControls
                w.Id = (Guid)ViewState["workstationId"];
            }

            var currentPdpId = (Guid)Session[SessionConsts.CPdpId];

            AssignWorkstationValuesFromControls(w, addNew, currentPdpId);

            var dict = (Dictionary <Guid, IList <WorkstationGridRow> >)Session[SessionConsts.CWorkstationDict];
            IList <WorkstationGridRow> list;

            if (!dict.ContainsKey(currentPdpId))
            {
                list = new List <WorkstationGridRow>();
                dict.Add(currentPdpId, list);
            }
            else
            {
                list = dict[currentPdpId];
            }

            // добавляем новый элемент
            if (addNew && (Guid)ViewState["workstationId"] == Guid.Empty)
            {
                var addedRow = new WorkstationGridRow(w);
                addedRow.IsNew = true;
                list.Add(addedRow);
            }
            else
            {
                var editedRow = list.FirstOrDefault(r => r.Id == (Guid)ViewState["workstationId"]);
                editedRow.AssignFrom(w);
            }

            dict[currentPdpId] = list;

            Session[SessionConsts.CWorkstationDict] = dict;

            if (BindParentList != null)
            {
                BindParentList(list);
            }

            // если было добавление то очищаем контролы
            if (addNew)
            {
                ClearControlValues();
            }

            SetEnableControls(false);
            ClearSessionValues();
            SetWorkstationViewStateValues(null, null);
            if (EnabledGrid != null)
            {
                EnabledGrid(true);
            }
        }