using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QW2021C.Resultate
{
    public partial class KategoriençKUKC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void GridDaten_ServerBatchEditRow(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
        {
            ArrayList changed = ((ArrayList)((Dictionary<String, Object>)e.Arguments["batchChanges"])["changed"]);
            if (changed.Count > 0)
                GridAction("change", changed, e);
        }

        protected void GridAction(string eventType, ArrayList changed, Syncfusion.JavaScript.Web.GridEventArgs e)
        {
            clsDB db = new clsDB();
            if (eventType == "change")
            {
                res_disziplin_select value = new res_disziplin_select();

                for (var i = 0; i <= changed.Count - 1; i++)
                {
                    Dictionary<string, object> KeyVal = changed[i] as Dictionary<string, object>;

                    foreach (KeyValuePair<string, object> keyvals in KeyVal)
                    {
                        if (keyvals.Key == "Res_Diszipllin_SelectNr") value.Res_Diszipllin_SelectNr = Convert.ToInt32(keyvals.Value);
                        if (keyvals.Key == "OrtNr") value.OrtNr = Convert.ToInt32(keyvals.Value);
                        if (keyvals.Key == "Kategorie") value.Kategorie = keyvals.Value.ToString();
                        if (keyvals.Key == "Disziplin") value.Disziplin = keyvals.Value.ToString();
                        if (keyvals.Key == "QW") value.QW = Convert.ToBoolean(keyvals.Value);
                        if (keyvals.Key == "EG") value.EG = Convert.ToBoolean(keyvals.Value);
                    }
                    db.Get_Tabeldata_for_Update("Select * from res_disziplin_select  where [Res_Diszipllin_SelectNr]=" + value.Res_Diszipllin_SelectNr.ToString(), false, true);
                    db.dsdaten.Tables[0].Rows[0]["Res_Diszipllin_SelectNr"] = value.Res_Diszipllin_SelectNr;
                    db.dsdaten.Tables[0].Rows[0]["OrtNr"] = value.OrtNr;
                    db.dsdaten.Tables[0].Rows[0]["Kategorie"] = value.Kategorie;
                    db.dsdaten.Tables[0].Rows[0]["Disziplin"] = value.Disziplin;
                    db.dsdaten.Tables[0].Rows[0]["QW"] = value.QW;
                    db.dsdaten.Tables[0].Rows[0]["EG"] = value.EG;
                    db.Update_Tabeldata();

                }

                // Dim update As Orders = order.Where(Function(ord) ord.code = value.code).FirstOrDefault()
                // update.isSelected = value.isSelected
                this.GridDaten.DataBind();
                
            }
        }

    }
    public class res_disziplin_select
    {
        public int Res_Diszipllin_SelectNr { get; set; }

        public int? OrtNr { get; set; }

        public string Kategorie { get; set; }

        public string Disziplin { get; set; }

        public bool? QW { get; set; }

        public bool? EG { get; set; }

    }
}