Exemplo n.º 1
0
        private void FillAliasGrid()
        {
            try
            {
                AliasDataTable = new DataTable();
                DataSet CredentialsDataSet = new DataSet();
                AliasDataTable = VSWebBL.ConfiguratorBL.CredentialsBL.Ins.GetAllData();
                //if (AliasDataTable.Rows.Count > 0)
                //{
                DataTable dtcopy = AliasDataTable.Copy();
                dtcopy.PrimaryKey = new DataColumn[] { dtcopy.Columns["ID"] };

                Session["Alias"]         = dtcopy;
                AliasGridView.DataSource = AliasDataTable;
                AliasGridView.DataBind();
                //}
                //else
                //{
                //    AliasGridView.DataSource = AliasDataTable;
                //    AliasGridView.DataBind();
                //}
            }
            catch (Exception ex)
            {
                //6/27/2014 NS added for VSPLUS-634
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
            finally { }
        }
        protected void ButtonAdd_Attribute(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(NameColumn.Text))
            {
                throw new InvalidOperationException("Поле «Псевдоним» не может содержать пустую строку.");
            }

            if (string.IsNullOrWhiteSpace(NameAttribute.Text))
            {
                throw new InvalidOperationException("Поле «Код» не может содержать пустую строку.");
            }

            List <char> num = new List <char>()
            {
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
            };

            if (num.Contains(NameAttribute.Text[0]))
            {
                throw new InvalidOperationException("«Код» не может начинатсья с цифры.");
            }

            var query = string.Format(@"EXEC [model].[UserAttributeAdd] '{0}', '{1}', '{2}', '{3}'",
                                      EntityList.SelectedValue, NameAttribute.Text.Trim(), ListType.SelectedValue, NameColumn.Text.Trim());

            using (var conn = new SqlConnection(Global.ConnectionString))
                using (var cmd = new SqlCommand(query, conn))
                {
                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        throw new InvalidOperationException(String.Format("Не удалось добавить атрибут в таблицу.\n{0}.", ex.Message));
                    }
                }

            NameColumn.Text = NameAttribute.Text = null;
            AddAttriabute.Close();
            AliasGridView.DataBind();
        }
Exemplo n.º 3
0
 private void FillAliasGridfromSession()
 {
     try
     {
         AliasDataTable = new DataTable();
         if (Session["Alias"] != "" && Session["Alias"] != null)
         {
             AliasDataTable = (DataTable)Session["Alias"];
         }
         if (AliasDataTable.Rows.Count > 0)
         {
             AliasGridView.DataSource = AliasDataTable;
             AliasGridView.DataBind();
         }
     }
     catch (Exception ex)
     {
         //6/27/2014 NS added for VSPLUS-634
         Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
         throw ex;
     }
     finally { }
 }