Exemple #1
0
    protected void CheckIsActive_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox Chk = sender as CheckBox;

        //Secilen setirin rengini deyishek
        GridViewRow row = (GridViewRow)Chk.Parent.Parent;

        row.BackColor = Color.FromName("#bbffc7");

        _SelectedTableName = Session["SelectedTable"]._ToString();
        DataListType       = (Tools.Table)Enum.Parse(typeof(Tools.Table), _SelectedTableName);

        Dictionary <string, object> Dictionary = new Dictionary <string, object>()
        {
            { "IsActive", !Chk.Checked },
            { "WhereID", int.Parse(Chk.Attributes["data-id"]) }
        };

        int Check = DALC.UpdateDatabase(DataListType, Dictionary);

        if (Check < 1)
        {
            Config.MsgBoxAjax(Config._DefaultErrorMessages);
            return;
        }
    }
Exemple #2
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        DataListType = (Tools.Table)Enum.Parse(typeof(Tools.Table), _SelectedTableName);

        TxtDataListsName.BorderColor = Color.Empty;
        if (string.IsNullOrEmpty(TxtDataListsName.Text))
        {
            TxtDataListsName.BorderColor = Color.Red;
            return;
        }
        Dictionary <string, object> Dictionary = new Dictionary <string, object>()
        {
            { "Name", TxtDataListsName.Text },
            { "Priority", 0 },
            { "IsActive", true }
        };

        int Check = 0;

        Check = DALC.InsertDatabase(DataListType, Dictionary);
        if (Check < 1)
        {
            Config.MsgBoxAjax(Config._DefaultErrorMessages);
            return;
        }
        TxtDataListsName.Text = "";
        BindGridDataLists();
    }
Exemple #3
0
 private void BindGridDataLists()
 {
     if (string.IsNullOrEmpty(_SelectedTableName))
     {
         GrdDataLists.DataSource = null;
         GrdDataLists.DataBind();
     }
     else
     {
         DataListType            = (Tools.Table)Enum.Parse(typeof(Tools.Table), _SelectedTableName);
         GrdDataLists.DataSource = DALC.GetList(DataListType, "Order By Priority asc,IsActive desc");
         GrdDataLists.DataBind();
         Session["SelectedTable"] = _SelectedTableName;
     }
 }
Exemple #4
0
    public static void BindControls(this Control Panel, Dictionary <string, object> FilterDictionary, Tools.Table TableName, bool ClearSession = false)
    {
        string SessionName = TableName._ToString();

        if (ClearSession)
        {
            HttpContext.Current.Session[SessionName] = null;
        }
        if (HttpContext.Current.Session[SessionName] != null)
        {
            if (FilterDictionary.Count < 1)
            {
                FilterDictionary = (Dictionary <string, object>)HttpContext.Current.Session[SessionName];
            }
            foreach (Control item in Panel.Controls)
            {
                if (item.HasControls())
                {
                    BindControls(item, FilterDictionary, TableName);
                }

                try
                {
                    if (item is TextBox)
                    {
                        TextBox Txt = item as TextBox;
                        Txt.Text = FilterDictionary[Txt.ID]._ToString();
                    }
                    else if (item is DropDownList)
                    {
                        DropDownList DList = item as DropDownList;
                        DList.SelectedValue = FilterDictionary[DList.ID]._ToString();
                    }
                    else if (item is ListBox)
                    {
                        ListBox LstBx = item as ListBox;
                        for (int i = 0; i < LstBx.Items.Count; i++)
                        {
                            ListItem Item = LstBx.Items[i];
                            if (FilterDictionary[LstBx.ID]._ToString().IndexOf(Item.Value) > -1)
                            {
                                Item.Selected = true;
                            }
                        }
                    }
                    else if (item is CheckBox)
                    {
                        CheckBox Check = item as CheckBox;
                        Check.Checked = (bool)FilterDictionary[Check.ID];
                    }
                }
                catch
                {
                    HttpContext.Current.Session[SessionName] = null;
                    FilterDictionary.Clear();
                    BindControls(Panel, FilterDictionary, TableName);
                }
            }
        }
        else
        {
            foreach (Control item in Panel.Controls)
            {
                if (item.HasControls())
                {
                    BindControls(item, FilterDictionary, TableName, true);
                }

                if (item is TextBox)
                {
                    TextBox Txt = item as TextBox;
                    FilterDictionary.Add(Txt.ID, Txt.Text);
                }
                else if (item is DropDownList)
                {
                    DropDownList DList = item as DropDownList;
                    FilterDictionary.Add(DList.ID, DList.SelectedValue);
                }
                else if (item is ListBox)
                {
                    ListBox       LstBx  = item as ListBox;
                    StringBuilder Values = new StringBuilder();
                    for (int i = 0; i < LstBx.Items.Count; i++)
                    {
                        ListItem Item = LstBx.Items[i];
                        if (Item.Selected)
                        {
                            Values.Append(Item.Value + ",");
                        }
                    }
                    FilterDictionary.Add(LstBx.ID, Values._ToString().Trim(','));
                }
                else if (item is CheckBox)
                {
                    CheckBox Check = item as CheckBox;
                    FilterDictionary.Add(Check.ID, Check.Checked);
                }
            }
            HttpContext.Current.Session[SessionName] = FilterDictionary;
        }
    }