GridView and DataTable

Please support our ASP.NET advertiser: 50% Off 6 Months Web Hosting from 1&1. The World's #1 Host!
Thread Solved

Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

GridView and DataTable

 
0
  #1
Aug 26th, 2009
Hi Guys

I have a GridView th show my data.

When I am including the data I have TextBox and DropDownList.Thesse data are going to populate a GridView using a DataTble.

In the update routine I populate the GridView with the recorded data but I can keep on including other data.In this case my DataTable is going to populate the Gridview with the last data only.

I need to show all records.The before ones (saved ones) and the new ones thar are not saved yet.

How can I do it my friends?



Thanks a lot and sorry for my English.



Regards
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,793
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 698
Sponsor
Featured Poster
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: GridView and DataTable

 
0
  #2
Aug 26th, 2009
Can you upload a project demonstrating the difficulties you're having? I don't follow where you are going. If the DataTable contains all of the data and you want to show all of the data -- then problem solved, right?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

Re: GridView and DataTable

 
0
  #3
Aug 26th, 2009
Thanks a lot for your help my friend.

You are sure.In first moment I have all the data in the DataTable then I saved then and finish my work.

But in the other side I need to show the saved data in a GridView.But I need to insert another data in the GridView before saving.

Then I intend to use a DataTable again only to insert these new data maintain the saved data in the Grid.

In one moment I will have saved data in the grid and data from the DataTable.

Maybe there´s a simple way to solve this problem but I don´t know any.

If there´s a simples way to solve this problem, please let me know.

I just need a solution I just need to use a DataTable.I need the best solution.

Because i am totally lost.

Thanks a lot my friend
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,793
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 698
Sponsor
Featured Poster
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: GridView and DataTable

 
0
  #4
Aug 26th, 2009
I still don't understand

>>In first moment I have all the data in the DataTable then I saved then and finish my work.
OK -- At this point we have a DataTable which contains multiple rows. All of the rows have been saved to the database, right?

>>But in the other side I need to show the saved data in a GridView.But I need to insert another data in the GridView before saving.
other side?

Need to show the saved data in a GridView?
Per the earlier commend you saved everything -- so that would be everything, right?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

Re: GridView and DataTable

 
0
  #5
Aug 27th, 2009
Hi my friend, how are you today?
Is that ok with you?
I have another problem.It´s my English.
I am from Brazil and sometimes I can´t explain in English what really happing.

But I am going to try this time.

1 - >>In first moment I have all the data in the DataTable then I saved then and finish my work.
OK -- At this point we have a DataTable which contains multiple rows. All of the rows have been saved to the database, right?

Yes in the case above I have been saved all rows to the database.


2 - >>But in the other side I need to show the saved data in a GridView.But I need to insert another data in the GridView before saving.
other side?

Need to show the saved data in a GridView?
Per the earlier commend you saved everything -- so that would be everything, right?


In this case, after saved any kind of data we need to show it. You agree with me don´t you?

Then I need to show the saved data in a Gridview.
I am going to do it in a update routine.It´s normal.

But in this situation I can insert new rows on GridView.Then I will have the saved data and the new rows.

In the end I need to save only the new rows for the old data already have been saved before.

I just need to solve this problem.I dont´t do it this way but I need to do it any way.

If you have a better idea just let me know.
By the way, where are you from my friend?

Thanks for your support again

Regards

Sidnei
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 164
Reputation: dnanetwork has a little shameless behaviour in the past 
Solved Threads: 24
dnanetwork's Avatar
dnanetwork dnanetwork is offline Offline
Junior Poster

Re: GridView and DataTable

 
0
  #6
Aug 27th, 2009
i don't get it...it's really complicated..

can i have lok at u r code...
Mark the thread as resolved if your problem gets resolved :)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

Re: GridView and DataTable

 
0
  #7
Aug 27th, 2009
Here is the code it´s a mess.

HTML Code :
  1. <%@ Page Language="VB" MasterPageFile="~/master/default.master" AutoEventWireup="false" CodeFile="Projetos.aspx.vb" Inherits="Admin_Projetos" title="NewCad Engenharia Ltda" %>
  2.  
  3.  
  4. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceholder1" Runat="Server">
  5.  
  6. <h1>
  7. Projetos</h1>
  8. <asp:ScriptManager ID="ScriptManager1" runat="server">
  9. </asp:ScriptManager>
  10.  
  11. <fieldset>
  12. <asp:Label ID="LblUserLoginID" runat="server" Width="106px" Visible="False"></asp:Label>
  13. <asp:Label ID="LblUserLoginIDDoc" runat="server" Width="106px"></asp:Label><br />
  14. <br />
  15. <table>
  16. <tr>
  17. <td style="width: 101px">
  18. <asp:Label ID="Label1" runat="server" Text="Data" Width="102px"></asp:Label></td>
  19. <td style="width: 87px">
  20. <asp:TextBox ID="TxtData" runat="server" Enabled="False" Width="77px"></asp:TextBox></td>
  21. <td style="width: 89px">
  22. </td>
  23. </tr>
  24. <tr>
  25. <td style="width: 101px">
  26. <asp:Label ID="Label2" runat="server" Text="Cliente" Width="102px"></asp:Label></td>
  27. <td style="width: 87px">
  28. <asp:DropDownList ID="CboCliente" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
  29. Width="337px">
  30. </asp:DropDownList>
  31. </td>
  32. <td style="width: 89px">
  33. <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="CboCliente"
  34. ErrorMessage="*" InitialValue="Selecione o Cliente" ValidationGroup="ValProjeto">*</asp:RequiredFieldValidator></td>
  35. </tr>
  36. <tr>
  37. <td style="width: 101px; height: 24px;">
  38. <asp:Label ID="Label3" runat="server" Text="Projeto" Width="102px"></asp:Label></td>
  39. <td style="width: 87px; height: 24px;">
  40. <asp:DropDownList ID="CboProjeto" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
  41. Width="337px">
  42. </asp:DropDownList>
  43. </td>
  44. <td style="width: 89px; height: 24px;">
  45. <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="CboProjeto"
  46. ErrorMessage="*" InitialValue="Selecione o Projeto" ValidationGroup="ValProjeto">*</asp:RequiredFieldValidator></td>
  47. </tr>
  48. <tr>
  49. <td style="width: 101px">
  50. <asp:Label ID="Label4" runat="server" Text="Gerente do Cliente" Width="156px"></asp:Label></td>
  51. <td style="width: 87px">
  52. <asp:DropDownList ID="CboGerenteCliente" runat="server" AppendDataBoundItems="True"
  53. AutoPostBack="True" Width="337px">
  54. </asp:DropDownList>
  55. </td>
  56. <td style="width: 89px">
  57. <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="CboGerenteCliente"
  58. ErrorMessage="*" InitialValue="Selecione o Cliente" ValidationGroup="ValProjeto">*</asp:RequiredFieldValidator></td>
  59. </tr>
  60. <tr>
  61. <td style="width: 101px; height: 21px;">
  62. <asp:Label ID="Label5" runat="server" Text="O.S. Cliente" Width="102px"></asp:Label></td>
  63. <td style="width: 87px; height: 21px;">
  64. <asp:TextBox ID="TxtOS" runat="server" MaxLength="25" Width="256px"></asp:TextBox>
  65. </td>
  66. <td style="width: 89px; height: 21px;">
  67. <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TxtOS"
  68. ErrorMessage="*" ValidationGroup="ValProjeto"></asp:RequiredFieldValidator></td>
  69. </tr>
  70. <tr>
  71. <td style="width: 101px">
  72. <asp:Label ID="Label6" runat="server" Text="Conta Gestor" Width="102px"></asp:Label></td>
  73. <td style="width: 87px">
  74. <asp:TextBox ID="TxtContaGestor" runat="server" Enabled="False" ValidationGroup="ValProjeto"></asp:TextBox></td>
  75. <td style="width: 89px">
  76. </td>
  77. </tr>
  78. <tr>
  79. <td style="width: 101px">
  80. <asp:Label ID="Label8" runat="server" Text="Gerente Responsável" Width="156px"></asp:Label></td>
  81. <td style="width: 87px">
  82. <asp:DropDownList ID="CboGerente" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
  83. Width="337px">
  84. </asp:DropDownList>
  85. </td>
  86. <td style="width: 89px">
  87. <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="CboGerente"
  88. ErrorMessage="*" InitialValue="Selecione o Gerente" ValidationGroup="ValProjeto">*</asp:RequiredFieldValidator></td>
  89. </tr>
  90. <tr>
  91. <td style="width: 101px">
  92. <asp:Label ID="Label7" runat="server" Text="Lider de Disciplina" Width="156px"></asp:Label></td>
  93. <td style="width: 87px"><asp:DropDownList ID="CboLiderDisc" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
  94. Width="337px">
  95. </asp:DropDownList>
  96. </td>
  97. <td style="width: 89px">
  98. <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="CboLiderDisc"
  99. ErrorMessage="*" InitialValue="Selecione o Gerente" ValidationGroup="ValProjeto"></asp:RequiredFieldValidator></td>
  100. </tr>
  101. <tr>
  102. <td style="width: 101px">
  103. </td>
  104. <td style="width: 87px">
  105. <asp:Button ID="Button4" runat="server" Text="Atualizar" ValidationGroup="ValProjeto" /></td>
  106. <td style="width: 89px">
  107. </td>
  108. </tr>
  109. <tr>
  110. <td style="width: 101px; height: 21px;">
  111. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
  112. </td>
  113. <td style="width: 87px; height: 21px;">
  114. </td>
  115. <td style="width: 89px; height: 21px;">
  116. </td>
  117. </tr>
  118. <tr>
  119. <td style="width: 101px; height: 26px;">
  120. <asp:Label ID="Label9" runat="server" Text="Nr.Documento" Width="156px"></asp:Label></td>
  121. <td style="width: 87px; height: 26px;">
  122. <asp:TextBox ID="TxtDocumento" runat="server" Enabled="False" MaxLength="25" ValidationGroup="ValDocumento"
  123. Width="256px"></asp:TextBox></td>
  124. <td style="width: 89px; height: 26px;">
  125. <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="TxtDocumento"
  126. ErrorMessage="*" ValidationGroup="ValDoc"></asp:RequiredFieldValidator></td>
  127. </tr>
  128. <tr>
  129. <td style="width: 101px; height: 3px;">
  130. <asp:Label ID="Label10" runat="server" Text="Formato" Width="156px"></asp:Label></td>
  131. <td style="width: 87px; height: 3px;">
  132. <asp:DropDownList ID="CboFormato" runat="server" AutoPostBack="True" Enabled="False" Width="259px">
  133. </asp:DropDownList></td>
  134. <td style="width: 89px; height: 3px;">
  135. <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="CboFormato"
  136. ErrorMessage="*" ValidationGroup="ValDoc"></asp:RequiredFieldValidator></td>
  137. </tr>
  138. <tr>
  139. <td style="width: 101px">
  140. <asp:Label ID="Label11" runat="server" Text="Previsão de Inicio" Width="156px"></asp:Label></td>
  141. <td style="width: 87px">
  142. <asp:TextBox ID="TxtInicioPrevisto" runat="server" ValidationGroup="ValDocumento"
  143. Width="85px"></asp:TextBox>
  144. <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" Mask="99/99/9999"
  145. MaskType="Date" TargetControlID="TxtInicioPrevisto">
  146. </ajaxToolkit:MaskedEditExtender>
  147. </td>
  148. <td style="width: 89px">
  149. <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator2" runat="server" ControlExtender="MaskedEditExtender1"
  150. ControlToValidate="TxtInicioPrevisto" Display="Dynamic" EmptyValueMessage="Informe a Data"
  151. InvalidValueMessage="Data Inválida" IsValidEmpty="false"></ajaxToolkit:MaskedEditValidator></td>
  152. <tr>
  153. <td style="width: 101px">
  154. <asp:Label ID="Label12" runat="server" Text="Previsão de Término" Width="156px"></asp:Label></td>
  155. <td style="width: 87px">
  156. <asp:TextBox ID="TxtTerminoPrevisto" runat="server" ValidationGroup="ValDocumento"
  157. Width="85px"></asp:TextBox>
  158. <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2" runat="server" Mask="99/99/9999"
  159. MaskType="Date" TargetControlID="TxtTerminoPrevisto">
  160. </ajaxToolkit:MaskedEditExtender>
  161. </td>
  162. <td style="width: 89px">
  163. <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlExtender="MaskedEditExtender1"
  164. ControlToValidate="TxtTerminoPrevisto" Display="Dynamic" EmptyValueMessage="Informe a Data"
  165. InvalidValueMessage="Data Inválida" IsValidEmpty="false"></ajaxToolkit:MaskedEditValidator></td>
  166. </tr>
  167. <tr>
  168. <td style="width: 101px; height: 21px;">
  169. <asp:Label ID="Label13" runat="server" Text="Especialidade" Width="156px"></asp:Label></td>
  170. <td style="width: 87px; height: 21px;">
  171. <asp:DropDownList ID="CboEspecialidade" runat="server" AutoPostBack="True" Enabled="False" Width="272px">
  172. </asp:DropDownList></td>
  173. <td style="width: 89px; height: 21px;">
  174. <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="CboEspecialidade"
  175. ErrorMessage="*" ValidationGroup="ValDoc"></asp:RequiredFieldValidator></td>
  176. </tr>
  177. <tr>
  178. <td style="width: 101px">
  179. <asp:Label ID="Label15" runat="server" Text="Horas Previstas" Width="156px"></asp:Label></td>
  180. <td style="width: 87px">
  181. <asp:TextBox ID="TxtHorasPrevistas" runat="server" Width="37px"></asp:TextBox>
  182. <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender4" runat="server" AutoComplete="False"
  183. Mask="99" MaskType="Number" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
  184. OnInvalidCssClass="MaskedEditError" TargetControlID="TxtHorasPrevistas">
  185. </ajaxToolkit:MaskedEditExtender>
  186. </td>
  187.  
  188.  
  189. <td style="width: 89px">
  190. <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator4" runat="server" ControlExtender="MaskedEditExtender4"
  191. ControlToValidate="TxtHorasPrevistas" Display="Dynamic" EmptyValueMessage="Horas Requeridas"
  192. InvalidValueMessage="Horas Requeridas" IsValidEmpty="false" TooltipMessage=" "></ajaxToolkit:MaskedEditValidator></td>
  193. </tr>
  194. <tr>
  195. <td style="width: 101px">
  196. <asp:Label ID="Label14" runat="server" Text="Colaborador" Width="156px"></asp:Label></td>
  197. <td style="width: 87px">
  198. <asp:DropDownList ID="CboColaborador" runat="server" AutoPostBack="True" DataTextField=" "
  199. DataValueField=" " Enabled="False" ValidationGroup="ValDoc" Width="350px">
  200. </asp:DropDownList></td>
  201. <td style="width: 89px">
  202. <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="CboColaborador"
  203. ErrorMessage="*" ValidationGroup="ValDoc"></asp:RequiredFieldValidator></td>
  204. </tr>
  205. <tr>
  206. <td style="width: 101px">
  207. </td>
  208. <td style="width: 87px">
  209. <asp:Button ID="Button3" runat="server" Enabled="False" Text="Relacionar" ValidationGroup="ValDoc" /></td>
  210. <td style="width: 89px">
  211. </td>
  212. </tr>
  213. <tr>
  214. <td style="width: 101px">
  215. </td>
  216. <td style="width: 87px">
  217. &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;
  218. </td>
  219. <td style="width: 89px">
  220. </td>
  221. </tr>
  222. <tr>
  223. <td style="width: 101px; height: 200px;">
  224. </td>
  225. <td style="width: 87px; height: 200px;">
  226. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
  227. </td>
  228. <td style="width: 89px; height: 200px;">
  229. </td>
  230. </tr>
  231. <tr>
  232. <td style="width: 101px; height: 21px">
  233. <asp:Button ID="Button5" runat="server" Text="Visualizar Documentos" /></td>
  234. <td style="width: 87px; height: 21px">
  235. &nbsp; &nbsp;
  236. </td>
  237. <td style="width: 89px; height: 21px">
  238. </td>
  239. </tr>
  240. <tr>
  241. <td style="width: 101px">
  242. </td>
  243. <td style="width: 87px">
  244.  
  245. <div style="left: 240px; width: 180px; bottom: 401px; position: absolute; top: 860px; height: 30px;">
  246.  
  247. <asp:Panel ID="Panel2" runat="server" ScrollBars="Horizontal" BorderStyle="Outset" Width="690px">
  248. &nbsp;<asp:GridView ID="GrdDocumentos" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" Width="1216px" Height="92px">
  249. <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
  250. <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
  251. <Columns>
  252. <asp:TemplateField ShowHeader="False">
  253. <ItemTemplate>
  254. <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
  255. Text="Exluir"></asp:LinkButton>
  256. </ItemTemplate>
  257. </asp:TemplateField>
  258. <asp:BoundField DataField="USER_ID" HeaderText="Colaborador" SortExpression="USER_ID"
  259. Visible="False" />
  260. <asp:BoundField DataField="USER_NOME" HeaderText="Colaborador" SortExpression="USER_NOME" />
  261. <asp:BoundField DataField="REL_DOCUMENTO" HeaderText="Nr.Documento" SortExpression="REL_DOCUMENTO" />
  262. <asp:BoundField DataField="FORMATO_NOME" HeaderText="Formato" SortExpression="FORMATO_NOME" />
  263. <asp:BoundField DataField="REL_PREVINI" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Prev.Inicio"
  264. SortExpression="REL_PREVINI" />
  265. <asp:BoundField DataField="REL_PREVFIM" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Prev.Fim"
  266. SortExpression="REL_PREVFIM" />
  267. <asp:BoundField DataField="REL_HORASPREVISTAS" HeaderText="Horas Previstas" SortExpression="REL_HORASPREVISTAS" />
  268. <asp:BoundField DataField="ESPEC_NOME" HeaderText="Especialidade" SortExpression="ESPEC_NOME" />
  269. <asp:BoundField DataField="COLABOR_ID" HeaderText="COLABOR_ID" SortExpression="COLABOR_ID"
  270. Visible="False" />
  271. <asp:BoundField DataField="FORMATO_ID" HeaderText="FORMATO_ID" SortExpression="FORMATO_ID"
  272. Visible="False" />
  273. <asp:BoundField DataField="UserLoginID" HeaderText="UserLoginID" Visible="False" />
  274. </Columns>
  275. <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
  276. <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
  277. <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
  278. <EditRowStyle BackColor="#999999" />
  279. <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
  280. </asp:GridView>
  281. </asp:Panel>
  282. </div>
  283. </td>
  284. <td style="width: 89px">
  285. </td>
  286. </tr>
  287. <tr>
  288. <td style="width: 101px">
  289. </td>
  290. <td style="width: 87px">
  291. <div style="left: 440px; width: 85px; bottom: 401px; position: absolute; top: 820px; height: 30px;">
  292. <asp:Button ID="Button1" runat="server" Enabled="False" Text="Atualizar" Width="107px" />
  293. </div>
  294.  
  295. <div style="left: 555px; width: 85px; bottom: 401px; position: absolute; top: 820px; height: 30px;">
  296. <asp:Button ID="Button2" runat="server" Enabled="False" Text="Enviar Email" Width="107px" />
  297. </div>
  298. </td>
  299. <td style="width: 89px">
  300. </td>
  301. </tr>
  302. <tr>
  303. <td style="width: 101px; height: 21px;">
  304. <asp:SqlDataSource ID="DsEspec" runat="server" ConnectionString="<%$ ConnectionStrings:timesheet %>"
  305. SelectCommand="SELECT * FROM [ESPECIALIDADES] ORDER BY [ESPEC_NOME]"></asp:SqlDataSource>
  306. </td>
  307. <td style="width: 87px; height: 21px;">
  308. <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:timesheet %>"
  309. SelectCommand="SELECT [USER_ID], [USER_NOME] FROM [USERS]"></asp:SqlDataSource>
  310. </td>
  311. <td style="width: 89px; height: 21px;">
  312. </td>
  313. </tr>
  314. <tr>
  315. <td style="width: 101px">
  316. <asp:SqlDataSource ID="DsFormato" runat="server" ConnectionString="<%$ ConnectionStrings:timesheet %>"
  317. SelectCommand="SELECT [FORMATO_ID], [FORMATO_NOME] FROM [FORMATOS] ORDER BY [FORMATO_NOME]">
  318. </asp:SqlDataSource>
  319. </td>
  320. <td style="width: 87px">
  321. <asp:Label ID="lblMensagem" runat="server" Font-Names="Tahoma" ForeColor="Red" Width="493px"></asp:Label></td>
  322. <td style="width: 89px">
  323. </td>
  324. </tr>
  325. <tr>
  326. <td style="width: 101px; height: 26px">
  327. </td>
  328. <td style="width: 87px; height: 26px">
  329. <asp:Label ID="LblStatus" runat="server" Font-Names="Tahoma" ForeColor="Red" Width="496px"></asp:Label></td>
  330. <td style="width: 89px; height: 26px">
  331. </td>
  332. </tr>
  333. <tr>
  334. <td style="width: 101px">
  335. &nbsp;</td>
  336. <td style="width: 87px"></td>
  337. <td style="width: 89px">
  338. </td>
  339. </tr>
  340. <tr>
  341. <td style="width: 101px">
  342. </td>
  343. <td style="width: 87px">
  344. </td>
  345. <td style="width: 89px">
  346. </td>
  347. </tr>
  348. </table>
  349. <br />
  350. <br />
  351. <br />
  352. &nbsp;<br />
  353. <br />
  354. <br />
  355. <br />
  356. <br />
  357. <br />
  358.  
  359.  
  360.  
  361.  
  362. </fieldset>
  363.  
  364. </asp:Content>


Code Behind :
  1. Imports System.Data.SqlClient
  2. Imports System.Data
  3. Imports System.Net.Mail
  4.  
  5. Partial Class Admin_Projetos
  6. Inherits System.Web.UI.Page
  7. Public IDProjeto As Double = 0
  8. Public IdCliente As Double = 0
  9. Public IdGerCliente As Double = 0
  10. Public IdGerente As Double = 0
  11. Public IdLider As Double = 0
  12. Public IdGestor As Double = 0
  13.  
  14. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  15.  
  16. Dim Sql As String
  17. Dim cmd As SqlCommand
  18. 'Dim cmdDoc As SqlCommand
  19. Dim dr As SqlDataReader = Nothing
  20. Dim DrDoc As SqlDataReader = Nothing
  21.  
  22. Dim conexao As SqlConnection
  23.  
  24. IDProjeto = Convert.ToDouble(Request.QueryString("PROJE_ID"))
  25. TxtData.Text = String.Format("{0:dd/MM/yyyy}", Date.Now)
  26.  
  27. If Not Page.IsPostBack Then
  28. MontaCliente()
  29. MontaProjeto()
  30. MontaGerente()
  31. MontaGerenteCliente()
  32. MontaLiderDisciplina()
  33. MontaEspecialidade()
  34. MontaColaborador()
  35. MontaFormato()
  36.  
  37. If Request.QueryString("PROJE_ID") <> "" Then
  38. Sql = "SELECT p.CLIENTE_ID,p.PROJE_ID,p.GERENTE_ID,p.UserLoginID,p.GERENTECLIENTE_ID,p.GESTOR_ID, "
  39. Sql += " p.PROJE_DATA,p.CLIENTE_OS,p.LIDERDISC_ID,g.GESTOR_PROJETO,g.GESTOR_CONTA "
  40. Sql += " FROM PROJETOS p, GESTOR g "
  41. Sql += " WHERE p.PROJE_ID = " + Request.QueryString("PROJE_ID")
  42. Sql += " AND p.GESTOR_ID=g.GESTOR_ID"
  43.  
  44. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  45.  
  46. conexao.Open()
  47.  
  48. cmd = New SqlCommand(Sql, conexao)
  49. dr = cmd.ExecuteReader()
  50.  
  51. If dr.Read() = True Then
  52. Try
  53. TxtData.Text = String.Format("{0:dd/MM/yyyy}", dr("PROJE_DATA"))
  54. TxtOS.Text = dr("CLIENTE_OS").ToString
  55. TxtContaGestor.Text = dr("GESTOR_CONTA").ToString
  56.  
  57. IdCliente = Convert.ToInt32(dr("CLIENTE_ID"))
  58. CboCliente.SelectedValue = IdCliente
  59.  
  60. IDProjeto = Convert.ToInt32(dr("PROJE_ID"))
  61.  
  62. IdGestor = Convert.ToInt32(dr("GESTOR_ID"))
  63. CboProjeto.SelectedValue = IdGestor
  64.  
  65. IdGerente = Convert.ToInt32(dr("GERENTE_ID"))
  66. CboGerente.SelectedValue = IdGerente
  67.  
  68. IdGerCliente = Convert.ToInt32(dr("GERENTECLIENTE_ID"))
  69. CboGerenteCliente.SelectedValue = IdGerCliente
  70.  
  71. IdLider = Convert.ToInt32(dr("LIDERDISC_ID"))
  72. CboLiderDisc.SelectedValue = IdLider
  73.  
  74. LblUserLoginID.Text = dr("UserLoginID").ToString
  75. Catch ex As Exception
  76. lblMensagem.Text = "Ocorreu Um Erro Durante a Exibição Dos Dados : " & vbCrLf & ex.Message & vbCrLf ' & ex.InnerException.ToString
  77. Finally
  78. dr.Close()
  79. End Try
  80.  
  81. Sql = " SELECT REL_PROJETOS.REL_DOCUMENTO, REL_PROJETOS.REL_HORASPREVISTAS, "
  82. Sql += " REL_PROJETOS.REL_PREVINI, REL_PROJETOS.REL_PREVFIM, "
  83. Sql += " REL_PROJETOS.REL_HORASCONSUMIDAS, REL_PROJETOS.REL_DATAINICIO, "
  84. sql += " PROJETOS.PROJE_ID, REL_PROJETOS.USER_ID, USERS.USER_NOME, "
  85. Sql += " FORMATOS.FORMATO_NOME, FORMATOS.FORMATO_ID, "
  86. Sql += " USERS.USER_ID AS USERID, REL_PROJETOS.ESPEC_ID, "
  87. Sql += " ESPECIALIDADES.ESPEC_NOME FROM REL_PROJETOS INNER JOIN "
  88. Sql += " PROJETOS ON REL_PROJETOS.PROJE_ID = PROJETOS.PROJE_ID "
  89. Sql += " INNER Join FORMATOS ON "
  90. Sql += " REL_PROJETOS.FORMATO_ID = FORMATOS.FORMATO_ID "
  91. Sql += " INNER Join USERS ON "
  92. Sql += " REL_PROJETOS.USER_ID = USERS.USER_ID INNER JOIN "
  93. Sql += " ESPECIALIDADES ON REL_PROJETOS.ESPEC_ID = ESPECIALIDADES.ESPEC_ID"
  94. Sql += " WHERE PROJETOS.PROJE_ID= " + Request.QueryString("PROJE_ID")
  95. Sql += " ORDER BY REL_PROJETOS.REL_PREVINI DESC "
  96.  
  97. Try
  98. cmdDoc = New SqlCommand(Sql, conexao)
  99. DrDoc = cmdDoc.ExecuteReader()
  100. Catch ex As Exception
  101. 'xxx
  102. Finally
  103. GrdDocumentos.DataSource = DrDoc
  104. GrdDocumentos.DataBind()
  105. DrDoc.Close()
  106. conexao.Close()
  107. End Try
  108. ' ObterDocumentosGravados()
  109. ' IncluirDocumentosGravados(Request.QueryString("PROJE_ID"))
  110. End If
  111. End If
  112. End If
  113. End Sub
  114. Public Function ObterDocumentosGravados() As DataSet
  115.  
  116. 'verifica se a cesta de compras esta na sessão
  117.  
  118. If Session("Documentos") Is Nothing Then
  119.  
  120. 'se nao estiver vamos criar um dataset e um datatable para armazenar os dados da compra
  121.  
  122. 'cria dataset
  123.  
  124. Dim ds As DataSet = New DataSet()
  125.  
  126. 'define um objeto DataColumn
  127.  
  128. Dim keys(1) As DataColumn
  129.  
  130. 'define o campo que sera a chave primaria
  131.  
  132. Dim ItemID As New DataColumn("ItemID", GetType(Int32))
  133.  
  134. 'cria o datatable
  135.  
  136. Dim dt As DataTable = New DataTable("Documentos")
  137.  
  138. 'inclua as colunas no datatable
  139.  
  140. dt.Columns.Add(ItemID)
  141.  
  142. 'outra forma de definir e incluir colunas no datatable
  143.  
  144. dt.Columns.Add("REL_DOCUMENTO", System.Type.GetType("System.String"), "")
  145. dt.Columns.Add("FORMATO_ID", System.Type.GetType("System.Double"), "")
  146. dt.Columns.Add("FORMATO_NOME", System.Type.GetType("System.String"), "")
  147. dt.Columns.Add("REL_PREVINI", System.Type.GetType("System.DateTime"), "")
  148. dt.Columns.Add("REL_PREVFIM", System.Type.GetType("System.DateTime"), "")
  149. dt.Columns.Add("ESPEC_ID", System.Type.GetType("System.Double"), "")
  150. dt.Columns.Add("ESPEC_NOME", System.Type.GetType("System.String"), "")
  151. dt.Columns.Add("REL_HORASPREVISTAS", System.Type.GetType("System.Double"), "")
  152. dt.Columns.Add("USER_ID", System.Type.GetType("System.Double"), "")
  153. dt.Columns.Add("USER_NOME", System.Type.GetType("System.String"), "")
  154. dt.Columns.Add("REL_DATAENVIO", System.Type.GetType("System.DateTime"), "")
  155. dt.Columns.Add("UserLoginID", System.Type.GetType("System.String"), "")
  156. dt.Columns.Add("Status", System.Type.GetType("System.Double"), "") ' 1-Gravado / 0-Nao Gravado
  157.  
  158. 'define a chave primária
  159.  
  160. keys(0) = ItemID
  161.  
  162. dt.PrimaryKey = keys
  163.  
  164. 'inclui na tabela
  165.  
  166. ds.Tables.Add(dt)
  167.  
  168. 'coloca o dataset na sessão
  169.  
  170. Session("Documentos") = ds
  171.  
  172. 'retorna o dataset criado
  173.  
  174. Return ds
  175.  
  176. Else
  177.  
  178. 'retorna o dataset que esta na sessão
  179.  
  180. Return Session("Documentos")
  181.  
  182. End If
  183.  
  184. End Function
  185. Private Sub IncluirDocumentosGravados(ByVal ID As String)
  186.  
  187. Dim Sql As String
  188. Dim cmd As SqlCommand
  189. Dim dr As SqlDataReader = Nothing
  190.  
  191. Dim conexao As SqlConnection
  192.  
  193. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  194.  
  195. Sql = " SELECT REL_PROJETOS.REL_DOCUMENTO, REL_PROJETOS.REL_HORASPREVISTAS, "
  196. Sql += " REL_PROJETOS.REL_PREVINI, REL_PROJETOS.REL_PREVFIM,REL_PROJETOS.REL_ID, "
  197. Sql += " REL_PROJETOS.REL_HORASCONSUMIDAS, REL_PROJETOS.REL_DATAINICIO, "
  198. Sql += " PROJETOS.PROJE_ID, REL_PROJETOS.USER_ID, USERS.USER_NOME, "
  199. Sql += " FORMATOS.FORMATO_NOME, FORMATOS.FORMATO_ID, "
  200. Sql += " USERS.USER_ID AS USERID, REL_PROJETOS.ESPEC_ID, "
  201. Sql += " ESPECIALIDADES.ESPEC_NOME FROM REL_PROJETOS INNER JOIN "
  202. Sql += " PROJETOS ON REL_PROJETOS.PROJE_ID = PROJETOS.PROJE_ID "
  203. Sql += " INNER Join FORMATOS ON "
  204. Sql += " REL_PROJETOS.FORMATO_ID = FORMATOS.FORMATO_ID "
  205. Sql += " INNER Join USERS ON "
  206. Sql += " REL_PROJETOS.USER_ID = USERS.USER_ID INNER JOIN "
  207. Sql += " ESPECIALIDADES ON REL_PROJETOS.ESPEC_ID = ESPECIALIDADES.ESPEC_ID"
  208. Sql += " WHERE PROJETOS.PROJE_ID= " + ID
  209. Sql += " ORDER BY REL_PROJETOS.REL_PREVINI DESC "
  210.  
  211. Try
  212.  
  213. 'abre a conexao
  214.  
  215. conexao.Open()
  216.  
  217. 'executa o comando e cria um datareader
  218.  
  219. cmd = New SqlCommand(Sql, conexao)
  220.  
  221. dr = cmd.ExecuteReader()
  222. Sql = dr("FORMATO_ID")
  223.  
  224. 'le o datareader
  225.  
  226. 'obtem a tabela do dataset e atribui ao datable local
  227.  
  228. Dim dt As DataTable = ObterDocumentos().Tables(0)
  229.  
  230. 'localiza o codigo do produto na tabela
  231.  
  232. Dim row As DataRow = dt.Rows.Find(Convert.ToDouble(dr("FORMATO_ID")))
  233. ' Dim row As DataRow = dt.Rows.Find(0)
  234.  
  235. If row Is Nothing Then
  236.  
  237. 'se nao achou cria uma nova linha
  238.  
  239. row = dt.NewRow()
  240.  
  241. row("itemID") = dr("REL_ID")
  242. row("REL_DOCUMENTO") = dr("REL_DOCUMENTO")
  243. row("FORMATO_ID") = dr("FORMATO_ID")
  244. row("FORMATO_NOME") = dr(" FORMATO_NOME")
  245. row("REL_PREVINI") = dr("REL_PREVINI")
  246. row("REL_PREVFIM") = dr("REL_PREVFIM")
  247. row("ESPEC_ID") = dr("ESPEC_ID")
  248. row("ESPEC_NOME") = dr("ESPEC_NOME")
  249. row("REL_HORASPREVISTAS") = dr("REL_HORASPREVISTAS")
  250. row("USER_ID") = dr("USERID")
  251. row("USER_NOME") = dr("USER_NOME")
  252. row("REL_DATAENVIO") = String.Format("{0:dd/MM/yyyy}", dr("REL_DATAENVIO"))
  253. row("USERLOGINID") = LblUserLoginIDDoc.Text
  254. row("STATUS") = 1
  255.  
  256. 'inclui a linha no datable
  257. dt.Rows.Add(row)
  258.  
  259. Else
  260.  
  261. 'se a linha ja existir então apenas altera a quantidade
  262.  
  263. 'Dim qtd As Integer = Convert.ToInt32(row("Quantidade"))
  264.  
  265. 'qtd = qtd + quantidade
  266.  
  267. 'row("Quantidade") = qtd
  268.  
  269. End If
  270. Catch ex As Exception
  271. lblMensagem.Text = "Ocorreu um Erro Inesperado : " & vbCrLf & ex.Message & vbCrLf ' & ex.InnerException.ToString
  272. Finally
  273. conexao.Close()
  274. End Try
  275.  
  276. End Sub
  277. Sub MontaCliente()
  278.  
  279. Dim conexao As SqlConnection
  280. Dim sql As String
  281. Dim da As SqlDataAdapter
  282. Dim ds As DataSet
  283.  
  284. sql = "SELECT * FROM CLIENTES ORDER BY CLIENTE_NOME"
  285.  
  286. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  287.  
  288. Try
  289.  
  290. conexao.Open()
  291.  
  292. da = New SqlDataAdapter(sql, conexao)
  293. ds = New DataSet()
  294.  
  295. da.Fill(ds, "CLIENTES")
  296.  
  297. With CboCliente
  298. .DataTextField = "CLIENTE_NOME"
  299. .DataValueField = "CLIENTE_ID"
  300. .DataSource = ds.Tables("CLIENTES").DefaultView
  301. .DataBind()
  302. End With
  303. CboCliente.Items.Insert(0, "Selecione o Cliente")
  304. Finally
  305. conexao.Close()
  306. conexao = Nothing
  307. End Try
  308. End Sub
  309. Sub MontaProjeto()
  310.  
  311. Dim conexao As SqlConnection
  312. Dim sql As String
  313. Dim da As SqlDataAdapter
  314. Dim ds As DataSet
  315.  
  316. sql = "SELECT * FROM GESTOR ORDER BY GESTOR_PROJETO"
  317.  
  318. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  319.  
  320. Try
  321.  
  322. conexao.Open()
  323.  
  324. da = New SqlDataAdapter(sql, conexao)
  325. ds = New DataSet()
  326.  
  327. da.Fill(ds, "GESTOR")
  328.  
  329. With CboProjeto
  330. .DataTextField = "GESTOR_PROJETO"
  331. .DataValueField = "GESTOR_ID"
  332. .DataSource = ds.Tables("GESTOR").DefaultView
  333. .DataBind()
  334. End With
  335. CboProjeto.Items.Insert(0, "Selecione o Projeto")
  336. Finally
  337. conexao.Close()
  338. conexao = Nothing
  339. End Try
  340. End Sub
  341. Sub MontaGerente()
  342.  
  343. Dim conexao As SqlConnection
  344. Dim sql As String
  345. Dim da As SqlDataAdapter
  346. Dim ds As DataSet
  347.  
  348. sql = "SELECT * FROM USERS ORDER BY USER_NOME"
  349.  
  350. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  351.  
  352. Try
  353.  
  354. conexao.Open()
  355.  
  356. da = New SqlDataAdapter(sql, conexao)
  357. ds = New DataSet()
  358.  
  359. da.Fill(ds, "USERS")
  360.  
  361. With CboGerente
  362. .DataTextField = "USER_NOME"
  363. .DataValueField = "USER_ID"
  364. .DataSource = ds.Tables("USERS").DefaultView
  365. .DataBind()
  366. End With
  367. CboGerente.Items.Insert(0, "Selecione o Gerente")
  368. Finally
  369. conexao.Close()
  370. conexao = Nothing
  371. End Try
  372. End Sub
  373. Sub MontaGerenteCliente()
  374.  
  375. Dim conexao As SqlConnection
  376. Dim sql As String
  377. Dim da As SqlDataAdapter
  378. Dim ds As DataSet
  379.  
  380. sql = "SELECT * FROM REL_GERENTES ORDER BY CLIENTE_GERENTE"
  381.  
  382. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  383.  
  384. Try
  385.  
  386. conexao.Open()
  387.  
  388. da = New SqlDataAdapter(sql, conexao)
  389. ds = New DataSet()
  390.  
  391. da.Fill(ds, "REL_GERENTES")
  392.  
  393. With CboGerenteCliente
  394. .DataTextField = "CLIENTE_GERENTE"
  395. .DataValueField = "GERENTE_ID"
  396. .DataSource = ds.Tables("REL_GERENTES").DefaultView
  397. .DataBind()
  398. End With
  399. CboGerenteCliente.Items.Insert(0, "Selecione o Gerente do Cliente")
  400. Finally
  401. conexao.Close()
  402. conexao = Nothing
  403. End Try
  404. End Sub
  405. Sub MontaLiderDisciplina()
  406.  
  407. Dim conexao As SqlConnection
  408. Dim sql As String
  409. Dim da As SqlDataAdapter
  410. Dim ds As DataSet
  411.  
  412. sql = "SELECT * FROM USERS ORDER BY USER_NOME"
  413.  
  414. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  415.  
  416. Try
  417.  
  418. conexao.Open()
  419.  
  420. da = New SqlDataAdapter(sql, conexao)
  421. ds = New DataSet()
  422.  
  423. da.Fill(ds, "USERS")
  424.  
  425. With CboLiderDisc
  426. .DataTextField = "USER_NOME"
  427. .DataValueField = "USER_ID"
  428. .DataSource = ds.Tables("USERS").DefaultView
  429. .DataBind()
  430. End With
  431. CboLiderDisc.Items.Insert(0, "Selecione o Lider de Disciplina")
  432. Finally
  433. conexao.Close()
  434. conexao = Nothing
  435. End Try
  436. End Sub
  437. Sub MontaColaborador()
  438.  
  439. Dim conexao As SqlConnection
  440. Dim sql As String
  441. Dim da As SqlDataAdapter
  442. Dim ds As DataSet
  443.  
  444. sql = "SELECT USER_NOME,USER_ID FROM USERS ORDER BY USER_NOME"
  445.  
  446. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  447.  
  448. Try
  449.  
  450. conexao.Open()
  451.  
  452. da = New SqlDataAdapter(sql, conexao)
  453. ds = New DataSet()
  454.  
  455. da.Fill(ds, "USERS")
  456.  
  457. With CboColaborador
  458. .DataTextField = "USER_NOME"
  459. .DataValueField = "USER_ID"
  460. .DataSource = ds.Tables("USERS").DefaultView
  461. .DataBind()
  462. End With
  463. CboColaborador.Items.Insert(0, "Selecione o Colaborador")
  464. Finally
  465. conexao.Close()
  466. conexao = Nothing
  467. End Try
  468. End Sub
  469. Sub MontaEspecialidade()
  470.  
  471. Dim conexao As SqlConnection
  472. Dim sql As String
  473. Dim da As SqlDataAdapter
  474. Dim ds As DataSet
  475.  
  476. sql = "SELECT * FROM ESPECIALIDADES ORDER BY ESPEC_NOME"
  477.  
  478. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  479.  
  480. Try
  481.  
  482. conexao.Open()
  483.  
  484. da = New SqlDataAdapter(sql, conexao)
  485. ds = New DataSet()
  486.  
  487. da.Fill(ds, "ESPECIALIDADES")
  488.  
  489. With CboEspecialidade
  490. .DataTextField = "ESPEC_NOME"
  491. .DataValueField = "ESPEC_ID"
  492. .DataSource = ds.Tables("ESPECIALIDADES").DefaultView
  493. .DataBind()
  494. End With
  495. CboEspecialidade.Items.Insert(0, "Selecione a Especialidade")
  496. Finally
  497. conexao.Close()
  498. conexao = Nothing
  499. End Try
  500. End Sub
  501. Sub MontaFormato()
  502.  
  503. Dim conexao As SqlConnection
  504. Dim sql As String
  505. Dim da As SqlDataAdapter
  506. Dim ds As DataSet
  507.  
  508. sql = "SELECT * FROM FORMATOS ORDER BY FORMATO_NOME"
  509.  
  510. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  511.  
  512. Try
  513.  
  514. conexao.Open()
  515.  
  516. da = New SqlDataAdapter(sql, conexao)
  517. ds = New DataSet()
  518.  
  519. da.Fill(ds, "FORMATOS")
  520.  
  521. With CboFormato
  522. .DataTextField = "FORMATO_NOME"
  523. .DataValueField = "FORMATO_ID"
  524. .DataSource = ds.Tables("FORMATOS").DefaultView
  525. .DataBind()
  526. End With
  527. CboFormato.Items.Insert(0, "Selecione o Formato")
  528. Finally
  529. conexao.Close()
  530. conexao = Nothing
  531. End Try
  532. End Sub
  533.  
  534. Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  535. Dim str_Mensagem As String
  536.  
  537. Dim oEmail As New MailMessage
  538. Dim oSmtp As New SmtpClient
  539. Dim basicAuthInfo As New System.Net.NetworkCredential("svs991234", "ventana")
  540.  
  541. lblMensagem.Text = ""
  542.  
  543. Try
  544. str_Mensagem = "Mensagem Enviada Por : " & User.Identity.Name & "<br/>"
  545. 'str_Mensagem += "Cargo : " & Session("Cargo_Empresa").ToString & "<br/>"
  546. str_Mensagem += "Projeto : " & CboProjeto.SelectedItem.Text & "<br/>"
  547. str_Mensagem += "Cliente : " & CboCliente.SelectedItem.Text & "<br/>"
  548. str_Mensagem += "Lider de Disciplina : " & CboLiderDisc.SelectedItem.Text & "<br/>"
  549. str_Mensagem += "Colaborador : " & CboColaborador.SelectedItem.Text & "<br/>"
  550. str_Mensagem += "Documento : " & TxtOS.Text.Trim & "<br/>"
  551. str_Mensagem += "Formato : " & CboFormato.SelectedItem.Text() & "<br/>"
  552. str_Mensagem += "Horas Previstas : " & TxtHorasPrevistas.Text.Trim & "<br/>"
  553. str_Mensagem += "Previsão de Inicio : " & TxtInicioPrevisto.Text.Trim & "<br/>"
  554. str_Mensagem += "Previsão de Termino : " & TxtTerminoPrevisto.Text.Trim & "<br/>"
  555.  
  556. 'cria objeto para receber os dados do email
  557. oSmtp.Host = "smtp.mail.yahoo.com.br"
  558. oSmtp.Credentials = basicAuthInfo
  559.  
  560. 'remetente do email
  561. oEmail.From = New MailAddress("svs991234@yahoo.com.br")
  562.  
  563. 'destinatario do email
  564. oEmail.To.Add("sid.sil@gmail.com")
  565. 'destinatario de copia do email
  566. oEmail.To.Add("svs99@ig.com.br")
  567. 'destinatario de copia oculta
  568. oEmail.Bcc.Add("svs99@correio24.com")
  569. 'prioridade de envio
  570. oEmail.Priority = MailPriority.Normal
  571. 'define o formato do email
  572. 'If chkFormato.Checked Then
  573.  
  574. 'IncluI um anexo a partir do arquivo de sistema
  575.  
  576. 'oEmail.Attachments.Add(New Attachment("c:\temp\exemplo.txt"))
  577. ''oEmail.Attachments.Add(New Attachment(FileUpload1.FileName))
  578. 'teste = FileUpload1.FileName
  579.  
  580. oEmail.IsBodyHtml = True
  581. 'Else
  582. 'oEmail.IsBodyHtml = False
  583. 'End If
  584. 'define o assunto do email
  585. oEmail.Subject = "Envio de Dados do Projeto"
  586. 'define a mensagem principal do email
  587. oEmail.Body = str_Mensagem
  588. 'Para evitar problemas com caracteres especiais configuramos o Charset
  589. oEmail.SubjectEncoding = Text.Encoding.GetEncoding("ISO-8859-1")
  590. oEmail.BodyEncoding = Text.Encoding.GetEncoding("ISO-8859-1")
  591. 'cria o objeto SMTP
  592.  
  593. 'envia o email
  594. oSmtp.Send(oEmail)
  595. lblMensagem.Text = "Email Enviado Com Sucesso. "
  596. Button1.Enabled = True
  597. Catch ex As Exception
  598. lblMensagem.Text = "Ocorreu Um Erro Ao Enviar o Email : " & ex.Message
  599. Finally
  600. 'limpa o objeto da memória
  601. oEmail.Dispose()
  602. End Try
  603.  
  604. End Sub
  605.  
  606. Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
  607. ObterDocumentos()
  608. IncluirDocumentos()
  609. ''mostra no gridview
  610.  
  611. GrdDocumentos.DataSource = ObterDocumentos()
  612.  
  613. GrdDocumentos.DataBind()
  614. Button1.Enabled = True
  615.  
  616. End Sub
  617. Public Function ObterDocumentos() As DataSet
  618.  
  619. 'verifica se a cesta de compras esta na sessão
  620.  
  621. If Session("Documentos") Is Nothing Then
  622.  
  623. 'se nao estiver vamos criar um dataset e um datatable para armazenar os dados da compra
  624.  
  625. 'cria dataset
  626.  
  627. Dim ds As DataSet = New DataSet()
  628.  
  629. 'define um objeto DataColumn
  630.  
  631. Dim keys(1) As DataColumn
  632.  
  633. 'define o campo que sera a chave primaria
  634.  
  635. Dim ItemID As New DataColumn("ItemID", GetType(Int32))
  636.  
  637. 'cria o datatable
  638.  
  639. Dim dt As DataTable = New DataTable("Documentos")
  640.  
  641. 'inclua as colunas no datatable
  642.  
  643. dt.Columns.Add(ItemID)
  644.  
  645. 'outra forma de definir e incluir colunas no datatable
  646.  
  647. dt.Columns.Add("REL_DOCUMENTO", System.Type.GetType("System.String"), "")
  648. dt.Columns.Add("FORMATO_ID", System.Type.GetType("System.Double"), "")
  649. dt.Columns.Add("FORMATO_NOME", System.Type.GetType("System.String"), "")
  650. dt.Columns.Add("REL_PREVINI", System.Type.GetType("System.DateTime"), "")
  651. dt.Columns.Add("REL_PREVFIM", System.Type.GetType("System.DateTime"), "")
  652. dt.Columns.Add("ESPEC_ID", System.Type.GetType("System.Double"), "")
  653. dt.Columns.Add("ESPEC_NOME", System.Type.GetType("System.String"), "")
  654. dt.Columns.Add("REL_HORASPREVISTAS", System.Type.GetType("System.Double"), "")
  655. dt.Columns.Add("USER_ID", System.Type.GetType("System.Double"), "")
  656. dt.Columns.Add("USER_NOME", System.Type.GetType("System.String"), "")
  657. dt.Columns.Add("REL_DATAENVIO", System.Type.GetType("System.DateTime"), "")
  658. dt.Columns.Add("UserLoginID", System.Type.GetType("System.String"), "")
  659.  
  660. 'define a chave primária
  661.  
  662. keys(0) = ItemID
  663.  
  664. dt.PrimaryKey = keys
  665.  
  666. 'inclui na tabela
  667.  
  668. ds.Tables.Add(dt)
  669.  
  670. 'coloca o dataset na sessão
  671.  
  672. Session("Documentos") = ds
  673.  
  674. 'retorna o dataset criado
  675.  
  676. Return ds
  677.  
  678. Else
  679.  
  680. 'retorna o dataset que esta na sessão
  681.  
  682. Return Session("Documentos")
  683.  
  684. End If
  685.  
  686. End Function
  687. Private Sub IncluirDocumentos()
  688.  
  689. Dim Sql As String
  690. Dim cmd As SqlCommand
  691. Dim dr As SqlDataReader = Nothing
  692.  
  693. Dim conexao As SqlConnection
  694. Dim str_Especialidade As String
  695. Dim str_Colaborador As String
  696.  
  697. 'Dim IdGestor As Integer
  698. 'Dim IdFormato As Integer
  699.  
  700. 'define o objeto conexao e obtem a string de conexao do arquivo web.config
  701.  
  702. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  703.  
  704. 'define a instrução sql para selecionar os dados das tabelas envolvidas
  705.  
  706. Sql = "Select r.USER_ID,r.FORMATO_ID,r.REL_PREVINI,r.REL_PREVFIM, "
  707. Sql += " r.REL_DOCUMENTO, p.PROJE_ID,e.ESPEC_NOME,u.USER_NOME "
  708. Sql += " FROM REL_PROJETOS r,PROJETOS p, ESPECIALIDADES e,USERS u "
  709. Sql += " WHERE r.PROJE_ID = p.PROJE_ID "
  710. Sql += " AND e.ESPEC_ID =" & Convert.ToDouble(CboEspecialidade.SelectedItem.Value)
  711. Sql += " AND u.USER_ID =" & Convert.ToDouble(CboColaborador.SelectedItem.Value)
  712.  
  713. Try
  714.  
  715. 'abre a conexao
  716.  
  717. conexao.Open()
  718.  
  719. 'executa o comando e cria um datareader
  720.  
  721. cmd = New SqlCommand(Sql, conexao)
  722.  
  723. dr = cmd.ExecuteReader()
  724.  
  725. 'le o datareader
  726.  
  727. If dr.Read() = True Then
  728. str_Especialidade = dr("ESPEC_NOME")
  729. str_Colaborador = dr("USER_NOME")
  730. 'LblUserLoginIDDoc.Text = dr("UserLoginID").ToString
  731. End If
  732.  
  733. dr.Close()
  734.  
  735. 'obtem a tabela do dataset e atribui ao datable local
  736.  
  737. Dim dt As DataTable = ObterDocumentos().Tables(0)
  738.  
  739. 'localiza o codigo do produto na tabela
  740.  
  741. Dim row As DataRow = dt.Rows.Find(Convert.ToDouble(CboFormato.SelectedItem.Value))
  742. ' Dim row As DataRow = dt.Rows.Find(0)
  743.  
  744. If row Is Nothing Then
  745.  
  746. 'se nao achou cria uma nova linha
  747.  
  748. row = dt.NewRow()
  749.  
  750. row("itemID") = Convert.ToDouble(CboFormato.SelectedItem.Value)
  751. row("REL_DOCUMENTO") = TxtDocumento.Text.Trim
  752. row("FORMATO_ID") = Convert.ToDouble(CboFormato.SelectedItem.Value)
  753. row("FORMATO_NOME") = CboFormato.SelectedItem.Text.Trim
  754. row("REL_PREVINI") = CDate(TxtInicioPrevisto.Text)
  755. row("REL_PREVFIM") = CDate(TxtTerminoPrevisto.Text)
  756. row("ESPEC_ID") = CboEspecialidade.SelectedItem.Value
  757. row("ESPEC_NOME") = CboEspecialidade.SelectedItem.Text.Trim
  758. row("REL_HORASPREVISTAS") = Convert.ToDouble(TxtHorasPrevistas.Text.Trim)
  759. row("USER_ID") = CboColaborador.SelectedItem.Value
  760. row("USER_NOME") = CboColaborador.SelectedItem.Text.Trim
  761. row("REL_DATAENVIO") = String.Format("{0:dd/MM/yyyy}", Date.Now)
  762. row("USERLOGINID") = LblUserLoginIDDoc.Text
  763.  
  764. 'inclui a linha no datable
  765. dt.Rows.Add(row)
  766.  
  767. Else
  768.  
  769. 'se a linha ja existir então apenas altera a quantidade
  770.  
  771. 'Dim qtd As Integer = Convert.ToInt32(row("Quantidade"))
  772.  
  773. 'qtd = qtd + quantidade
  774.  
  775. 'row("Quantidade") = qtd
  776.  
  777. End If
  778. Catch ex As Exception
  779. lblMensagem.Text = "Ocorreu um Erro Inesperado : " & vbCrLf & ex.Message & vbCrLf ' & ex.InnerException.ToString
  780. Finally
  781. conexao.Close()
  782. End Try
  783.  
  784. End Sub
  785. Private Sub RemoverDocumento(ByVal prodID As Integer)
  786.  
  787. 'obtem o dataset
  788.  
  789. Dim ds As DataSet = ObterDocumentos()
  790.  
  791. 'localiza o produto
  792.  
  793. Dim row As DataRow = ds.Tables(0).Rows.Find(prodID)
  794.  
  795.  
  796. 'se a linha nao for nula
  797.  
  798. If row IsNot Nothing Then
  799.  
  800. 'remove a linha
  801.  
  802. ds.Tables(0).Rows.Remove(row)
  803.  
  804. 'atualiza o dataset
  805.  
  806. ds.AcceptChanges()
  807.  
  808. 'mostra no gridview
  809.  
  810. GrdDocumentos.DataSource = ObterDocumentos()
  811.  
  812. GrdDocumentos.DataBind()
  813.  
  814. End If
  815.  
  816. End Sub
  817. Protected Sub GrdDocumentos_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GrdDocumentos.RowDeleting
  818. 'chama rotina para remover item do documento
  819. Dim NUMERO As Double
  820. NUMERO = Convert.ToInt32(GrdDocumentos.DataKeys(e.RowIndex).Value)
  821.  
  822. RemoverDocumento(Convert.ToInt32(GrdDocumentos.DataKeys(e.RowIndex).Value))
  823. End Sub
  824. 'Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
  825.  
  826. ' 'verifica se a linha é do tipo rodape
  827.  
  828. ' If e.Row.RowType = DataControlRowType.Footer Then
  829.  
  830. ' 'na quarta celula inclui o texto Total
  831.  
  832. ' e.Row.Cells(3).Text = "Total: "
  833.  
  834. ' 'na quinta celula obtem o total e formata
  835.  
  836. ' 'e.Row.Cells(4).Text = String.Format("{0:c}", ObterDocumentos().Tables(0).Rows(0)("Total"))
  837.  
  838. ' End If
  839.  
  840. 'End Sub
  841.  
  842. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  843.  
  844. Dim conexao As SqlConnection
  845. Dim row As DataRow
  846. Dim linha As Double = 0
  847. 'Dim linta As DataRow
  848.  
  849. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  850. lblMensagem.Text = ""
  851.  
  852. Try
  853. conexao.Open()
  854.  
  855. For Each row In ObterDocumentos.Tables(0).Rows
  856. Dim cmdItem As SqlCommand
  857.  
  858. cmdItem = New SqlCommand("SP_IncluiRelProjetos", conexao)
  859. cmdItem.CommandType = CommandType.StoredProcedure
  860.  
  861. cmdItem.Parameters.Add("@PROJE_ID", SqlDbType.Int, 0, "PROJE_ID").Value = Session("IdKey")
  862. cmdItem.Parameters.Add("@FORMATO_ID", SqlDbType.Int, 0, "FORMATO_ID").Value = row("FORMATO_ID")
  863. cmdItem.Parameters.Add("@REL_HORASPREVISTAS", SqlDbType.Int, 0, "REL_HORASPREVISTAS").Value = row("REL_HORASPREVISTAS")
  864. cmdItem.Parameters.Add("@REL_DOCUMENTO", SqlDbType.NVarChar, 50, "REL_DOCUMENTO").Value = row("REL_DOCUMENTO")
  865. cmdItem.Parameters.Add("@ESPEC_ID", SqlDbType.Int, 0, "ESPEC_ID").Value = row("ESPEC_ID")
  866. cmdItem.Parameters.Add("@REL_PREVINI", SqlDbType.DateTime, 0, "REL_PREVINI").Value = row("REL_PREVINI")
  867. cmdItem.Parameters.Add("@REL_PREVFIM", SqlDbType.DateTime, 0, "REL_PREVFIM").Value = row("REL_PREVFIM")
  868. cmdItem.Parameters.Add("@USER_ID", SqlDbType.Int, 0, "USER_ID").Value = row("USER_ID")
  869. cmdItem.Parameters.Add("@REL_DATAENVIO", SqlDbType.DateTime, 0, "REL_DATAENVIO").Value = row("REL_DATAENVIO")
  870. cmdItem.Parameters.Add("@UserLoginID", SqlDbType.NVarChar, 50, "UserLoginID").Value = row("UserLoginID")
  871.  
  872. cmdItem.ExecuteNonQuery()
  873.  
  874. Session("Documentos") = Nothing
  875. Next
  876.  
  877. Catch ex As Exception
  878. lblMensagem.Text = "Erro ao acessar os dados : " & vbCrLf & ex.Message & vbCrLf
  879. Finally
  880. conexao.Close()
  881. End Try
  882.  
  883. Button2.Enabled = True
  884. 'Call Me.Limpar(Me)
  885.  
  886. End Sub
  887.  
  888. 'Dim _message As String = "window.alert('Item já adicionado.')"
  889.  
  890. Protected Sub CboProjeto_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboProjeto.SelectedIndexChanged
  891. Dim Sql As String
  892. Dim cmd As SqlCommand
  893. Dim dr As SqlDataReader = Nothing
  894.  
  895. Dim conexao As SqlConnection
  896. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  897.  
  898. Sql = "Select GESTOR_CONTA from GESTOR where GESTOR_ID = " + CboProjeto.SelectedValue
  899.  
  900. cmd = New SqlCommand(Sql, conexao)
  901.  
  902. conexao.Open()
  903. dr = cmd.ExecuteReader()
  904.  
  905. If dr.Read() = True Then
  906. TxtContaGestor.Text = dr("GESTOR_CONTA")
  907. End If
  908. dr.Close()
  909. conexao.Close()
  910. End Sub
  911.  
  912. Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
  913. Dim Sql As String
  914. Dim cmd As SqlCommand
  915.  
  916. Dim conexao As SqlConnection
  917. Dim UserLoginID As MembershipUser = Membership.GetUser(User.Identity.Name)
  918.  
  919. Dim UserGUID As Object = UserLoginID.ProviderUserKey
  920. Sql = UserGUID.ToString
  921.  
  922. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  923. lblMensagem.Text = ""
  924.  
  925. Try
  926. If IDProjeto = 0 Then
  927.  
  928. Sql = "INSERT INTO PROJETOS "
  929. Sql += " (PROJE_DATA,CLIENTE_ID,GESTOR_ID,GERENTE_ID,GERENTECLIENTE_ID,CLIENTE_OS,LIDERDISC_ID,UserLoginID) "
  930. Sql += " VALUES (@PROJE_DATA,@CLIENTE_ID,@GESTOR_ID,@GERENTE_ID,@GERENTECLIENTE_ID,@CLIENTE_OS,@LIDERDISC_ID,@UserLoginID) "
  931. Else
  932. Sql = "UPDATE PROJETOS "
  933. Sql += " SET PROJE_DATA=@PROJE_DATA, "
  934. Sql += " CLIENTE_ID=@CLIENTE_ID, "
  935. Sql += " GERENTE_ID=@GERENTE_ID, "
  936. Sql += " GERENTECLIENTE_ID=@GERENTECLIENTE_ID, "
  937. Sql += " CLIENTE_OS=@CLIENTE_OS, "
  938. Sql += " LIDERDISC_ID=@LIDERDISC_ID, "
  939. Sql += " UserLoginID=@UserLoginID "
  940. Sql += " WHERE PROJE_ID=" & IDProjeto
  941. End If
  942.  
  943. conexao.Open()
  944.  
  945. cmd = New SqlCommand(Sql, conexao)
  946.  
  947. With cmd.Parameters
  948. 'If IDProjeto = 0 Then
  949. .Add(New SqlParameter("@PROJE_DATA", CDate(TxtData.Text)))
  950. 'End If
  951.  
  952. .Add(New SqlParameter("@CLIENTE_ID", CboCliente.SelectedValue))
  953. .Add(New SqlParameter("@GESTOR_ID", CboProjeto.SelectedValue))
  954. .Add(New SqlParameter("@GERENTE_ID", CboGerente.SelectedValue))
  955. .Add(New SqlParameter("@GERENTECLIENTE_ID", CboGerenteCliente.SelectedValue))
  956. .Add(New SqlParameter("@CLIENTE_OS", TxtOS.Text.Trim))
  957. .Add(New SqlParameter("@LIDERDISC_ID", CboLiderDisc.SelectedValue))
  958. .Add(New SqlParameter("@UserLoginID", UserGUID.ToString))
  959. End With
  960.  
  961. cmd.ExecuteNonQuery()
  962. 'Erro = cmd.ExecuteNonQuery()
  963.  
  964. If IDProjeto = 0 Then
  965. Try
  966.  
  967. 'Determine a query que seleciona o identificador do registro inserido
  968.  
  969. cmd = New SqlCommand("SELECT @@IDENTITY", conexao)
  970.  
  971. cmd.CommandType = CommandType.Text
  972.  
  973. 'obtem o codigo do pedido que foi incluido na tabela Pedidos
  974.  
  975. Session("IdKey") = cmd.ExecuteScalar()
  976.  
  977. Catch ex As Exception
  978.  
  979. lblMensagem.Text = "Ocorreu um Erro Durante a Gravação : " & vbCrLf & ex.Message & vbCrLf ' & ex.InnerException.ToString
  980.  
  981. Finally
  982. ' XXX
  983. End Try
  984. Else
  985. Session("IdKey") = IDProjeto
  986. End If
  987. Catch ex As Exception
  988. lblMensagem.Text = "Ocorreu um Erro Durante a Gravação : " & vbCrLf & ex.Message & vbCrLf ' & ex.InnerException.ToString
  989. Finally
  990. conexao.Close()
  991. TxtDocumento.Enabled = True
  992. CboFormato.Enabled = True
  993. TxtInicioPrevisto.Enabled = True
  994. TxtTerminoPrevisto.Enabled = True
  995. TxtHorasPrevistas.Enabled = True
  996. CboColaborador.Enabled = True
  997. CboEspecialidade.Enabled = True
  998. Button3.Enabled = True
  999. 'Button2.Enabled = True
  1000. End Try
  1001.  
  1002. End Sub
  1003.  
  1004. Public Sub Limpar(ByVal controlP As Control)
  1005. Dim ctl As Control
  1006. For Each ctl In controlP.Controls
  1007. If TypeOf ctl Is TextBox Then
  1008. DirectCast(ctl, TextBox).Text = String.Empty
  1009. ElseIf ctl.Controls.Count > 0 Then
  1010. Limpar(ctl)
  1011. End If
  1012. Next
  1013. End Sub
  1014.  
  1015. Protected Sub CboColaborador_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboColaborador.SelectedIndexChanged
  1016.  
  1017. Dim Sql As String
  1018. Dim cmd As SqlCommand
  1019. Dim conexao As SqlConnection
  1020. Dim dr As SqlDataReader = Nothing
  1021.  
  1022. Sql = "SELECT UserLoginID FROM USERS "
  1023. Sql += "WHERE USER_ID= " + CboColaborador.SelectedItem.Value
  1024.  
  1025. conexao = New SqlConnection(ConfigurationManager.ConnectionStrings("timesheet").ConnectionString)
  1026.  
  1027. Try
  1028. conexao.Open()
  1029.  
  1030. cmd = New SqlCommand(Sql, conexao)
  1031. dr = cmd.ExecuteReader()
  1032.  
  1033. If dr.Read() = True Then
  1034. LblUserLoginIDDoc.Text = dr("UserLoginID").ToString
  1035. End If
  1036. Finally
  1037. conexao.Close()
  1038. conexao = Nothing
  1039. End Try
  1040. End Sub
  1041. End Class


Thanks a lot guys
Last edited by Ezzaral; Aug 27th, 2009 at 12:45 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

Re: GridView and DataTable

 
0
  #8
Aug 27th, 2009
Hi again

Maybe one of my problens be English.That´s way I´ve used google translate.

Here is the text:

I have several textbox and DropDownList, where digit and select information dai click a button and add this information
in a DataTable, since I can not include them directly in the GridView all the routine inclusion.

Then I walk to the GriidView and save the data in the dados.Isso is working well.


I do not have the need to change any of the information line of GridView.Se will need to delete it and include it
again.

In routine amendment as I have said, I need to change any line of the GridView, however I need to display all
that was previously recorded in its GridView.

Back in the TextBox and DropDownList from the start, this routine amendment I need possibility to add new
lines to the GridView, then turned once again to the DataTable, and then populate the GridView.

Oh, and that the problem arises, because if I load the Grid with the current DataTable, Grid no longer display the recorded data, from
only show the data on the DataTable.

I need this routine amendment, be able to add new lines without the prior disappear.
So at some point, I'll have the GridView data which came from the database and data that come from the DataTable.

Perhaps an alternative is, the routine amendment, instead of populating the GridView to the DataSource of recorded data,
it sends them to a DataTable and oh yeah first populate the GridView as the inclusion and so I only include
new lines in the same DataTable.

I believe at the time of recording, I have to read the database to see which line of the GridView has not yet been recorded,
to avoid duplication of data.

That's what I want my friends.

Maybe it ate a simple task but for me this is very complicated.

If there is a simpler way, please let me know, I accept all suggestions.


Thanks and a hug.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,793
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 698
Sponsor
Featured Poster
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: GridView and DataTable

 
0
  #9
Aug 27th, 2009
Please use code tags when pasting code on daniweb:

[code=vb.net]
...code here....
[/code]


Can you .zip a runnable project? A paste that big doesn't do much good.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: SID.SIL is an unknown quantity at this point 
Solved Threads: 0
SID.SIL SID.SIL is offline Offline
Light Poster

Re: GridView and DataTable

 
0
  #10
Aug 27th, 2009
Well, this is my problem below.
My lay out and system is a mess for while.

http://www.sidnet.vbweb.com.br/

Usuario = SOCORRO
SENHA = SOCORRO


Click IN THE LINK "Projetos" and in the GridView that is going to appear click in "Construcao Civil".

In the next screen "Projetos" is my problem.

The fields "Documento","Formato","Previsao de Inicio" and the others are going to insert in the DataTable to populate
the gridView as you can see.

when I click the button that "Relacionar" somewhat hidden these data are insert in the dataTable that is going to populate the gridView
In the inserting routine.

As you can see in the web page I am in a updating routine and the GridView is showing some records.This record
of course are already saved and I need to insert another ones using the same DataTable as before.

But in this case I will have somre records saved and others in the datatable/gridview not saved then I need to
save these ones.

Was I clear now?
Did you understand now?

Thanks a lot guys

Regards
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1460 | Replies: 13
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC