Skip to main content

Microsoft Silverlight

update changes in databaseRSS Feed

(0)

sreeka
sreeka

Member

Member

20 points

23 Posts

update changes in database

hi there, i am working in gantt chart. i cant able to update my changes to database...help plz

varshavmane
varshavmane

Contributor

Contributor

6719 points

1,578 Posts

Re: update changes in database

Hi,

How you are updating your database ? Can you post your code ?

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

sreeka
sreeka

Member

Member

20 points

23 Posts

Re: update changes in database

hi,

here is my code...i am using linq+dbml+wcf...

not having any control for datagrid in design..instead generating it using a class file...plz help 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using System.Text;

using System.Windows.Data;

using System.ComponentModel;

using System.IO.IsolatedStorage;

using System.Windows.Browser;

using System.Reflection;

using LinqToSqlClientHelper;

using System.Collections.ObjectModel;

using TaskGantt.PMOGSRef;

using CoderForRent.Silverlight.Charting.Gantt;

namespace TaskGantt

{

public partial class Page : UserControl

{

#region Declarations

List<ProjectTaskGanttChart> unsortedList = new List<ProjectTaskGanttChart>();

PMOGanttServiceClient client = new PMOGanttServiceClient();

ObservableCollection<ProjectTaskGanttChart> project = new ObservableCollection<ProjectTaskGanttChart>();

ObservableCollection<GanttNode> node = new ObservableCollection<GanttNode>();

List<GanttNode> unsort = new List<GanttNode>();

ProjectTaskGanttChart[] retResult;

#endregion

#region
Constructorpublic Page()

{

InitializeComponent();

//gantt.GeneratingGanttPanelColumn += new CoderForRent.Silverlight.Charting.Gantt.GanttPanelColumnHandler(gantt_GeneratingGanttPanelColumn);

gantt.ColumnGeneratingType = typeof(GanttNode);//to display grid datas

gantt.Loaded += gantt_Loaded;

Loaded += new RoutedEventHandler(Page_Loaded);//popupTN

Loaded += new RoutedEventHandler(Page_Loaded1);//popupSTN1

}

#endregion

#region Popup

#region PopUpTNvoid Page_Loaded(object sender, RoutedEventArgs e)

{

ShowPopupTN.Click += new RoutedEventHandler(ShowPopup_Click);

ClosePopup.Click += new RoutedEventHandler(ClosePopup_Click);

}

void ClosePopup_Click(object sender, RoutedEventArgs e)

{

MyPopupTN.IsOpen =
false;

}

void ShowPopup_Click(object sender, RoutedEventArgs e)

{

MyPopupTN.IsOpen =
true;

}

private void TSave_Click(object sender, RoutedEventArgs e)

{

 

client.RowAddCompleted +=
new EventHandler<AsyncCompletedEventArgs>(client_RowAddCompleted);

GanttNode result = new GanttNode

{

TaskName = tTaskName.Text,

StartDate =
Convert.ToDateTime(tStartDate.Text),

EndDate = Convert.ToDateTime(tEndDate.Text),

Resources = tResource.Text,

Expanded = true //for expand/colapse in left column ---default "false"

};

 

if (TSave.IsPressed)

{

node.Add(
new GanttNode()

{

State =
RowState.Inserted

});

}

node.Add(result);

var inserted = (from i in node

where i.State == RowState.Inserted

select NodeToTask1(i)).ToArray();

 

client.RowAddAsync(inserted);

}

void client_RowAddCompleted(object sender, AsyncCompletedEventArgs e)

{

Tlabel.Text =
"Details successfully Inserted";

}

#endregion

 

#region PopUpSTN1void Page_Loaded1(object sender, RoutedEventArgs e)

{

ShowPopupSTN1.Click += new RoutedEventHandler(ShowPopupSTN1_Click);

stClosePopup1.Click += new RoutedEventHandler(stClosePopup1_Click);

}

void stClosePopup1_Click(object sender, RoutedEventArgs e)

{

MyPopupSTN1.IsOpen =
false;

}

void ShowPopupSTN1_Click(object sender, RoutedEventArgs e)

{

MyPopupSTN1.IsOpen =
true;

}

private void STSave_Click(object sender, RoutedEventArgs e)

{

}

#endregion

#endregion

#region
GanttLoadvoid gantt_GeneratingGanttPanelColumn(object sender, CoderForRent.Silverlight.Charting.Gantt.GanttPanelColumnEventArgs e)

{

bool important = false;

//if it's the first of the month, add month separator

if (e.Column.RepresentedDate.Day == 1)

{

e.Column.BorderThickness =
new Thickness(1, 0, 0, 0);

e.Column.BorderBrush = new SolidColorBrush(Colors.Gray);

important = true;

}

//If weekend, then gray background.

if (e.Column.RepresentedDate.DayOfWeek == DayOfWeek.Saturday || e.Column.RepresentedDate.DayOfWeek == DayOfWeek.Sunday)

{

e.Column.Background =
new SolidColorBrush(Colors.LightGray);important = true;

}

if (!important)

{

e.Column.Background = new SolidColorBrush(Colors.Transparent);

e.Cancel = true;

}

}

private void gantt_Loaded(object sender, RoutedEventArgs e)

{

client.FetchProjectTaskGanttChartCompleted += ((s, e2) =>

{

TaskGantt.PMOGSRef.
ProjectTaskGanttChart[] tasks = e2.Result;

 

 

foreach (ProjectTaskGanttChart t in tasks)

{

unsortedList.Add(t);

}

foreach (ProjectTaskGanttChart t in tasks)

{

if (t.ProjectTaskID == t.ParentTaskID)

{

node.Add(ConvertTaskToNode(t));

}

}

gantt.Node = node;

});

client.FetchProjectTaskGanttChartAsync();

}

private GanttNode ConvertTaskToNode(ProjectTaskGanttChart t)

{

GanttNode result = new GanttNode

{

ProjectTaskID=
Convert.ToInt32(t.ProjectTaskID),

TaskName = t.TaskName,

StartDate =
Convert.ToDateTime(t.StartDate),EndDate = Convert.ToDateTime(t.EndDate),

Resources = t.ResourceName,

PercentComplete = Convert.ToDouble(t.PercentageCompleted),

Expanded = true //for expand/colapse in left column ---default "false"

};

var children = unsortedList.Where(x => x.ParentTaskID == t.ProjectTaskID && x.ProjectTaskID != t.ProjectTaskID);

// add the child to the item's children collection and call the FindChildren recursively, in case the child has children

foreach (ProjectTaskGanttChart child in children)

{

result.ChildNode.Add(ConvertTaskToNode(child));//new try

}

return result;

}

#endregion

#region
GanttSaveprivate void Save_Click(object sender, RoutedEventArgs e)

{

client.RowChangeCompleted += new EventHandler<AsyncCompletedEventArgs>(client_RowChangeCompleted);

var updated = (from u in node

where u.State == RowState.Modified

select NodeToTask(u)).ToArray();

client.RowChangeAsync(updated);

}

void client_RowChangeCompleted(object sender, AsyncCompletedEventArgs e)

{

label.Text =
"Details successfully updated";

}

private ProjectTaskGanttChart NodeToTask(GanttNode t)

{

ProjectTaskGanttChart task = new ProjectTaskGanttChart()

{

ProjectTaskID = t.ProjectTaskID,

TaskName = t.TaskName,

StartDate = t.StartDate,

EndDate = t.EndDate,

ResourceName = t.Resources,

PercentageCompleted =
Convert.ToInt32(t.PercentComplete)

};

return task;

}

 

#endregion

}

}

 

varshavmane
varshavmane

Contributor

Contributor

6719 points

1,578 Posts

Re: Re: update changes in database

Hi,

I am not able to understand your code as its very hude. You can check this links:

http://www.aspfree.com/c/a/Windows-Scripting/Database-operations-using-Silverlight-20-WCF-and-LINQ-to-SQL/

http://silverlight.net/forums/p/50997/133892.aspx

http://www.asp.net/learn/videos/video-235.aspx

HTH Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

sreeka
sreeka

Member

Member

20 points

23 Posts

Re: Re: update changes in database

Hi varsha,

sorry.. and thanks for ur response...

i have seen all these links...i am using the gantt chart user control..i need update the changes to the database...i coundnt find solution anywhere....

Thanks & Regards,

Sreeka

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities