Beispiel #1
0
        protected void DetailsObjectDataSource_OnUpdated(object sender, ObjectDataSourceStatusEventArgs e)
        {
            ClaimSparesListDataSource.DeleteMethod = "DeleteRecord";
            ClaimSparesListDataSource.DeleteParameters.Add("ID_ClaimSparesList", "0");
            ClaimSparesListDataSource.InsertMethod = "InsertRecord";
            ClaimSparesListDataSource.InsertParameters.Clear();
            try
            {
                ClaimSparesListDataSource.InsertParameters.Add("ID_Claim", GridView.SelectedValue.ToString());
            }
            catch (Exception)
            { Msg.Text = "Вновь создаваемая запись, невозможно обновить"; }
            ClaimSparesListDataSource.InsertParameters.Add("ID_Spares", "0");
            for (int i = 0; i < CheckBoxDevice.Items.Count; i++)
            {
                for (int j = 0; j < ListClaimSpares.Rows.Count; j++)
                {
                    if (ListClaimSpares.Rows[j].Cells[3].Text == CheckBoxDevice.Items[i].Value && CheckBoxDevice.Items[i].Selected == false)
                    {
                        ClaimSparesListDataSource.DeleteParameters["ID_ClaimSparesList"].DefaultValue = ListClaimSpares.Rows[j].Cells[0].Text;
                        ClaimSparesListDataSource.Delete();   // удаляем запись
                    }
                }
            }

            for (int i = 0; i < CheckBoxSpares.Items.Count; i++)
            {
                bool k = new bool();
                k = false;
                for (int j = 0; j < ListClaimSpares.Rows.Count; j++)
                {
                    if (ListClaimSpares.Rows[j].Cells[2].Text == CheckBoxSpares.Items[i].Value && CheckBoxSpares.Items[i].Selected == false)
                    {
                        ClaimSparesListDataSource.DeleteParameters["ID_ClaimSparesList"].DefaultValue = ListClaimSpares.Rows[j].Cells[0].Text;
                        ClaimSparesListDataSource.Delete();   // удаляем запись
                    }
                    if (ListClaimSpares.Rows[j].Cells[2].Text == CheckBoxSpares.Items[i].Value && CheckBoxSpares.Items[i].Selected == true)
                    {
                        k = true;
                    }
                }
                if (CheckBoxSpares.Items[i].Selected == true && k == false)
                {
                    ClaimSparesListDataSource.InsertParameters["ID_Spares"].DefaultValue = CheckBoxSpares.Items[i].Value;
                    ClaimSparesListDataSource.Insert();
                }
            }
            GridView.DataBind();
            if ((int)e.ReturnValue == 0)
            {
                Msg.Text = "Employee was not updated. Please try again.";
            }
        }
Beispiel #2
0
        protected void DetailsObjectDataSource_OnInserted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            string ID_Claim = "0";

            ID_Claim = e.ReturnValue.ToString();
            ClaimSparesListDataSource.InsertMethod = "InsertRecord";
            ClaimSparesListDataSource.InsertParameters.Clear();
            ClaimSparesListDataSource.InsertParameters.Add("ID_Claim", ID_Claim);
            ClaimSparesListDataSource.InsertParameters.Add("ID_Spares", null);
            for (int i = 0; i < CheckBoxSpares.Items.Count; i++)
            {
                if (CheckBoxSpares.Items[i].Selected == true)
                {
                    ClaimSparesListDataSource.InsertParameters["ID_Spares"].DefaultValue = CheckBoxSpares.Items[i].Value;
                    ClaimSparesListDataSource.Insert();
                }
            }
        }