|
You can use the split method on the string class to break the text in the textbox into lines, then you will have a string array to work with.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am using a data grid view which loads data from the database and displays. Moreover, on my form are the buttons as INSERT(i.e for inserting records in database and grid), DELETE_SELECTED_ROWS(i.e for deleting records from database and grid). Now as you know that grids are editable so if any changes are made inside the grid then how to update.
Talking all in all I need to know how to update a dataset/datatable
<pre>
<code>
private void ManageCustomer_Load(object sender, EventArgs e)
{
LoadCustomers();
}
private void btnInsertInDataBase_Click(object sender, EventArgs e)
{
// Insert Customer In Database
DALHelper helper = new DALHelper();
helper.InsertCustomer(textBox1.Text);
LoadCustomers();
}
private void LoadCustomers()
{
// Load Cashiers from Database
DALHelper dal = new DALHelper();
dataGridView1.DataSource = dal.GetCustomers();
dataGridView1.Refresh();
}
List<int>customerIDsToDelete = new List<int>();
private void btnDELETE_Click(object sender, EventArgs e)
{
// Iterate all the Rows in DataGridView Rows Collection
foreach (DataGridViewRow row in dataGridView1.Rows)
{
// Get the status of CheckBox in the current Row
bool deleteStatus = Convert.ToBoolean(row.Cells[0].Value);
// Get the CashierID of the Cashier in the current row
int customerID = Convert.ToInt32(row.Cells[1].Value);
if (deleteStatus)
{
row.Selected = true;
customerIDsToDelete.Add(customerID);
}
}
// Remove From DataGridView
foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(selectedRow);
}
// Remove From Database
DALHelper dal = new DALHelper();
dal.DeleteCustomers(customerIDsToDelete);
customerIDsToDelete.Clear();
// Load Cashiers from Database
LoadCustomers();
}
}
}
// THE FOLLOWING IS THE CODE I AM USING IN MY DAL(Data Access Layer) CLASS
public DataTable GetCustomers()
{
string query = "SELECT * FROM Customer_2";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
return table;
}
// For Inserting Customers
public void InsertCustomer(string customerName)
{
string query = "INSERT INTO Customer_2 (CustomerName) VALUES (@CustomerName)";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = customerName;
con.Open();
com.ExecuteNonQuery();
con.Close();
}
// For Deleting Customers
public void DeleteCustomers(List<int> customerIDsToDelete)
{
string query = "DELETE FROM Customer_2 WHERE CustomerID = @CustomerID";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
SqlTransaction tr = null;
try
{
con.Open();
tr = con.BeginTransaction();
com.Transaction = tr;
com.Parameters.Add("@CustomerID", SqlDbType.Int);
foreach (int item in customerIDsToDelete)
{
com.Parameters["@CustomerID"].Value = item;
com.ExecuteNonQuery();
}
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
throw ex;
}
finally
{
con.Close();
}
}
</code><code></code><code></code></pre>
|
|
|
|
|
"...Now as you know that grids are editable so if any changes are made inside the grid then how to update..."
sorry i didn´t check your code because of this sentence
you don´t edit that DataGridView, you edit the database
in sql database, you create Store Procedures that you trigger in an c# event like button click
the SP you create are: insert row, update row, delete row etc etc etc
so, to make changes in the DB you have to trigger the procedure you want, after, show it in the DGV
(later, don´t forget to use crystal report to display and print data)
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I have a web service (Called ABWebService) that I have created that contacts someone else's webservice (ZWebService). My main project has a reference to ABWebService and also has a reference to ZWebService, which it needs to contact directly. The problem I have is if I create a WebMethod in ABWebService that gets passed an object from ZWebService in the web method it is expecting and object of type ZWebService. But in the Main Project if I call the web method in ABWebService the object type for what I am passing is ABWebService.object, even though the type of object I want to pass to it is ZWebService.object.
It then says I can't do this because they are different types.
Any suggestions?
|
|
|
|
|
Your issue is not coming out very clear.
|
|
|
|
|
how do i import
this reference is not availbale in device application
any way to solve???
pls help................
This code was posted by me...
|
|
|
|
|
It won't work because none of the Deployment classes are supported by the .NET Compact Framework used by devices.
You're only recourse is to either find a 3rd party library that offer equivilient functionality (I don't know of any) or make your own from scratch.
|
|
|
|
|
why not you use Reflection to load the assembly ??
Also mind that, you can only call Deployment dlls from Compact framework.
|
|
|
|
|
reefleciton??
what is taht
pls explain
This code was posted by me...
|
|
|
|
|
you dont know about Reflection classes ?
Even .NET itself reads everything using Reflection, when you take reference to a dll.
System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFile("Path");
Read basics of System.Reflection classes to get the idea. Its very simple.
|
|
|
|
|
I'm trying to make my program take a screenshot of a webbrowser after it finishes navigating and all I seem to be able to do is take a screenshot of it before it finishes navigating (a white rectangle). It's probably something very simple that I just keep missing, but am getting too annoyed to see it.
I stepped through it and apparently it takes the screenshot when the webBrowserForScreenShot is called after Navigate has been called, but no image is present. However the url is set for the webbrowser to the address it was sent by navigate. I also tried a while loop until webBrowser.ReadyState = complete, but ended up in an infinite loop. I tried adding Application.DoEvents(); as the action in the loop and then end up with a black rectangle. Btw, it does load the page after all is said and done, just too late to be a part of the screenshot. Any help would be great!
public ScreenShotWin()
{
InitializeComponent();
openWebBrowser();
}
public void openWebBrowser()
{
webBrowser1.Navigate("http://google.com");
}
private void webBrowserForScreenShot(object sender, WebBrowserDocumentCompletedEventArgs e)
{
IntPtr htmlWindow = webBrowser1.Handle;
CaptureWindowToFile(htmlWindow, "C:\\Interbank.bmp", ImageFormat.Bmp);
}
this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowserForScreenShot);
|
|
|
|
|
This is because a DocumentComplete event fires once for every frame in the WebBrowser. However, the second event argument has a Url property. If e.Url == webBrowser1.Url , then the control has finished loading the top-level frame; this is usually the browser window.
I got some of this from MSDN forums, here. If the == operator doesn't work, you could also try the Equals method
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Actually, the URLs matching is another one of fun parts. When it finishes navigating, the URLs match, the page is still not loaded.
It turned out to be a threading issue. I created a timer after my webbrowser navigated and checked per every 1000 ticks if the readystate was equal to complete. Very annoying, but it works now. A lesson well learned about trusting documentation.
Thank you for your help.
|
|
|
|
|
Hello,
VS 2008 SP1
I have created a application that I have installed on the user computer. However, I want the application to be self-updating. But I am not sure if this would really update the application.
The application will download all the files from the web server, and replace the files in the directory where the program as been installed to. The user will restart the application.
I am just want to be sure, because I can't replace the installed files with the updated ones. As the application will be running. So really the application cannot delete/replace itself.
So, I was thinking that I could download into another directory, if the program is installed in this directory 'program files/application/1.0.0' then I could download the files to 'program files/application/1.0.1'.
However, when the program restarts, how can it know that it has to execute from the 1.0.1 directory?
I can't use clickonce or the updater block for this.
Many thanks for any advice,
|
|
|
|
|
The first thing to spring to mind is the terrible practice of downloading the new files to a temp folder, then creating a run once on startup shortcut to a small app that copies the new files over the old ones and if necessary deleting the temp folder. Then prompting the user to reboot and doing it for them if they say OK.
But as I said it is a terrible practice, so I hope someone else has a better solution for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
I use the following in a console app:
/* Not Visual Studio Resource File **********************************************************/
#ifdef APSTUDIO_INVOKED
#error This file is not editable by Microsoft Visual C++, use a text editor.
#endif
/* Header Files *****************************************************************************/
#include "Interface.h"
#include "Resources.h"
/* Icon Files *******************************************************************************/
IDI_C14_App ICON "Wrench.ico"
/* Version Resource *************************************************************************/
#define VER_FILEVERSION C14ROM_Major, C14ROM_Minor, C14ROM_Ver, C14ROM_Build
#define VER_FILEVERSION_STR C14ROM_Version
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "ROM Initialization Program"
#define VER_INTERNALNAME_STR "C14ROM"
#define VER_ORIGINALFILENAME_STR "C14ROM.exe"
#define VER_PARTNUMBER D5502
#define VER_PARTNUMBER_REV C14ROM_Build
#include "Version.rc"
Is there a way I can incorporate this into a VC# project without having to learn to do this from scratch? I can do small adjustments to the original file, but don't want to start from nothing.
Jer 29:11
|
|
|
|
|
Al_S wrote: Is there a way I can incorporate this into a VC# project without having to learn to do this from scratch?
Nope. It's not usable in it's current form. This file just sets up macros for the compiler. Whenever the compiler finds "VER_FILEVERSION" in the code, it gets replaced with "C14ROM_Major, C14ROM_Minor, C14ROM_Ver, C14ROM_Build". And so on down the line for each #define. You'd have to write equivilent C# code to do something similar. C# doesn't support macros like C/C++ does.
Oh, there's also an icon resource defined, which is easy enough to add to your project as long as you have the .ico file. You do have the .ico file, correct?
|
|
|
|
|
How do I translate this then? Is there a link to a tutorial that shows how to do this in C#? I've never had to do this in C#.NET and Win32 resources were usually done from scratch because they were small enough as shown.
I do have the icon file. That's the least of it
Jer 29:11
|
|
|
|
|
I just completed a file section on a BBS I just setup and I wanted to add an option to download files from it. From what I have read I need to find out how to Initialize a protocol in a BBS.
I'm trying to use FDSZ and GSZ and I get the same problem, 'No port Detected'
Both programs require a Fossel. x00 or bnu I have tried to use.
After researching this for the last 30 days. I find a lot if note on
the protocols them self's. Just nothing related to Initializing the bbs
Does any one now how to do this.
|
|
|
|
|
I am trying to write a small application for my domain that will delete files on the clients machine.
i have the delete code already also i have wrapped this around impersonation code so i can have admin creds
i am able to open file dialog and choose the txt file i want etc.. but after that im lost. I want to load the machine names i have listed in the machines.txt file and then hit search and it will go out and delete the file i have chosen.
for feed back i have a listview that is setup with grid lines and detail view with 2 columns machine and status
so once i load the machines.txt and i hit search button it will go through each machine name in the txt file go out to that pc remotely delete the file then will populate the listview with machine name and status saying deleted or file not found.
Thank you for your time!
-summey
|
|
|
|
|
ryan.summey wrote:
i am able to open file dialog and choose the txt file i want etc.. but after that im lost. I want to load the machine names i have listed in the machines.txt file and then hit search and it will go out and delete the file i have chosen.
I didn't get this line. You want to read machine name or you have stored machine name in machines.txt file?
Can you please give me some clarification on this
Hope to help you !
|
|
|
|
|
sorry for the confusion. In my program i have a menu and in that menu is file > open
click open and you can navigate to your machine.txt file or whatever as long as its .txt
once you click it hit ok i want it to load each machine name with in that .txt file
the reason for this is my applicatation deletes a file i have specified in the code. i dont want to do this manually entering in the machine names etc... I would like them to be all loaded then i hit search and it will go out and check each machine remotely delete the file if so show in the listview under status file deleted or file not found then move on to the next machine from the text file.
www.summeylabs.com/images/authplay.jpg
click that link and you can see what im talking about thank for your help.
|
|
|
|
|
Hey dude I think it will be easy if u try a database with 1 table ......... just my suggestion
|
|
|
|
|
I am on a domain is it possible to pull the machine names from Active directory? but my goal is to do this all at once i dont want to have to keep hitting search i want to load the names and hit search and it goes out if it dosnt find it keep moving it it does delete the file then keep moving till the end of the list.
|
|
|
|