Esempio n. 1
0
        public static int SaveQuickAttributes(string listId, string listattribute_id, string displayname, string defaultcssclassname)
        {
            string sql = @"UPDATE listsettings.listattribute
                            SET displayname = @displayname,
                            defaultcssclassname = @defaultcssclassname
                            WHERE listattribute_id = @listattribute_id AND list_id = @list_id
                            ";

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("listattribute_id", listattribute_id),
                new KeyValuePair <string, string>("list_id", listId),
                new KeyValuePair <string, string>("displayname", displayname),
                new KeyValuePair <string, string>("defaultcssclassname", defaultcssclassname),
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                return(0);
            }


            return(1);
        }
Esempio n. 2
0
        protected void btnDropEntity_Click(object sender, EventArgs e)
        {
            string sql = @"SELECT entitysettings.dropentityfrommodelbyid(
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            Response.Redirect("EntityManagerList.aspx");
        }
Esempio n. 3
0
        private void AddNewClientClaim()
        {
            try
            {
                string sql = "INSERT INTO \"ClientClaims\" (\"Type\", \"Value\", \"ClientId\") VALUES(@Type, @Value, CAST(@ClientId AS INT));";

                var paramList = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("Type", this.txtType.Text),
                    new KeyValuePair <string, string>("Value", this.txtValue.Text),
                    new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                };

                DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                ClearAttributesForm();
                this.lblSuccess.Text    = "Client claim added";
                this.lblSuccess.Visible = true;

                BindEntityGrid();
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
Esempio n. 4
0
        protected void dgClientClaim_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Remove")
            {
                try
                {
                    string sql = "DELETE FROM \"ClientClaims\" WHERE \"Id\" = CAST(@Id AS INT);";

                    var paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("Id", e.Item.Cells[0].Text.ToString())
                    };

                    DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                    ClearAttributesForm();
                    this.lblSuccess.Text    = "Client claim removed";
                    this.lblSuccess.Visible = true;

                    BindEntityGrid();
                }
                catch (Exception ex)
                {
                    this.lblError.Text    = ex.ToString();
                    this.lblError.Visible = true;
                    return;
                }
            }
        }
Esempio n. 5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string sql       = @"DELETE FROM eboards.bedboard WHERE bedboard_id = @bedboard_id;";
            string newID     = this.hdnBedBoardID.Value;
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("bedboard_id", newID)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                StringBuilder sbe = new StringBuilder();
                sbe.AppendLine("<div class='contentAlertDanger'><h3 style='color: #712f2f'>Sorry, there was an error:</h3>");
                sbe.AppendLine(ex.ToString());
                sbe.AppendLine("</div>");
                this.ltrlError.Visible = true;
                this.ltrlError.Text    = sbe.ToString();
                return;
            }

            Response.Redirect("BoardManagerList.aspx");
        }
Esempio n. 6
0
        protected void btnDropBaseView_Click(object sender, EventArgs e)
        {
            this.lblError.Visible   = false;
            this.lblSuccess.Visible = false;

            string sql = @"SELECT listsettings.dropbaseview(
	                    @p_baseview_id, 
	                    @p_baseviewname
                    )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_baseview_id", this.hdnBaseViewID.Value),
                new KeyValuePair <string, string>("p_baseviewname", this.lblSummaryType.Text)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Visible = true;
                this.lblError.Text    = ex.ToString();
                return;
            }
            Response.Redirect("BaseViewManagerList.aspx");
        }
Esempio n. 7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string haserr = "form-group has-error";
            string noerr  = "form-group";


            this.lblError.Text      = string.Empty;
            this.lblError.Visible   = false;
            this.lblSuccess.Visible = false;

            this.fgDeviceName.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtDeviceName.Text.ToString()))
            {
                this.lblError.Text = "Please enter the device name";
                this.txtDeviceName.Focus();
                this.lblError.Visible      = true;
                this.fgDeviceName.CssClass = haserr;
                return;
            }

            this.fgIPAddress.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtIPAddress.Text.ToString()))
            {
                this.lblError.Text = "Please enter the IP Address";
                this.txtIPAddress.Focus();
                this.lblError.Visible     = true;
                this.fgIPAddress.CssClass = haserr;
                return;
            }

            string sql = @"UPDATE eboards.bedboarddevice SET
                        bedboarddevicename = @bedboarddevicename, bedboard_id = @bedboard_id, deviceipaddress = @deviceipaddress, locationward = @locationward, locationbayroom = @locationbayroom, locationbed = @locationbed
	                    WHERE bedboarddevice_id = @bedboarddevice_id;"    ;

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("bedboarddevice_id", this.hdnDeviceID.Value),
                new KeyValuePair <string, string>("bedboarddevicename", this.txtDeviceName.Text),
                new KeyValuePair <string, string>("bedboard_id", this.ddlBedBoard.SelectedValue),
                new KeyValuePair <string, string>("deviceipaddress", this.txtIPAddress.Text),
                new KeyValuePair <string, string>("locationward", this.ddllWard.SelectedValue),
                new KeyValuePair <string, string>("locationbayroom", this.ddlBayRoom.SelectedValue),
                new KeyValuePair <string, string>("locationbed", this.ddlBed.SelectedValue)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            Response.Redirect("BedBoardDeviceList.aspx");
        }
Esempio n. 8
0
        private void CreateNewList()
        {
            string sql = "INSERT INTO listsettings.listmanager(list_id, listname, listdescription, listcontextkey, baseview_id, listnamespaceid, " +
                         "listnamespace, defaultcontext, defaultcontextfield, matchedcontextfield, tablecssstyle, tableheadercssstyle, defaultrowcssstyle, " +
                         "patientbannerfield, rowcssfield, wardpersonacontextfield, clinicalunitpersonacontextfield, specialtypersonacontextfield, teampersonacontextfield, snapshottemplateline1, " +
                         "snapshottemplateline2, snapshottemplatebadge, defaultsortcolumn, defaultsortorder) " +
                         "VALUES (@list_id, @listname, @listdescription, @listcontextkey, @baseview_id, @listnamespaceid, " +
                         "@listnamespace, @defaultcontext, @defaultcontextfield, @matchedcontextfield, @tablecssstyle, @tableheadercssstyle, @defaultrowcssstyle, @patientbannerfield, @rowcssfield, " +
                         "@wardpersonacontextfield, @clinicalunitpersonacontextfield, @specialtypersonacontextfield, @teampersonacontextfield, @snapshottemplateline1, @snapshottemplateline2, @snapshottemplatebadge, " +
                         "@defaultsortcolumn, @defaultsortorder)";

            string newId     = System.Guid.NewGuid().ToString();
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("list_id", newId),
                new KeyValuePair <string, string>("listname", this.txtListName.Text),
                new KeyValuePair <string, string>("listdescription", this.txtListComments.Text),
                new KeyValuePair <string, string>("listcontextkey", ""),
                new KeyValuePair <string, string>("baseview_id", this.ddlBaseView.SelectedValue),
                new KeyValuePair <string, string>("listnamespaceid", this.hdnNamespaceID.Value),
                new KeyValuePair <string, string>("listnamespace", SynapseHelpers.GetListNamespaceNameFromID(this.hdnNamespaceID.Value)),
                new KeyValuePair <string, string>("defaultcontext", this.ddlDefaultContext.SelectedValue),
                new KeyValuePair <string, string>("defaultcontextfield", this.lblDefaultContextField.Text),
                new KeyValuePair <string, string>("matchedcontextfield", this.ddlMatchedContextField.SelectedValue),
                new KeyValuePair <string, string>("patientbannerfield", this.ddlPatientBannerField.SelectedValue),
                new KeyValuePair <string, string>("rowcssfield", this.ddlRowCSSField.SelectedValue),
                new KeyValuePair <string, string>("tablecssstyle", this.txtTableClass.Text),
                new KeyValuePair <string, string>("tableheadercssstyle", this.txtTableHeaderClass.Text),
                new KeyValuePair <string, string>("defaultrowcssstyle", this.txtDefaultTableRowCSS.Text),
                new KeyValuePair <string, string>("wardpersonacontextfield", this.ddlWardPersonaContextField.SelectedValue == "0" ? null : this.ddlWardPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("clinicalunitpersonacontextfield", this.ddlCUPersonaContextField.SelectedValue == "0" ? null : this.ddlCUPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("specialtypersonacontextfield", this.ddlSpecialtyPersonaContextField.SelectedValue == "0" ? null : this.ddlSpecialtyPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("teampersonacontextfield", this.ddlTeamPersonaContextField.SelectedValue == "0" ? null : this.ddlTeamPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplateline1", this.ddlSnapshotLine1.SelectedValue == "0" ? null : this.ddlSnapshotLine1.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplateline2", this.ddlSnapshotLine2.SelectedValue == "0" ? null : this.ddlSnapshotLine2.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplatebadge", this.ddlSnapshotBadge.SelectedValue == "0" ? null : this.ddlSnapshotBadge.SelectedValue),
                new KeyValuePair <string, string>("defaultsortcolumn", this.ddlDefaultSortColumn.SelectedValue == "0" ? null : this.ddlDefaultSortColumn.SelectedValue),
                // Don't save defaultsortorder if defaultsortcolumn is not selected
                new KeyValuePair <string, string>("defaultsortorder", this.ddlDefaultSortColumn.SelectedValue == "0" ? null : this.ddlDefaultSortOrder.SelectedValue)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
                updateTeminusFilter(newId);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }


            Response.Redirect("ListManagerAttributes.aspx?id=" + newId);
        }
        private void AddNewClientRedirectUri()
        {
            try
            {
                string sql       = string.Empty;
                var    paramList = new List <KeyValuePair <string, string> >();

                if (this.ddlURIType.SelectedValue == "Redirect URI")
                {
                    sql = "INSERT INTO \"ClientRedirectUris\" (\"RedirectUri\", \"ClientId\") VALUES(@RedirectUri, CAST(@ClientId AS INT));";

                    paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("RedirectUri", this.txtRedirectUri.Text),
                        new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                    };
                }
                else if (this.ddlURIType.SelectedValue == "CORS origin URI")
                {
                    sql = "INSERT INTO \"ClientCorsOrigins\" (\"Origin\", \"ClientId\") VALUES(@Origin, CAST(@ClientId AS INT));";

                    paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("Origin", this.txtRedirectUri.Text),
                        new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                    };
                }
                else if (this.ddlURIType.SelectedValue == "Post logout redirect URI")
                {
                    sql = "INSERT INTO \"ClientPostLogoutRedirectUris\" (\"PostLogoutRedirectUri\", \"ClientId\") VALUES(@PostLogoutRedirectUri, CAST(@ClientId AS INT));";

                    paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("PostLogoutRedirectUri", this.txtRedirectUri.Text),
                        new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                    };
                }

                DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                string selectedValue = this.ddlURIType.SelectedValue;

                ClearAttributesForm();

                this.lblSuccess.Text    = "Client " + selectedValue + " URI added";
                this.lblSuccess.Visible = true;

                BindEntityGrid();
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
        protected void dgClientRedirectURI_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Remove")
            {
                try
                {
                    string sql = string.Empty;

                    var paramList = new List <KeyValuePair <string, string> >();

                    if (e.Item.Cells[2].Text.ToString() == "Redirect URI")
                    {
                        sql = "DELETE FROM \"ClientRedirectUris\" WHERE \"Id\" = CAST(@Id AS INT);";

                        paramList = new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("Id", e.Item.Cells[0].Text.ToString())
                        };
                    }
                    else if (e.Item.Cells[2].Text.ToString() == "CORS origin URI")
                    {
                        sql = "DELETE FROM \"ClientCorsOrigins\" WHERE \"Id\" = CAST(@Id AS INT);";

                        paramList = new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("Id", e.Item.Cells[0].Text.ToString())
                        };
                    }
                    else if (e.Item.Cells[2].Text.ToString() == "Post logout redirect URI")
                    {
                        sql = "DELETE FROM \"ClientPostLogoutRedirectUris\" WHERE \"Id\" = CAST(@Id AS INT);";

                        paramList = new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("Id", e.Item.Cells[0].Text.ToString())
                        };
                    }

                    DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                    ClearAttributesForm();

                    this.lblSuccess.Text    = "Client " + e.Item.Cells[2].Text.ToString() + " removed";
                    this.lblSuccess.Visible = true;

                    BindEntityGrid();
                }
                catch (Exception ex)
                {
                    this.lblError.Text    = ex.ToString();
                    this.lblError.Visible = true;
                    return;
                }
            }
        }
Esempio n. 11
0
        protected void btnDropAttribute_Click(object sender, EventArgs e)
        {
            DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(this.hdnEntityID.Value);


            string sql = @"SELECT entitysettings.dropattributefromentity(
                                @p_attributeid,
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_attributeid", this.hdnAttributeID.Value),
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }


            foreach (DataRow row in dtBVs.Rows)
            {
                string baseview_id       = row["baseview_id"].ToString();
                string sqlRecreate       = "SELECT listsettings.recreatebaseview(@baseview_id);";
                var    paramListRecreate = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("baseview_id", baseview_id)
                };

                try
                {
                    DataServices.ExcecuteNonQueryFromSQL(sqlRecreate, paramListRecreate);
                }
                catch (Exception ex)
                {
                    this.lblError.Text    = ex.ToString();
                    this.lblError.Visible = true;
                    return;
                }
            }


            Response.Redirect("EntityManagerAttributes.aspx?action=view&id=" + this.hdnEntityID.Value);
        }
Esempio n. 12
0
        private void AddNewClientGrantType()
        {
            try
            {
                string sql = "SELECT * FROM \"ClientGrantTypes\" WHERE \"ClientId\" = CAST(@ClientId AS INT) AND \"GrantType\" = @GrantType";

                var param = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value),
                    new KeyValuePair <string, string>("GrantType", this.ddlClientGrantType.SelectedValue)
                };

                DataSet   ds = DataServices.DataSetFromSQL(sql, param, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);
                DataTable dt = ds.Tables[0];

                if (dt.Rows.Count > 0)
                {
                    this.lblError.Text               = "Grant type already exists";
                    this.lblError.Visible            = true;
                    this.pnlClientGrantType.CssClass = "form - group has - error";
                    return;
                }
                else
                {
                    string insertSql = "INSERT INTO \"ClientGrantTypes\" (\"GrantType\", \"ClientId\") VALUES(@GrantType, CAST(@ClientId AS INT));";

                    var paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("GrantType", this.ddlClientGrantType.SelectedValue),
                        new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                    };

                    DataServices.ExcecuteNonQueryFromSQL(insertSql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                    ClearAttributesForm();
                    this.lblSuccess.Text    = "Client grant type added";
                    this.lblSuccess.Visible = true;

                    BindEntityGrid();
                }
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
        protected void btnDropEntity_Click(object sender, EventArgs e)
        {
            string sql = @"SELECT entitysettings.dropentityfrommodelbyid(
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value)
            };

            DataServices.ExcecuteNonQueryFromSQL(sql, paramList);

            Response.Redirect("EntityManagerList.aspx");
        }
        protected void btnDropAttribute_Click(object sender, EventArgs e)
        {
            string sql = @"SELECT entitysettings.droprelationfromentity(
                                @p_attributeid,
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_attributeid", this.hdnAttributeID.Value),
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value)
            };

            DataServices.ExcecuteNonQueryFromSQL(sql, paramList);

            Response.Redirect("EntityManagerRelations.aspx?action=view&id=" + this.hdnEntityID.Value);
        }
Esempio n. 15
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string  sql       = "DELETE FROM eboards.bedboarddevice WHERE bedboarddevice_id = @bedboarddevice_id;";
            DataSet ds        = new DataSet();
            var     paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("bedboarddevice_id", this.hdnDeviceID.Value)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
                Response.Redirect("BedBoardDeviceList.aspx");
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
        public void updateTeminusFilter()
        {
            string sql       = "delete	FROM entitystorematerialised.meta_listcontexts WHERE list_id = @list_id;";
            string listid    = this.hdnListID.Value;
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("list_id", listid)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            DataTable dt = (DataTable)Session["personfilterTable"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string sqlAddfilter = "INSERT INTO entitystorematerialised.meta_listcontexts(listcontexts_id,persona_id, field, list_id) " +

                                      "VALUES (@listcontexts_id, @persona_id, @field, @list_id) ";

                string newId            = System.Guid.NewGuid().ToString();
                var    paramListAddlist = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("listcontexts_id", newId),
                    new KeyValuePair <string, string>("persona_id", dt.Rows[i]["persona_id"].ToString()),
                    new KeyValuePair <string, string>("field", dt.Rows[i]["field"].ToString()),
                    new KeyValuePair <string, string>("list_id", dt.Rows[i]["list_id"].ToString())
                };

                DataServices.ExcecuteNonQueryFromSQL(sqlAddfilter, paramListAddlist);
            }
        }
Esempio n. 17
0
        public void updateTeminusFilter(string listid)
        {
            DataTable dt = (DataTable)Session["personfilterTable"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string sqlAddfilter = "INSERT INTO entitystorematerialised.meta_listcontexts(listcontexts_id,persona_id, field, list_id) " +

                                      "VALUES (@listcontexts_id, @persona_id, @field, @list_id) ";

                string newId            = System.Guid.NewGuid().ToString();
                var    paramListAddlist = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("listcontexts_id", newId),
                    new KeyValuePair <string, string>("persona_id", dt.Rows[i]["persona_id"].ToString()),
                    new KeyValuePair <string, string>("field", dt.Rows[i]["field"].ToString()),
                    new KeyValuePair <string, string>("list_id", dt.Rows[i]["list_id"].ToString())
                };

                DataServices.ExcecuteNonQueryFromSQL(sqlAddfilter, paramListAddlist);
            }
        }
Esempio n. 18
0
        private void AddNewClientSecret()
        {
            try
            {
                string sql = "INSERT INTO \"ClientSecrets\" (\"Value\", \"Type\", \"ClientId\") VALUES(@Value, @Type, CAST(@ClientId AS INT));";

                string hashedPassword = string.Empty;

                using (SHA256 shA256 = SHA256.Create())
                {
                    byte[] bytes = Encoding.UTF8.GetBytes(this.txtValue.Text);
                    hashedPassword = Convert.ToBase64String(((HashAlgorithm)shA256).ComputeHash(bytes));
                }

                var paramList = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("Value", hashedPassword),
                    new KeyValuePair <string, string>("Type", this.txtType.Text),
                    new KeyValuePair <string, string>("ClientId", this.hdnClientID.Value)
                };

                DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                ClearAttributesForm();
                this.lblSuccess.Text    = "Client secret added";
                this.lblSuccess.Visible = true;

                BindEntityGrid();
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
Esempio n. 19
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string haserr = "form-group has-error";
            string noerr  = "form-group";


            this.lblError.Text      = string.Empty;
            this.lblError.Visible   = false;
            this.lblSuccess.Visible = false;

            this.fgDeviceName.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtDeviceName.Text.ToString()))
            {
                this.lblError.Text = "Please enter the device name";
                this.txtDeviceName.Focus();
                this.lblError.Visible      = true;
                this.fgDeviceName.CssClass = haserr;
                return;
            }

            this.fgIPAddress.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtIPAddress.Text.ToString()))
            {
                this.lblError.Text = "Please enter the IP Address";
                this.txtIPAddress.Focus();
                this.lblError.Visible     = true;
                this.fgIPAddress.CssClass = haserr;
                return;
            }


            this.fgLocationCode.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtLocationCode.Text.ToString()))
            {
                this.lblError.Text = "Please enter the Location Code";
                this.txtLocationCode.Focus();
                this.lblError.Visible        = true;
                this.fgLocationCode.CssClass = haserr;
                return;
            }

            string sql = @"INSERT INTO eboards.Locatorboarddevice(
                        Locatorboarddevice_id, Locatorboarddevicename, Locatorboard_id, deviceipaddress, locationid)
	                    VALUES(@Locatorboarddevice_id, @Locatorboarddevicename, @Locatorboard_id, @deviceipaddress, @locationid);"    ;

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("Locatorboarddevice_id", this.hdnDeviceID.Value),
                new KeyValuePair <string, string>("Locatorboarddevicename", this.txtDeviceName.Text),
                new KeyValuePair <string, string>("Locatorboard_id", this.ddlLocatorBoard.SelectedValue),
                new KeyValuePair <string, string>("deviceipaddress", this.txtIPAddress.Text),
                new KeyValuePair <string, string>("locationid", this.txtLocationCode.Text)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            Response.Redirect("LocatorBoardDeviceView.aspx?id=" + this.hdnDeviceID.Value);
        }
Esempio n. 20
0
        private void CreateNewAttribute()
        {
            DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(this.hdnEntityID.Value);

            this.hdnDataType.Value = SynapseHelpers.GetDataTypeFromID(this.ddlDataType.SelectedValue);

            string sql = @"SELECT entitysettings.addattributetoentity(
	                            @p_entityid, 
	                            @p_entityname, 
	                            @p_synapsenamespaceid, 
	                            @p_synapsenamespacename, 
	                            @p_username, 
	                            @p_attributename, 
	                            @p_attributedescription, 
	                            @p_datatype, 
	                            @p_datatypeid, 
	                            CAST(@p_ordinal_position AS integer),
	                            @p_attributedefault, 
	                            @p_maximumlength, 
	                            @p_commondisplayname, 
	                            @p_isnullsetting, 
	                            @p_entityversionid
                            )";

            DataTable dt = SynapseHelpers.GetEntityDSFromID(this.hdnEntityID.Value);

            string maxLength = "";

            if (this.ddlDataType.SelectedItem.Text == "Short String")
            {
                maxLength = "255";
            }
            if (this.ddlDataType.SelectedItem.Text == "Long String")
            {
                maxLength = "1000";
            }

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value),
                new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(this.hdnEntityID.Value)),
                new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()),
                new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()),
                new KeyValuePair <string, string>("p_username", this.hdnUserName.Value),
                new KeyValuePair <string, string>("p_attributename", this.txtAttributeName.Text),
                new KeyValuePair <string, string>("p_attributedescription", "Description"),
                new KeyValuePair <string, string>("p_datatype", this.hdnDataType.Value),
                new KeyValuePair <string, string>("p_datatypeid", this.ddlDataType.SelectedValue),
                new KeyValuePair <string, string>("p_ordinal_position", this.hdnNextOrdinalPosition.Value),
                new KeyValuePair <string, string>("p_attributedefault", ""),
                new KeyValuePair <string, string>("p_maximumlength", maxLength),
                new KeyValuePair <string, string>("p_commondisplayname", ""),
                new KeyValuePair <string, string>("p_isnullsetting", ""),
                new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(this.hdnEntityID.Value))
            };

            DataServices.ExcecuteNonQueryFromSQL(sql, paramList);

            ClearAttributesForm();
            this.lblSuccess.Text    = "Attribute created";
            this.lblSuccess.Visible = true;

            this.hdnNextOrdinalPosition.Value = SynapseHelpers.GetNextOrdinalPositionFromID(this.hdnEntityID.Value);



            foreach (DataRow row in dtBVs.Rows)
            {
                string baseview_id       = row["baseview_id"].ToString();
                string sqlRecreate       = "SELECT listsettings.recreatebaseview(@baseview_id);";
                var    paramListRecreate = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("baseview_id", baseview_id)
                };

                try
                {
                    DataServices.ExcecuteNonQueryFromSQL(sqlRecreate, paramListRecreate);
                }
                catch (Exception ex) {
                    var a = ex.ToString();
                }
            }


            BindEntityGrid();
        }
Esempio n. 21
0
        private void AddUser()
        {
            try
            {
                string userId = Guid.NewGuid().ToString();

                string hashedPassword = string.Empty;

                PasswordHasher <IdentityUser> passwordHasher = new PasswordHasher <IdentityUser>();
                IdentityUser user = new IdentityUser(this.txtUsername.Text);
                hashedPassword = passwordHasher.HashPassword(user, this.txtPassword.Text);

                //using (SHA256 shA256 = SHA256.Create())
                //{
                //    byte[] bytes = Encoding.UTF8.GetBytes(this.txtPassword.Text);
                //    hashedPassword = Convert.ToBase64String(((HashAlgorithm)shA256).ComputeHash(bytes));
                //}

                string sql = "INSERT INTO \"AspNetUsers\"(\"Id\", \"UserName\", \"NormalizedUserName\", \"Email\", \"NormalizedEmail\", \"EmailConfirmed\", \"PasswordHash\", \"SecurityStamp\", \"ConcurrencyStamp\", \"PhoneNumberConfirmed\",                    \"TwoFactorEnabled\", \"LockoutEnabled\", \"AccessFailedCount\") "
                             + " VALUES(@Id, @UserName, @NormalizedUserName, @Email, @NormalizedEmail, false, @PasswordHash, @SecurityStamp, @ConcurrencyStamp, false, false, false, 0)";

                var paramList = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("Id", userId),
                    new KeyValuePair <string, string>("Username", this.txtUsername.Text),
                    new KeyValuePair <string, string>("NormalizedUserName", this.txtUsername.Text.ToUpper()),
                    new KeyValuePair <string, string>("Email", this.txtEmail.Text),
                    new KeyValuePair <string, string>("NormalizedEmail", this.txtEmail.Text.ToUpper()),
                    new KeyValuePair <string, string>("PasswordHash", hashedPassword),
                    new KeyValuePair <string, string>("SecurityStamp", Guid.NewGuid().ToString()),
                    new KeyValuePair <string, string>("ConcurrencyStamp", Guid.NewGuid().ToString())
                };

                DataServices.ExcecuteNonQueryFromSQL(sql, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                string query = "INSERT INTO \"AspNetUserClaims\" (\"UserId\", \"ClaimType\", \"ClaimValue\") " +
                               "VALUES(@UserId, @ClaimType, @ClaimValue), " +
                               "(@UserId, @ClaimType1, @ClaimValue1), " +
                               "(@UserId, @ClaimType2, @ClaimValue2), " +
                               "(@UserId, @ClaimType3, @ClaimValue3), " +
                               "(@UserId, @ClaimType4, @ClaimValue4);";

                var parameters = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("UserId", userId),
                    new KeyValuePair <string, string>("ClaimType", "name"),
                    new KeyValuePair <string, string>("ClaimValue", this.txtFirstName.Text + ' ' + this.txtLastName.Text),
                    new KeyValuePair <string, string>("ClaimType1", "given_name"),
                    new KeyValuePair <string, string>("ClaimValue1", this.txtFirstName.Text),
                    new KeyValuePair <string, string>("ClaimType2", "family_name"),
                    new KeyValuePair <string, string>("ClaimValue2", this.txtLastName.Text),
                    new KeyValuePair <string, string>("ClaimType3", "email"),
                    new KeyValuePair <string, string>("ClaimValue3", this.txtEmail.Text),
                    new KeyValuePair <string, string>("ClaimType4", "email_verified"),
                    new KeyValuePair <string, string>("ClaimValue4", "true")
                };

                DataServices.ExcecuteNonQueryFromSQL(query, parameters, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                ClearAttributesForm();
                this.lblSuccess.Text    = "New user added";
                this.lblSuccess.Visible = true;
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
        private void updateClient()
        {
            try
            {
                string sql = "SELECT * FROM \"Clients\" WHERE \"ClientId\" = @ClientId";

                var param = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("ClientId", txtClientId.Text)
                };

                DataSet   ds = DataServices.DataSetFromSQL(sql, param, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);
                DataTable dt = ds.Tables[0];

                if (dt.Rows.Count != 1)
                {
                    lblError.Text = "Client Id Not exists";
                    txtClientId.Focus();
                    lblError.Visible     = true;
                    pnlClientId.CssClass = "form - group has - error";
                    return;
                }
                else
                {
                    string insertSQL = "  UPDATE \"Clients\" SET "
                                       + "  \"Enabled\" =CAST(@Enabled AS BOOLEAN), "

                                       + "  \"RequireClientSecret\" =  CAST(@RequireClientSecret AS BOOLEAN), "
                                       + "  \"ClientName\" = @ClientName,"
                                       + "  \"Description\" =  @Description, "
                                       + "  \"RequireConsent\" = CAST(@RequireConsent AS BOOLEAN), "

                                       + "  \"AllowAccessTokensViaBrowser\" = CAST(@AllowAccessTokensViaBrowser AS BOOLEAN), "

                                       + "  \"AllowOfflineAccess\" =  CAST(@AllowOfflineAccess AS BOOLEAN), "
                                       + "  \"IdentityTokenLifetime\" =  CAST(@IdentityTokenLifetime AS INT), "
                                       + "  \"AccessTokenLifetime\" =  CAST(@AccessTokenLifetime AS INT), "
                                       + "  \"AuthorizationCodeLifetime\" =  CAST(@AuthorizationCodeLifetime AS INT), "
                                       + "  \"ConsentLifetime\" = CAST(@ConsentLifetime AS INT), "
                                       + "  \"AbsoluteRefreshTokenLifetime\" =  CAST(@AbsoluteRefreshTokenLifetime AS INT), "
                                       + "  \"SlidingRefreshTokenLifetime\" =  CAST(@SlidingRefreshTokenLifetime AS INT), "
                                       + "  \"RefreshTokenUsage\" =  CAST(@RefreshTokenUsage AS INT), "
                                       + "  \"UpdateAccessTokenClaimsOnRefresh\" =  CAST(@UpdateAccessTokenClaimsOnRefresh AS BOOLEAN), "
                                       + "  \"RefreshTokenExpiration\" =CAST(@RefreshTokenExpiration AS INT), "
                                       + "  \"EnableLocalLogin\" = CAST(@EnableLocalLogin AS BOOLEAN), "
                                       + "  \"AlwaysSendClientClaims\" =CAST(@AlwaysSendClientClaims AS BOOLEAN), "
                                       + "  \"ClientClaimsPrefix\" = @ClientClaimsPrefix "
                                       + " WHERE \"ClientId\" = @ClientId ";


                    var paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("Enabled", chkEnabled.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientId", txtClientId.Text),
                        new KeyValuePair <string, string>("RequireClientSecret", chkReqClntSecret.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientName", txtClientName.Text),
                        new KeyValuePair <string, string>("Description", txtDesc.Text),
                        new KeyValuePair <string, string>("RequireConsent", chkReqCon.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AllowAccessTokensViaBrowser", chkAllAccTkn.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AllowOfflineAccess", chkAllOffAcc.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("IdentityTokenLifetime", txtIdTknLt.Text),
                        new KeyValuePair <string, string>("AccessTokenLifetime", txtAccTknLt.Text),
                        new KeyValuePair <string, string>("AuthorizationCodeLifetime", txtAuthCodeLt.Text),
                        new KeyValuePair <string, string>("ConsentLifetime", txtConLt.Text),
                        new KeyValuePair <string, string>("AbsoluteRefreshTokenLifetime", txtAbReTknLt.Text),
                        new KeyValuePair <string, string>("SlidingRefreshTokenLifetime", txtSlReTknLt.Text),
                        new KeyValuePair <string, string>("RefreshTokenUsage", chkReTknUs.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("UpdateAccessTokenClaimsOnRefresh", chkUpdAccTknClRe.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("RefreshTokenExpiration", chkReTknExp.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("EnableLocalLogin", chkEnLocLog.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AlwaysSendClientClaims", chkAlSenClntCl.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientClaimsPrefix", txtClntClPre.Text)
                    };

                    DataServices.ExcecuteNonQueryFromSQL(insertSQL, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                    if (!string.IsNullOrEmpty(GetClientId(this.txtClientId.Text)) || GetClientId(this.txtClientId.Text) != "An error occurred")
                    {
                        string clientId = GetClientId(this.txtClientId.Text);

                        Response.Redirect("ClientScopes.aspx?id=" + clientId);
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text    = ex.ToString();
                lblError.Visible = true;
                return;
            }
        }
        private void AddNewClient()
        {
            try
            {
                string sql = "SELECT * FROM \"Clients\" WHERE \"ClientId\" = @ClientId";

                var param = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("ClientId", this.txtClientId.Text)
                };

                DataSet   ds = DataServices.DataSetFromSQL(sql, param, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);
                DataTable dt = ds.Tables[0];

                if (dt.Rows.Count > 0)
                {
                    this.lblError.Text = "Client Id already exists";
                    this.txtClientId.Focus();
                    this.lblError.Visible     = true;
                    this.pnlClientId.CssClass = "form - group has - error";
                    return;
                }
                else
                {
                    string insertSQL = "INSERT INTO \"Clients\" (\"Enabled\", \"ClientId\", \"ProtocolType\", \"RequireClientSecret\", \"ClientName\", "
                                       + " \"Description\", \"RequireConsent\", \"AllowRememberConsent\", \"AlwaysIncludeUserClaimsInIdToken\", "
                                       + " \"RequirePkce\", \"AllowPlainTextPkce\", \"AllowAccessTokensViaBrowser\", \"FrontChannelLogoutSessionRequired\", "
                                       + " \"BackChannelLogoutSessionRequired\", \"AllowOfflineAccess\", \"IdentityTokenLifetime\", \"AccessTokenLifetime\", "
                                       + " \"AuthorizationCodeLifetime\", \"ConsentLifetime\", \"AbsoluteRefreshTokenLifetime\", \"SlidingRefreshTokenLifetime\", "
                                       + " \"RefreshTokenUsage\", \"UpdateAccessTokenClaimsOnRefresh\", \"RefreshTokenExpiration\", \"AccessTokenType\", "
                                       + " \"EnableLocalLogin\", \"IncludeJwtId\", \"AlwaysSendClientClaims\", \"ClientClaimsPrefix\") "
                                       + " VALUES(CAST(@Enabled AS BOOLEAN), @ClientId, 'oidc', CAST(@RequireClientSecret AS BOOLEAN), @ClientName, "
                                       + " @Description, CAST(@RequireConsent AS BOOLEAN), true, true, "
                                       + " false, true, CAST(@AllowAccessTokensViaBrowser AS BOOLEAN), false, "
                                       + " false, CAST(@AllowOfflineAccess AS BOOLEAN), CAST(@IdentityTokenLifetime AS INT), CAST(@AccessTokenLifetime AS INT), "
                                       + " CAST(@AuthorizationCodeLifetime AS INT), CAST(@ConsentLifetime AS INT), CAST(@AbsoluteRefreshTokenLifetime AS INT), CAST(@SlidingRefreshTokenLifetime AS INT), "
                                       + " CAST(@RefreshTokenUsage AS INT), CAST(@UpdateAccessTokenClaimsOnRefresh AS BOOLEAN), CAST(@RefreshTokenExpiration AS INT), 0, "
                                       + " CAST(@EnableLocalLogin AS BOOLEAN), false, CAST(@AlwaysSendClientClaims AS BOOLEAN), @ClientClaimsPrefix);";

                    var paramList = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("Enabled", this.chkEnabled.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientId", this.txtClientId.Text),
                        new KeyValuePair <string, string>("RequireClientSecret", this.chkReqClntSecret.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientName", this.txtClientName.Text),
                        new KeyValuePair <string, string>("Description", this.txtDesc.Text),
                        new KeyValuePair <string, string>("RequireConsent", this.chkReqCon.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AllowAccessTokensViaBrowser", this.chkAllAccTkn.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AllowOfflineAccess", this.chkAllOffAcc.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("IdentityTokenLifetime", this.txtIdTknLt.Text),
                        new KeyValuePair <string, string>("AccessTokenLifetime", this.txtAccTknLt.Text),
                        new KeyValuePair <string, string>("AuthorizationCodeLifetime", this.txtAuthCodeLt.Text),
                        new KeyValuePair <string, string>("ConsentLifetime", this.txtConLt.Text),
                        new KeyValuePair <string, string>("AbsoluteRefreshTokenLifetime", this.txtAbReTknLt.Text),
                        new KeyValuePair <string, string>("SlidingRefreshTokenLifetime", this.txtSlReTknLt.Text),
                        new KeyValuePair <string, string>("RefreshTokenUsage", this.chkReTknUs.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("UpdateAccessTokenClaimsOnRefresh", this.chkUpdAccTknClRe.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("RefreshTokenExpiration", this.chkReTknExp.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("EnableLocalLogin", this.chkEnLocLog.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("AlwaysSendClientClaims", this.chkAlSenClntCl.Checked ? "1" : "0"),
                        new KeyValuePair <string, string>("ClientClaimsPrefix", this.txtClntClPre.Text)
                    };

                    DataServices.ExcecuteNonQueryFromSQL(insertSQL, paramList, dbConnection: SynapseHelpers.DBConnections.PGSQLConnectionSIS);

                    if (!string.IsNullOrEmpty(GetClientId(this.txtClientId.Text)) || GetClientId(this.txtClientId.Text) != "An error occurred")
                    {
                        string clientId = GetClientId(this.txtClientId.Text);

                        Response.Redirect("ClientScopes.aspx?id=" + clientId);
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }
        }
        protected void btnCreateNewEntity_Click(object sender, EventArgs e)
        {
            //Drop the baseeview
            string sqlDrop = @"SELECT listsettings.dropbaseview(
	                    @p_baseview_id, 
	                    @p_baseviewname
                    )";



            var paramListDrop = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_baseview_id", this.hdnBaseViewID.Value),
                new KeyValuePair <string, string>("p_baseviewname", this.lblSummaryType.Text)
            };

            DataServices.ExcecuteNonQueryFromSQL(sqlDrop, paramListDrop);


            //Recreate the baseview
            //string tmpViewName = Guid.NewGuid().ToString("N");
            //Check if we can create a temporary view using the supplied SQL Statement
            string sqlCreate       = "CREATE VIEW baseviewcore." + this.lblNamespaceName.Text + "_" + this.lblBaseViewName.Text + " AS " + this.txtSQL.Text + ";";
            var    paramListCreate = new List <KeyValuePair <string, string> >()
            {
            };

            try
            {
                DataServices.executeSQLStatement(sqlCreate, paramListCreate);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = "Error creating view: " + ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            string baseviewid = this.hdnBaseViewID.Value;

            string sql = "SELECT listsettings.recreatebaseview(@p_baseviewnamespaceid, @p_baseviewnamespace, @p_baseviewname, @p_baseviewdescription, @p_baseviewsqlstatement, @p_username, @baseviewid);";

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_baseviewnamespaceid", this.hdnNamespaceID.Value),
                new KeyValuePair <string, string>("p_baseviewnamespace", this.lblNamespaceName.Text),
                new KeyValuePair <string, string>("p_baseviewname", this.lblBaseViewName.Text),
                new KeyValuePair <string, string>("p_baseviewdescription", this.lblBaseViewComments.Text),
                new KeyValuePair <string, string>("p_baseviewsqlstatement", this.txtSQL.Text),
                new KeyValuePair <string, string>("p_username", this.hdnUserName.Value),
                new KeyValuePair <string, string>("baseviewid", this.hdnBaseViewID.Value),
            };

            DataSet ds = new DataSet();

            try
            {
                ds = DataServices.DataSetFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = "Error creating view: " + ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            DataTable dt = ds.Tables[0];

            string newGuid = "";

            try
            {
                newGuid = dt.Rows[0][0].ToString();
            }
            catch { }

            Response.Redirect("BaseViewManageSQL.aspx?id=" + newGuid);
        }
Esempio n. 25
0
        protected void btnClone_Click(object sender, EventArgs e)
        {
            string haserr = "form-group has-error";
            string noerr  = "form-group";

            this.ltrlError.Text     = string.Empty;
            this.ltrlError.Visible  = false;
            this.lblSuccess.Visible = false;

            int           errcount = 0;
            StringBuilder sb       = new StringBuilder();

            sb.AppendLine("<div class='contentAlertDanger'><h3 style='color: #712f2f'>Please resolve the following errors:</h3><ul>");

            this.fgBedBoardName.CssClass = noerr;
            if (string.IsNullOrWhiteSpace(this.txtBedBoardName.Text))
            {
                sb.AppendLine("<li>" + "Please enter a new name for the Bed Board" + "</li>");
                this.fgBedBoardName.CssClass = haserr;
                errcount++;
            }

            this.fgBaseView.CssClass = noerr;
            if (this.ddlBaseView.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select a baseview" + "</li>");
                this.fgBaseView.CssClass = haserr;
                errcount++;
            }

            this.fgPersonIDField.CssClass = noerr;
            if (this.ddlPersonIDField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the PersonID field from the baseview" + "</li>");
                this.fgPersonIDField.CssClass = haserr;
                errcount++;
            }

            this.fgEncounterIDField.CssClass = noerr;
            if (this.ddlEncounterIDField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the EncounterID field from the baseview" + "</li>");
                this.fgEncounterIDField.CssClass = haserr;
                errcount++;
            }

            this.fgWardField.CssClass = noerr;
            if (this.ddlWardField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Ward Code field from the baseview" + "</li>");
                this.fgWardField.CssClass = haserr;
                errcount++;
            }

            this.fgBedField.CssClass = noerr;
            if (this.ddlBedField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Bed Code field from the baseview" + "</li>");
                this.fgBedField.CssClass = haserr;
                errcount++;
            }

            this.fgTopSetting.CssClass = noerr;
            if (this.ddlTopSetting.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the top section setting" + "</li>");
                this.fgTopSetting.CssClass = haserr;
                errcount++;
            }

            this.fgTopField.CssClass = noerr;
            if (this.ddlTopSetting.SelectedValue == "1" && this.ddlTopField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Top Section" + "</li>");
                this.fgTopField.CssClass = haserr;
                errcount++;
            }

            this.fgTopLeftField.CssClass = noerr;
            if (this.ddlTopSetting.SelectedValue == "2" && this.ddlTopLeftField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Top Left Section" + "</li>");
                this.fgTopField.CssClass = haserr;
                errcount++;
            }

            this.fgTopRightField.CssClass = noerr;
            if (this.ddlTopSetting.SelectedValue == "2" && this.ddlTopRightField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Top Right Section" + "</li>");
                this.fgTopField.CssClass = haserr;
                errcount++;
            }

            this.fgMiddleSetting.CssClass = noerr;
            if (this.ddlMiddleSetting.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Middle section setting" + "</li>");
                this.fgMiddleSetting.CssClass = haserr;
                errcount++;
            }

            this.fgMiddleField.CssClass = noerr;
            if (this.ddlMiddleSetting.SelectedValue == "1" && this.ddlMiddleField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Middle Section" + "</li>");
                this.fgMiddleField.CssClass = haserr;
                errcount++;
            }

            this.fgMiddleLeftField.CssClass = noerr;
            if (this.ddlMiddleSetting.SelectedValue == "2" && this.ddlMiddleLeftField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Middle Left Section" + "</li>");
                this.fgMiddleField.CssClass = haserr;
                errcount++;
            }

            this.fgMiddleRightField.CssClass = noerr;
            if (this.ddlMiddleSetting.SelectedValue == "2" && this.ddlMiddleRightField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Middle Right Section" + "</li>");
                this.fgMiddleField.CssClass = haserr;
                errcount++;
            }

            this.fgBottomSetting.CssClass = noerr;
            if (this.ddlBottomSetting.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Bottom section setting" + "</li>");
                this.fgBottomSetting.CssClass = haserr;
                errcount++;
            }

            this.fgBottomField.CssClass = noerr;
            if (this.ddlBottomSetting.SelectedValue == "1" && this.ddlBottomField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Bottom Section" + "</li>");
                this.fgBottomField.CssClass = haserr;
                errcount++;
            }

            this.fgBottomLeftField.CssClass = noerr;
            if (this.ddlBottomSetting.SelectedValue == "2" && this.ddlBottomLeftField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Bottom Left Section" + "</li>");
                this.fgBottomField.CssClass = haserr;
                errcount++;
            }

            this.fgBottomRightField.CssClass = noerr;
            if (this.ddlBottomSetting.SelectedValue == "2" && this.ddlBottomRightField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Bottom Right Section" + "</li>");
                this.fgBottomField.CssClass = haserr;
                errcount++;
            }



            if (errcount > 0)
            {
                sb.AppendLine("</ul></div>");
                this.ltrlError.Visible = true;
                this.ltrlError.Text    = sb.ToString();
                return;
            }

            string sql = @"INSERT INTO eboards.bedboard(
                                _createdby, 
	                            bedboard_id, 
	                            bedboardname, 
	                            bedboarddescription, 
	                            baseviewnamespace_id, 
	                            baseview_id, 
	                            baseviewpersonidfield, 
	                            baseviewencounteridfield, 
	                            baseviewwardfield, 
	                            baseviewbedfield, 
	                            topsetting, 
	                            middlesetting, 
	                            bottomsetting, 
	                            topfield, 
	                            topleftfield, 
	                            toprightfield, 
	                            middlefield, 
	                            middleleftfield, 
	                            middlerightfield, 
	                            bottomfield, 
	                            bottomleftfield, 
	                            bottomrightfield
                            )
                            VALUES(
                                @_createdby,
                                @bedboard_id,
                                @bedboardname,
                                @bedboarddescription,
                                @baseviewnamespace_id,
                                @baseview_id,
                                @baseviewpersonidfield,
                                @baseviewencounteridfield,
                                @baseviewwardfield,
                                @baseviewbedfield,
                                @topsetting,
                                @middlesetting,
                                @bottomsetting,
                                @topfield,
                                @topleftfield,
                                @toprightfield,
                                @middlefield,
                                @middleleftfield,
                                @middlerightfield,
                                @bottomfield,
                                @bottomleftfield,
                                @bottomrightfield
                            )";

            string newID     = System.Guid.NewGuid().ToString();
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("_createdby", this.hdnUserName.Value),
                new KeyValuePair <string, string>("bedboard_id", newID),
                new KeyValuePair <string, string>("bedboardname", this.txtBedBoardName.Text + "_Clone"),
                new KeyValuePair <string, string>("bedboarddescription", this.txtBedBoardDescription.Text),
                new KeyValuePair <string, string>("baseviewnamespace_id", this.ddlBaseViewNamespace.SelectedValue),
                new KeyValuePair <string, string>("baseview_id", this.ddlBaseView.SelectedValue),
                new KeyValuePair <string, string>("baseviewpersonidfield", this.ddlPersonIDField.SelectedValue),
                new KeyValuePair <string, string>("baseviewencounteridfield", this.ddlEncounterIDField.SelectedValue),
                new KeyValuePair <string, string>("baseviewwardfield", this.ddlWardField.SelectedValue),
                new KeyValuePair <string, string>("baseviewbedfield", this.ddlBedField.SelectedValue),
                new KeyValuePair <string, string>("topsetting", this.ddlTopSetting.SelectedValue),
                new KeyValuePair <string, string>("middlesetting", this.ddlMiddleSetting.SelectedValue),
                new KeyValuePair <string, string>("bottomsetting", this.ddlBottomSetting.SelectedValue),
                new KeyValuePair <string, string>("topfield", this.ddlTopField.SelectedValue),
                new KeyValuePair <string, string>("topleftfield", this.ddlTopLeftField.SelectedValue),
                new KeyValuePair <string, string>("toprightfield", this.ddlTopRightField.SelectedValue),
                new KeyValuePair <string, string>("middlefield", this.ddlMiddleField.SelectedValue),
                new KeyValuePair <string, string>("middleleftfield", this.ddlMiddleLeftField.SelectedValue),
                new KeyValuePair <string, string>("middlerightfield", this.ddlMiddleRightField.SelectedValue),
                new KeyValuePair <string, string>("bottomfield", this.ddlBottomField.SelectedValue),
                new KeyValuePair <string, string>("bottomleftfield", this.ddlBottomLeftField.SelectedValue),
                new KeyValuePair <string, string>("bottomrightfield", this.ddlBottomRightField.SelectedValue)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                StringBuilder sbe = new StringBuilder();
                sbe.AppendLine("<div class='contentAlertDanger'><h3 style='color: #712f2f'>Sorry, there was an error:</h3>");
                sbe.AppendLine(ex.ToString());
                sbe.AppendLine("</div>");
                this.ltrlError.Visible = true;
                this.ltrlError.Text    = sbe.ToString();
                return;
            }

            Response.Redirect("BedBoardManagerView.aspx?id=" + newID);
        }
Esempio n. 26
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string haserr = "form-group has-error";
            string noerr  = "form-group";

            this.ltrlError.Text     = string.Empty;
            this.ltrlError.Visible  = false;
            this.lblSuccess.Visible = false;

            int           errcount = 0;
            StringBuilder sb       = new StringBuilder();

            sb.AppendLine("<div class='contentAlertDanger'><h3 style='color: #712f2f'>Please resolve the following errors:</h3><ul>");

            this.fgLocatorBoardName.CssClass = noerr;
            if (string.IsNullOrWhiteSpace(this.txtLocatorBoardName.Text))
            {
                sb.AppendLine("<li>" + "Please enter a new name for the Bed Board" + "</li>");
                this.fgLocatorBoardName.CssClass = haserr;
                errcount++;
            }



            //Lists
            this.fgList.CssClass = noerr;
            if (this.ddlList.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the underlying list for the board" + "</li>");
                this.fgList.CssClass = haserr;
                errcount++;
            }

            this.fgListLocationField.CssClass = noerr;
            if (this.ddlListLocationField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the location id field for the list" + "</li>");
                this.fgListLocationField.CssClass = haserr;
                errcount++;
            }

            this.fgBaseViewNamespace.CssClass = noerr;
            if (this.ddlBaseViewNamespace.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the location specific information baseview" + "</li>");
                this.fgBaseViewNamespace.CssClass = haserr;
                errcount++;
            }

            this.fgBaseView.CssClass = noerr;
            if (this.ddlBaseView.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select a location specific baseview" + "</li>");
                this.fgBaseView.CssClass = haserr;
                errcount++;
            }



            this.fgLocationIDField.CssClass = noerr;
            if (this.ddlLocationIDField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Bed Code field from the baseview" + "</li>");
                this.fgLocationIDField.CssClass = haserr;
                errcount++;
            }


            this.fgHeading.CssClass = noerr;
            if (this.ddlHeading.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the Heading column from the baseview" + "</li>");
                this.fgHeading.CssClass = haserr;
                errcount++;
            }

            this.fgTopLeftField.CssClass = noerr;
            if (this.ddlTopLeftField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Top Left Section" + "</li>");
                this.fgTopLeftField.CssClass = haserr;
                errcount++;
            }

            this.fgTopRightField.CssClass = noerr;
            if (ddlTopRightField.SelectedIndex == 0)
            {
                sb.AppendLine("<li>" + "Please select the field column from the baseview for the Top Right Section" + "</li>");
                this.fgTopRightField.CssClass = haserr;
                errcount++;
            }



            if (errcount > 0)
            {
                sb.AppendLine("</ul></div>");
                this.ltrlError.Visible = true;
                this.ltrlError.Text    = sb.ToString();
                return;
            }

            string sql = @"INSERT INTO eboards.LocatorBoard(
                                _createdby, 
	                            LocatorBoard_id, 
	                            LocatorBoardname, 
	                            LocatorBoarddescription, 
	                            list_id,
                                listlocationfield,
                                locationbaseviewnamespace_id, 
	                            locationbaseview_id,              
                                locationidfield,
                                locationdisplayfield,
	                            topleftfield, 
	                            toprightfield
                            )
                            VALUES(
                                @_createdby, 
	                            @LocatorBoard_id, 
	                            @LocatorBoardname, 
	                            @LocatorBoarddescription, 
	                            @list_id,
                                @listlocationfield,
                                @locationbaseviewnamespace_id, 
	                            @locationbaseview_id,       
                                @locationidfield,
                                @locationdisplayfield,
	                            @topleftfield, 
	                            @toprightfield
                            )";

            string newID     = System.Guid.NewGuid().ToString();
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("_createdby", this.hdnUserName.Value),
                new KeyValuePair <string, string>("LocatorBoard_id", newID),
                new KeyValuePair <string, string>("LocatorBoardname", this.txtLocatorBoardName.Text),
                new KeyValuePair <string, string>("LocatorBoarddescription", this.txtLocatorBoardDescription.Text),

                new KeyValuePair <string, string>("list_id", this.ddlList.SelectedValue),
                new KeyValuePair <string, string>("listlocationfield", this.ddlListLocationField.SelectedValue),

                new KeyValuePair <string, string>("locationbaseviewnamespace_id", this.ddlBaseViewNamespace.SelectedValue),
                new KeyValuePair <string, string>("locationbaseview_id", this.ddlBaseView.SelectedValue),
                new KeyValuePair <string, string>("locationidfield", this.ddlLocationIDField.SelectedValue),
                new KeyValuePair <string, string>("locationdisplayfield", this.ddlHeading.SelectedValue),
                new KeyValuePair <string, string>("topleftfield", this.ddlTopLeftField.SelectedValue),
                new KeyValuePair <string, string>("toprightfield", this.ddlTopRightField.SelectedValue)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                StringBuilder sbe = new StringBuilder();
                sbe.AppendLine("<div class='contentAlertDanger'><h3 style='color: #712f2f'>Sorry, there was an error:</h3>");
                sbe.AppendLine(ex.ToString());
                sbe.AppendLine("</div>");
                this.ltrlError.Visible = true;
                this.ltrlError.Text    = sbe.ToString();
                return;
            }

            Response.Redirect("LocatorBoardManagerView.aspx?id=" + newID);
        }
        private void SaveNewList()
        {
            string haserr = "form-group has-error";
            string noerr  = "form-group";


            this.lblError.Text      = string.Empty;
            this.lblError.Visible   = false;
            this.lblSuccess.Visible = false;

            this.fgListName.CssClass = noerr;
            if (string.IsNullOrEmpty(this.txtListName.Text.ToString()))
            {
                this.lblError.Text = "Please enter a new name for the List";
                this.txtListName.Focus();
                this.lblError.Visible    = true;
                this.fgListName.CssClass = haserr;
                return;
            }


            this.fgDefaultContext.CssClass = noerr;
            if (this.ddlDefaultContext.SelectedIndex == 0)
            {
                this.lblError.Text = "Please select the entity that defines the default context";
                this.ddlDefaultContext.Focus();
                this.lblError.Visible          = true;
                this.fgDefaultContext.CssClass = haserr;
                return;
            }

            this.fgMatchedContextField.CssClass = noerr;
            if (this.ddlMatchedContextField.SelectedIndex == 0)
            {
                this.lblError.Text = "Please select the field from the baseview that matches the default context key defined";
                this.ddlMatchedContextField.Focus();
                this.lblError.Visible = true;
                this.fgMatchedContextField.CssClass = haserr;
                return;
            }



            string sql = "UPDATE listsettings.listmanager SET " +
                         "listname = @listname, " +
                         "listdescription = @listdescription, " +
                         "defaultcontext = @defaultcontext, " +
                         "defaultcontextfield = @defaultcontextfield, " +
                         "matchedcontextfield = @matchedcontextfield, " +
                         "tablecssstyle = @tablecssstyle, " +
                         "tableheadercssstyle = @tableheadercssstyle, " +
                         "defaultrowcssstyle = @defaultrowcssstyle, " +
                         "patientbannerfield = @patientbannerfield, " +
                         "rowcssfield = @rowcssfield, " +
                         "wardpersonacontextfield = @wardpersonacontextfield, " +
                         "clinicalunitpersonacontextfield = @clinicalunitpersonacontextfield, " +
                         "specialtypersonacontextfield = @specialtypersonacontextfield, " +
                         "teampersonacontextfield = @teampersonacontextfield, " +
                         "snapshottemplateline1 = @snapshottemplateline1, " +
                         "snapshottemplateline2 = @snapshottemplateline2, " +
                         "snapshottemplatebadge = @snapshottemplatebadge, " +
                         "defaultsortcolumn = @defaultsortcolumn, " +
                         "defaultsortorder = @defaultsortorder " +
                         "WHERE list_id = @list_id;";

            string newId     = this.hdnListID.Value;
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("list_id", newId),
                new KeyValuePair <string, string>("listname", this.txtListName.Text),
                new KeyValuePair <string, string>("listdescription", this.txtListComments.Text),
                new KeyValuePair <string, string>("defaultcontext", this.ddlDefaultContext.SelectedValue),
                new KeyValuePair <string, string>("defaultcontextfield", this.lblDefaultContextField.Text),
                new KeyValuePair <string, string>("matchedcontextfield", this.ddlMatchedContextField.SelectedValue),
                new KeyValuePair <string, string>("patientbannerfield", this.ddlPatientBannerField.SelectedValue),
                new KeyValuePair <string, string>("rowcssfield", this.ddlRowCSSField.SelectedValue),
                new KeyValuePair <string, string>("tablecssstyle", this.txtTableClass.Text),
                new KeyValuePair <string, string>("tableheadercssstyle", this.txtTableHeaderClass.Text),
                new KeyValuePair <string, string>("defaultrowcssstyle", this.txtDefaultTableRowCSS.Text),
                new KeyValuePair <string, string>("wardpersonacontextfield", this.ddlWardPersonaContextField.SelectedValue == "0" ? null : this.ddlWardPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("clinicalunitpersonacontextfield", this.ddlCUPersonaContextField.SelectedValue == "0" ? null : this.ddlCUPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("specialtypersonacontextfield", this.ddlSpecialtyPersonaContextField.SelectedValue == "0" ? null : this.ddlSpecialtyPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("teampersonacontextfield", this.ddlTeamPersonaContextField.SelectedValue == "0" ? null : this.ddlTeamPersonaContextField.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplateline1", this.ddlSnapshotLine1.SelectedValue == "0" ? null : this.ddlSnapshotLine1.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplateline2", this.ddlSnapshotLine2.SelectedValue == "0" ? null : this.ddlSnapshotLine2.SelectedValue),
                new KeyValuePair <string, string>("snapshottemplatebadge", this.ddlSnapshotBadge.SelectedValue == "0" ? null : this.ddlSnapshotBadge.SelectedValue),
                new KeyValuePair <string, string>("defaultsortcolumn", this.ddlDefaultSortColumn.SelectedValue == "0" ? null : this.ddlDefaultSortColumn.SelectedValue),
                // Don't save defaultsortorder if defaultsortcolumn is not selected
                new KeyValuePair <string, string>("defaultsortorder", this.ddlDefaultSortColumn.SelectedValue == "0" ? null : this.ddlDefaultSortOrder.SelectedValue)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
                updateTeminusFilter();
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }


            Response.Redirect("ListManagerList.aspx");
        }
Esempio n. 28
0
        private void CreateRelation()
        {
            string sql = @"SELECT entitysettings.addrelationtoentity(
	                            @p_entityid, 
	                            @p_entityname, 
	                            @p_synapsenamespaceid, 
	                            @p_synapsenamespacename,     
                                @p_parententityid,
                                @p_parententityname,
                                @p_parentsynapsenamespaceid, 
	                            @p_parentsynapsenamespacename, 
                                @p_attributeid,
	                            @p_attributename,                            
	                            CAST(@p_ordinal_position AS integer),
	                            @p_entityversionid,
                                @p_username,
                                @p_localentityattributeid,
                                @p_localentityattributename
                            )";



            DataTable dt       = SynapseHelpers.GetEntityDSFromID(this.hdnEntityID.Value);
            DataTable dtParent = SynapseHelpers.GetEntityDSFromID(this.ddlEntity.SelectedValue);
            DataTable dtKey    = SynapseHelpers.GetEntityKeyAttributeFromID(this.ddlEntity.SelectedValue);

            string attributename = dtKey.Rows[0]["attributename"].ToString();

            if (this.ddlLocalAttribute.SelectedIndex > 0)
            {
                attributename += "_" + this.ddlLocalAttribute.SelectedItem.Text;
            }


            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value),
                new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(this.hdnEntityID.Value)),
                new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()),
                new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()),
                new KeyValuePair <string, string>("p_parententityid", this.ddlEntity.SelectedValue),
                new KeyValuePair <string, string>("p_parententityname", this.ddlEntity.SelectedItem.Text),
                new KeyValuePair <string, string>("p_parentsynapsenamespaceid", dtParent.Rows[0]["synapsenamespaceid"].ToString()),
                new KeyValuePair <string, string>("p_parentsynapsenamespacename", dtParent.Rows[0]["synapsenamespacename"].ToString()),
                new KeyValuePair <string, string>("p_attributeid", dtKey.Rows[0]["attributeid"].ToString()),
                new KeyValuePair <string, string>("p_attributename", attributename),
                new KeyValuePair <string, string>("p_ordinal_position", this.hdnNextOrdinalPosition.Value),
                new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(this.hdnEntityID.Value)),
                new KeyValuePair <string, string>("p_username", this.hdnUserName.Value),
                new KeyValuePair <string, string>("p_localentityattributeid", this.ddlLocalAttribute.SelectedValue),
                new KeyValuePair <string, string>("p_localentityattributename", this.ddlLocalAttribute.SelectedItem.Text)
            };

            DataServices.ExcecuteNonQueryFromSQL(sql, paramList);

            ClearAttributesForm();
            this.hdnNextOrdinalPosition.Value = SynapseHelpers.GetNextOrdinalPositionFromID(this.hdnEntityID.Value);
            BindEntityGrid();

            this.lblSuccess.Text    = "Relation created";
            this.lblSuccess.Visible = true;
        }