1

Closed

UI DB: to add a button 'replicate the changes' into all screens

description

to add a button 'replicate the changes' into all screens to allow the user to replicate changes into the fields having the same Police/customs identifier
Closed Dec 28, 2009 at 11:51 AM by Abdelkrim

comments

Abdelkrim wrote May 23, 2009 at 12:08 AM

I added to controls/wuc[B-D][1-3]*.ascx
<script runat="server"> void dvB1Events_ItemCommand(object sender, DetailsViewCommandEventArgs e) { if (e.CommandName.Equals("ReplicateDataFunction")) { replicateARow(sender, e); } } </script> <asp:DetailsView ...OnItemCommand="dvB1Events_ItemCommand">

...
<asp:TemplateField>
  <ItemTemplate>
    <asp:Button ID="btnSelect" runat="server" CommandArgument='<%# Container.DisplayIndex %>'
      CommandName="ReplicateDataFunction" Text="Replicate" CssClass="button" />
  </ItemTemplate>
</asp:TemplateField>






I added this to controls/wuc[B-D][1-3]*.ascx.cs

protected void replicateARow(object sender, DetailsViewCommandEventArgs e)
{
  String myMessage = ""; //message listing the id's that have been updated
  DetailsView dv = (DetailsView)sender;
  int index = int.Parse(e.CommandArgument.ToString());

  String id = (dv.DataKey["ID"]).ToString();

  MONTRASEC_test.Classes.A_NEWENTRY_DataContext dataContext = new MONTRASEC_test.Classes.A_NEWENTRY_DataContext();

  using (System.Transactions.TransactionScope scope =
new System.Transactions.TransactionScope())
  {

  var newEntryToCopy =
      from b in dataContext.GetTable<A_NEWENTRY_>()
      where b.ID == long.Parse(id)
      select b;



  foreach (A_NEWENTRY_ c in newEntryToCopy)
  {
    var recordsToWhichToReplicate =
      from listOfRecordsToReplicate in dataContext.GetTable<A_NEWENTRY_>()
      where listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_POLICE_CUSTOMSFILEIDENTIF.Equals(c.A_NEWENTRY_NEWENTRY_POLICE_CUSTOMSFILEIDENTIF)
      && listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_PUBLICPROSECUTORSFILEIDEN.Equals(c.A_NEWENTRY_NEWENTRY_PUBLICPROSECUTORSFILEIDEN)
      && listOfRecordsToReplicate.A_NEWENTRY_NEWENTRY_COURTSFILEIDENTIFICATIONN.Equals(c.A_NEWENTRY_NEWENTRY_COURTSFILEIDENTIFICATIONN)
      && listOfRecordsToReplicate.ID != c.ID
      select listOfRecordsToReplicate;

    foreach (A_NEWENTRY_ recordToWhichToReplicate in recordsToWhichToReplicate)
    {

      recordToWhichToReplicate.B_1_EVENTS_DIGEST = c.B_1_EVENTS_DIGEST;
      recordToWhichToReplicate.B_1_EVENTS_DIGEST_NFP = c.B_1_EVENTS_DIGEST_NFP;
      recordToWhichToReplicate.B_1_EVENTS_ACTIVITIES_RECRUITMENT = c.B_1_EVENTS_ACTIVITIES_RECRUITMENT;
      ...
      recordToWhichToReplicate.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_DETERMINEDBYTHEPURSUITOFP = c.B_1_EVENTS_INDICATORSOFORGANISEDCRIM_DETERMINEDBYTHEPURSUITOFP;
      myMessage += recordToWhichToReplicate.ID + " - ";
    } //foreach




  } //foreach

  //try
  //{
  //  dataContext.Connection.Open();
  //  dataContext.Transaction = dataContext.Connection.BeginTransaction();
  //  dataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
  //  dataContext.Transaction.Commit();
  //}
  //catch (ChangeConflictException)
  //{
  //  dataContext.Transaction.Rollback();
  //}



    dataContext.SubmitChanges(ConflictMode.FailOnFirstConflict);
    scope.Complete();
  }

  if (myMessage.Length > 0)
  {
    myMessage = "Entries that have been updated - " + myMessage;
  }
  else
  {
    myMessage = "No entries have updated";
  }

  System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>");
  System.Web.HttpContext.Current.Response.Write("alert('" + myMessage + "')");
  System.Web.HttpContext.Current.Response.Write("</SCRIPT>");
}



** Closed by Abdelkrim 5/22/2009 12:41 PM

Abdelkrim wrote May 23, 2009 at 12:08 AM

There is a bug:
-service unavailalbe
-to check the event logs for more details

wrote Dec 28, 2009 at 11:51 AM

wrote Feb 13, 2013 at 7:23 PM

wrote May 14, 2013 at 7:29 AM