|
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using Dotnet67.Sales.DAL;
using Dotnet67.Sales.Items;
using Dotnet67.Sales.Persons;
using System.Data.SqlClient;
namespace Dotnet67.Sales.DAL
{
public class DALHelper
{
private readonly string CONSTRING3 = "CASHIER1";
public void InsertIntoCashier(string[] str,int[] val)
{
SqlConnection con = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
SqlCommand com = new SqlCommand(this.CONSTRING3, con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@CashierID", val[0]);
com.Parameters.AddWithValue("@CashierName", str[0]);
con.Open();
try
{
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dotnet67.Sales.DAL;
using Dotnet67.CommonTypes;
using Dotnet67.WinControls;
using System.Data.Sql;
using System.Data.SqlClient;
namespace Dotnet67.Sales.WinUI
{
public partial class ManageCashier : Form
{
public ManageCashier()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void ManageCashier_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dotnet67DataSet8.Cashier_2' table. You can move, or remove it, as needed.
this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
}
//This is the button for inserting values into grid view which is running perfect.
private void btnInsertIntoDataBase_Click(object sender, EventArgs e)
{
DALHelper dH = new DALHelper();
ManageCashier mc = new ManageCashier();
string[] str = new string[3];
int[] values = new int[3];
str[0] = txtName.Text;
dH.InsertIntoCashier(str,values);
dataGridView1.Refresh();
dataGridView1.RefreshEdit();
this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
//dataGridView1.AllowUserToDeleteRows.ToString();
}
//WHAT SHOULD I WRITE HERE IN THE BODY OF THE FOLLOWING BUTTON TO DELETE SUCCESSFULLY
private void btnDeleteFromGridViewAndDatabase_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
string stro ="DELETE FROM Cashier_2 WHERE CashierID='0'" ;
SqlCommand sqlDelete = conn.CreateCommand();
//sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID= '@cashierIDDataGridViewTextBoxColumn'";
sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID= '@CashierID'";
conn.Open();
sqlDelete.ExecuteNonQuery();
conn.Close();
}
THE FOLLOWING IS THE STORED PROCEDURE I WROTE FOR DELETING PURPOSE.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UET]
@CashierID nvarchar(50)
AS
BEGIN
DELETE FROM [dbo].[Cashiers] // DELETE from Table_Name where Coloumn=''
WHERE CashierID='@CashierID'
END
return
</pre>
Kindly if anyone could send me the code for this scenario.
I am using a data grid view which loads the data from the database table. My database table has only two attributes i.e, CashierID and CashierName. Now in my grid view placed on the form has an extra column i.e., the check box column. Now I want the user to check the rows he wants to delete and after checking the check boxes when he clicks the Delete button on the form then not only the selected values be deleted from the grid but also from the database table as well.<b></b>
|
|
|
|
|
Check this google result.[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
modified on Wednesday, July 22, 2009 2:58 PM
|
|
|
|
|
Hello All,
any idea why SendKeys.SendWait("{ENTER}") would restore a textbox to a previous state instead of submitting it? The problem cannot be reproduced manually, it submits every time. I do not have source control of the textbox or it's form, but should be able to submit it this way.
Thanks in advance.
|
|
|
|
|
I am not quite clear what you are saying, but I have one experience with SendKeys. I was trying to built a Bluetooth remote control and was using SendKeys to pass shortcut keys to Media Player. During testing I put this code behind a windows form button event and it works only first time then do nothing. But when I interfaced it to application and there were no UI event to trigger it it worked great. May be it helps you.
|
|
|
|
|
I am trying to grab the HTML source of a web page using the WebBrowser control. The page in question allows the user to query out a specific record (or set of records) from a database. Once these records have been listed, the user clicks on the desired title and javascript (or AJAX) overlays the current query page with the desired result display.
Problem:
If I try to programmatically grab the source, I get the original query page, not the overlayed desired result object. I can right click on the result and view source correctly but I can't seem to get it via code.
Anyone out there solved this issue in the past?
|
|
|
|
|
|
Michael Potter wrote: I am trying to grab the HTML source of a web page using the WebBrowser control.
I don't know what your requirements are but making an HTTP Request will get you the HTML code. It's far simpler than using a WebBrowser Control. You can use many different Base Class items to do this, one is the HttpWebRequest Class[^]
|
|
|
|
|
Thanks for the response.
I can't hide the functionality of the website I wish to scrape. I need its query interface to function as designed. I just can't get to the result source HTML. I am guessing it is inserted somewhere in the DOM but, I failed to locate it.
Essentially, a small square 'frame' appears (via java script) in the center if the page. If I right click on the small square 'frame' and choose [view source], I get what I want. If I right click OFF the small square 'frame' and choose [view source], I get the intial query HTML. I can't find the small square 'frame's HTML programically.
|
|
|
|
|
Michael Potter wrote: I can't hide the functionality of the website I wish to scrape.
Not sure what that means but if you must use a WebBrowser Control you could still use the URL from the control to make separate HTTP Requests to obtain the HTML. If you are trying to capture the dynamic changes to the DOM from any client side script then of course that will not help you.
Michael Potter wrote: I am guessing it is inserted somewhere in the DOM
Yes the DOM is the in memory version of the HTML. Again if you want the original stream from the server then just make a HTTP Request. If you need the dynamic HTML you will have to use the DOM. You will have to dig through the DOM documentation to find the parts you need. The basic concept is that each Frame has a Body and a Body element might give you access to the Inner HTML as Text.
|
|
|
|
|
Is the "frame" an iFrame? If it is that would explain your problem. An iFrame hold it's contents in it's own innerHTMl property so it wouldn't come back from the webbrowsers.Document.InnerHTML.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
After some javascript research - yes it is an IFrame.
I was able to capture the navigated URL and use HttpWebRequest (thanks led mike) to re-grab the IFrame when it is unsecured. I am unable to do so when it is secured data. I can't seem to hitch onto the rights the WebBrowser object has negotiated and I don't know how to negotiate a new set (I am not privy to the sites inner workings).
So the problem remains but, is better defined. How do I read an IFrame's source from the WebBrowser control?
|
|
|
|
|
What I would do, I'm sure there is a better way, is just append a JavaScript function and a hidden textbox to the innerHTML of the loaded document.
then call InvokeScript on the webbrowser to run your JavaScript (which should set the hidden textboxs text to the inner HTML of the iframe) then get the text from the textbox by getting the innerhtml and parsing out the textbox value.
Like I said I'm sure there is a better way.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Any idea on what the script would look like? I have not done a lot of web programming.
|
|
|
|
|
Found this on the net that allowed me to use HttpWebRequest (as suggested earlier).
http://mmarinov.blogspot.com/2007/10/using-exsiting-ie-cookies-with.html[^]
Thanks for all those that helped - refining the definition of the problem was very helpful.
Special Note: The WPF WebBrowser control doesn't even fire the events (IFrame navigation) necessary for the above solution. I have to use the Windows Forms version.
modified on Friday, July 24, 2009 2:07 PM
|
|
|
|
|
Public class MyClass<t> where T:int
{
}
why it's giving error. why .net framework not supporting
|
|
|
|
|
You can use struct
public class MyClass<T> where T : struct
{
}
or wrap an int in a (immutable?) class of your own and use that for the constraint.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
why this restriction.
Allowing struct. what problem allowing int?
|
|
|
|
|
You'd have to ask Anders Hejlsberg[^]. It's the way generics were built into C#. Search for generic type constraints and you might find some reasoning.
MSDN[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
public class MyClass<T>
{
...
}
MyClass<int> myClass = new MyClass<int>();
is this what you need ?
|
|
|
|
|
public class CplusEnumExtension<t, f=""> : whehre T:int
{
public CplusEnumExtension(int t)
{
enumT = t;
}
public bool Has(F findvalue)
{
return ((int)(object)enumT & (int)(object)findvalue)>0;
}
private int enumT=0;
}
In above code Has method i comparing int type that's why i expecting int from client side.
Apartment from this
I have implemented code below in C++ which client can use any type.(int, long etc) Is it possible in C#
//EnumT->int,long,Ulong...0x0001;
//Findvalue->ePDVE_DllError
//usage : CEnumerationExtensions<ULONGLONG,ePileplandesign_verificationError> obj(errorcode);
template <typename enumt,typename="" findvalue="">;
class CEnumerationExtensions
{
public:
CEnumerationExtensions(EnumT e)
: enum_(e)
{}
public:
bool Has(Findvalue value)
{
return ((enum_ & static_cast<enumt>(value))>0);
}
private:
EnumT enum_;
};
|
|
|
|
|
What types do you expect you should be able to use with "int" as a constraint?
You would only be able to use a single type - "int" itself (no uint, long etc. - those don't derive from int).
But if there's only one possible type argument, it doesn't make sense to use generics at all!
|
|
|
|
|
Hi,
you might want to enumerate the acceptable types and use common features:
public class MyClass<T> where T : int, long, float, double and now perform addition.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
But multiple constraints mean the type T must implement all of those.
There is no way to say "int OR float" (which would have to automatically generate an interface with all methods common between int and float).
But unfortunately, .NET doesn't support 'dynamic interfaces' (you declare an interface, and all classes having the appropriate methods will automatically implement it). Actually, I think VB10 will have something dynamic interfaces, but I guess it'll be implemented on top of Reflection/the DLR.
|
|
|
|
|
Thanks.
Syntax proposal: public class MyClass<T> where T in { int, long, float, double }
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Right, that would be good. Or the numeric types should implement some sort of IDoMath interface and we could use that.
I also want an enum constriant.
|
|
|
|