Ejemplo n.º 1
0
    private void Save()
    {
        using (Database dbObj = Utils.GetMainDB())
        {
            // *************************************************************************
            // Update user localizations scope
            // *************************************************************************
            if (dg.Rows.Count > 0)
            {
                string updateSQL = string.Empty;
                string cultureCode;
                lbError.Visible = false;

                foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow r in dg.Rows)
                {
                    Infragistics.WebUI.UltraWebGrid.TemplatedColumn col = (Infragistics.WebUI.UltraWebGrid.TemplatedColumn)r.Cells.FromKey("Select").Column;
                    CheckBox cb = (CheckBox)((Infragistics.WebUI.UltraWebGrid.CellItem)col.CellItems[r.Index]).FindControl("g_sd");

                    cultureCode = r.Cells.FromKey("CultureCode").Text;
                    updateSQL  += "DELETE from UserCultures WHERE UserId = " + userId + " AND CultureCode='" + cultureCode + "'; ";

                    if (cb.Checked)
                    {
                        updateSQL += "INSERT INTO UserCultures(UserId, CultureCode) VALUES(" + userId + ", '" + cultureCode + "'); ";
                    }
                }

                dbObj.RunSQL(updateSQL);
                dbObj.CloseConnection();
                if (dbObj.LastError.Length > 0)
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = dbObj.LastError;
                    lbError.Visible  = true;
                }
                else
                {
                    lbError.Text     = "Data saved!";
                    lbError.CssClass = "hc_success";
                    lbError.Visible  = true;
                }
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = "No Culture found";
                lbError.Visible  = true;
            }
            UITools.RefreshTab(Page, "Cultures", Utils.GetCount(dbObj, string.Format("SELECT COUNT(*) FROM UserCultures Where UserId = {0}", userId)));
        }
    }
Ejemplo n.º 2
0
    private void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        Infragistics.WebUI.UltraWebGrid.TemplatedColumn col = (Infragistics.WebUI.UltraWebGrid.TemplatedColumn)e.Row.Cells.FromKey("Select").Column;
        CheckBox cb = (CheckBox)((Infragistics.WebUI.UltraWebGrid.CellItem)col.CellItems[e.Row.Index]).FindControl("g_sd");

        cb.Checked = Convert.ToBoolean(e.Row.Cells.FromKey("InScope").Value);

        string sIndent = string.Empty;

        Infragistics.WebUI.UltraWebGrid.UltraGridRow r = e.Row;
        for (int i = 0; i < Convert.ToInt32(r.Cells.FromKey("CultureTypeId").Value); i++)
        {
            sIndent += "&nbsp;&nbsp;&nbsp;";
        }
        r.Cells.FromKey("CultureName").Value          = sIndent + "[" + r.Cells.FromKey("CultureCode").Value + "]&nbsp;" + r.Cells.FromKey("CultureName").Value;
        r.Cells.FromKey("CultureName").Style.CssClass = "culture_" + r.Cells.FromKey("CultureTypeId").Value;
        r.Cells.FromKey("CountryCode").Value          = "<img src='/hc_v4/img/flags/" + r.Cells.FromKey("CountryCode").Value + ".gif'/>";
    }