Пример #1
0
        protected void DataSource_OnInserted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            string ID_NewDevice;

            ID_NewDevice = Convert.ToString(e.ReturnValue);
            if (TreeViewUpdate.CheckedNodes.Count > 0)
            {
                Msg.Text = "Цикл TreeViewUpdate.CheckedNodes.Count";
                for (int i = 0; i < TreeViewUpdate.CheckedNodes.Count; i++)
                {
                    if (i == 0)
                    {
                        Msg.Text = "Update";
                        TreeDeviceObjectDataSource.UpdateMethod = "UpdateRecord_Device_list";
                        TreeDeviceObjectDataSource.UpdateParameters.Clear();
                        TreeDeviceObjectDataSource.UpdateParameters.Add("ID_Device", TreeViewUpdate.CheckedNodes[i].Value);
                        TreeDeviceObjectDataSource.UpdateParameters.Add("ID_NewDevice", ID_NewDevice);
                        TreeDeviceObjectDataSource.Update();
                    }
                    else
                    {
                        Msg.Text = "iNSEERT";
                        TreeDeviceObjectDataSource.InsertMethod = "InsertRecord_Device_list";
                        TreeDeviceObjectDataSource.InsertParameters.Clear();
                        TreeDeviceObjectDataSource.InsertParameters.Add("ID_Device", TreeViewUpdate.CheckedNodes[i].Value);
                        TreeDeviceObjectDataSource.InsertParameters.Add("ID_NewDevice", ID_NewDevice);
                        TreeDeviceObjectDataSource.Insert();
                    }
                }
            }
        }
Пример #2
0
        protected void DataSource_OnUpdated(object sender, ObjectDataSourceStatusEventArgs e)
        {
            string ID_NewDevice;

            ID_NewDevice = GridDevice.SelectedValue.ToString();
            if (TreeViewUpdate.CheckedNodes.Count > 0)
            {
//                Msg.Text = "Цикл TreeViewUpdate.CheckedNodes.Count";
                for (int i = 0; i < TreeViewUpdate.CheckedNodes.Count; i++)
                {
                    Msg.Text += " if count";
                    if (CheckBoxParent.Items.Count == 0)
                    {
//                        Msg.Text += " UpdateU";
                        TreeDeviceObjectDataSource.UpdateMethod = "UpdateRecord_Device_list";
                        TreeDeviceObjectDataSource.UpdateParameters.Clear();
                        TreeDeviceObjectDataSource.UpdateParameters.Add("ID_NewDevice", TreeViewUpdate.CheckedNodes[i].Value);
                        TreeDeviceObjectDataSource.UpdateParameters.Add("ID_Device", ID_NewDevice);
                        TreeDeviceObjectDataSource.Update();
                    }
                    else if (CheckBoxParent.Items.Count != 0)
                    {
//                        Msg.Text += "iNSEERTU";
                        TreeDeviceObjectDataSource.InsertMethod = "InsertRecord_Device_list";
                        TreeDeviceObjectDataSource.InsertParameters.Clear();
                        TreeDeviceObjectDataSource.InsertParameters.Add("ID_NewDevice", TreeViewUpdate.CheckedNodes[i].Value);
                        TreeDeviceObjectDataSource.InsertParameters.Add("ID_Device", ID_NewDevice);
                        TreeDeviceObjectDataSource.Insert();
                    }
                }
            }
            // удаление по крыжикам чекбокса
            for (int j = 0; j < CheckBoxParent.Items.Count; j++)
            {
                if (CheckBoxParent.Items[j].Selected == false)
                {
                    TreeDeviceObjectDataSource.DeleteMethod = "DeleteRecord_Device_list";
                    TreeDeviceObjectDataSource.DeleteParameters.Clear();
                    TreeDeviceObjectDataSource.DeleteParameters.Add("ID_Device", CheckBoxParent.Items[j].Value);
                    TreeDeviceObjectDataSource.DeleteParameters.Add("ID_NewDevice", ID_NewDevice);
                    TreeDeviceObjectDataSource.Delete();
//                    Msg.Text += " Delete";
                }
            }
//            ModalPopupExtender1.Show();
            TreeView1.Nodes.Clear();
            PopulateRootLevel();
        }