pitic 15 Newbie Poster

You could do this if you create your own Image class. Something like:

public class MyImage
{
    string Path { get; private set; }
    Image Image { get; private set; }

    public MyImage (string path, Image image)
    {
        Path = path;
        Image = image;
    }

    public bool Equals(MyImage secondImage)
    {
        if (secondImage == null)
        {
            return false;
        }
        return string.Compare(Path, secondImage.Path) == 0;
    }
}

What this does is compare the paths used by two MyImages and if they are the same returns true;

pitic 15 Newbie Poster

To extend on BackgroundWorker that gusano79 suggested you can update each row of the DataTable in the DoWork method (foreach row do a separate thread with Verificare_Online_single) and on RunWorkerCompleted do the update do the database using the DataTable.

pitic 15 Newbie Poster

My guess is you are talking about a Singleton. Click Here

pitic 15 Newbie Poster

Good thing you specified to send a piece of his code. Otherwise you could have received a photo of a car missing it's wheels. :)

pitic 15 Newbie Poster

Use a byte array (byte[]) and then work with it using streams (memory, file...).

pitic 15 Newbie Poster

The TextBox has a TextChanged event where you can do your logic. However, that's not smart. As every input in that TextBox would fire-up the event. You can narrow it down to only fire-up when "Enter" key is pressed inside the TextBox (check if event args key is Enter).

As for the calculations... simple select from database where CustomerId = TextBox.Text and set Label.Text = value of calculations. If you don't know the syntax... Click Here

pitic 15 Newbie Poster

There is a AS.NET thread under Web Development tab.

pitic 15 Newbie Poster

Perhaps because you are using "Table" as table name which is a reserved word. I'm not sure since I cannot test it right now. But just a thought...

pitic 15 Newbie Poster

I really can't tell from the 2 methods you posted how are you handling things. For starters, what library are you using to connect to the webcam.

Also by lokking at your bug description, my best guess is that when you close the form you should also close the streaming and restart it on form open.

And one more thing

// resume the video capture from the stop
webcam.Start(this.webcam.FrameNumber);

Are you trying to resume from a frame in the past? Aren't you doing a live streaming? Maybe posting your form code could be more helpful as I'm having trouble understanding what it is supposed to do.

pitic 15 Newbie Poster

I've never used it before, but I think you can use Microsoft Windows Image Acquisition (WIA). Add a reference to your project and build your application using the classes available in this library.

pitic 15 Newbie Poster

search google for "connect to <enter your DB server here> from c#" (if you want to send the info to a DB). After actually failing on something come here with your problem.
Failing to start a project is not going to be answered here.

pitic 15 Newbie Poster

for starters... do this and then come back when you're stuck:

  • connect to fingerprint device through code
  • get stream of bytes from fingerprint device and serialize into string
  • send to other computers databases
pitic 15 Newbie Poster

Here's what I would do (did not write this in an environment so there may be some typos):

//from line 179 - 199
for (int i = 0; i < dt.Rows.Count; i++)
{
    var currentRow = dt.Rows[i];
    cui = currentRow["cui"].ToString().Trim();
    cod_asis = currentRow["cod_asis"].ToString().Trim();
    cui = Main_App.Clase.VerificareCIF.FormatezCIF(cui);
    Verificare_Online_single(cui, cod_asis, ref dt.Rows[i]);        
}

// refactored method
private void Verificare_Online_single(string cui, string cod_asis, ref DataRow dr)
{
    SqlCeConnection connection = new SqlCeConnection(Properties.Settings.Default.dbPartnersConnectionString);
    string update = "";
    string tva = "NU";
    string adresa = "";
    string fax = "";
    string denumire = "";
    string tel = "";
    string regCom = "";
    string judet = "";
    string platitorTVA = "NU";
    string codPostal = "";
    string dataS = "";
    string dataE = "";
    try
    {
        if (Main_App.Clase.VerificareCIF.ValidareCIF(cui)) //first where this condition is true
        {
            string rsp = "";
            try
            {
                using (WebClient client = new WebClient())
                { rsp = client.DownloadString("server bla bla" + cui); }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "   Eroare la aducerea de pe server");
            }
            try
            {
                if (rsp.Length > 0 && rsp.Trim() != "")
                    rsp = rsp.Remove(rsp.Length - 1, 1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (rsp != null || rsp.Trim() != "")
            {
                string mesaj = "";
                string[] words = rsp.ToString().Split('|'); //putting the server response in an array;
                //getting data from the array
                denumire = words[1];
                adresa = normalizare(words[3]);
                judet = normalizare(words[5]);
                regCom = normalizare(words[7]);
                update = regCom;
                tel = words[13];
                fax = words[15];
                codPostal = words[11];
                if (words[31].Trim() != "NU")
                    platitorTVA = "DA";

                // modyfing …
pitic 15 Newbie Poster

Verificare_Online_single(cui, cod_asis, i, dt2);

You are passing dt2 as parameter to the method, shouldn't it be dt? dt2 is the new empty table and you said you are doing an update.

DataTable dt2 = CreateTable(dt.Rows.Count);

My code will not work since it searches the dt for a row where the value "cod_asis" equals something. And since your parameter is dt2 (empty table) it can't find anything.

pitic 15 Newbie Poster

You can create a constructor for Form2 that accepts a string parameter and pass that value when showing the second form. Be sure to set the textbox text on second form on Init().

pitic 15 Newbie Poster

(edited las message as I saw the second line after)

it means it found no rows that match the criteria. Do a check if rowsFound.Length > 0 before setting the values for rowsFound[0].

pitic 15 Newbie Poster

Run a step-by-step debug and give us more details about what's not working. Or paste full code.

pitic 15 Newbie Poster

Are you trying to save in the table where the update came from? Just add a column where to store it and pass the hostname as value in the insert.

pitic 15 Newbie Poster

He is using SQL Compact Edition which does not support stored procedures (as I know)

pitic 15 Newbie Poster

Try this after filling the DataTable (in your for loop or whatever you use to increment i)

var rowsFound = dt.Select("<unique identifier from table>=" + value);
rowsFound[0]["cui"] = cui;
rowsFound[0]["denumire"] = denumire;
...
da.update(dt);
pitic 15 Newbie Poster

Like what? If you're accepting null values you should always do a null check before comparing. And in the example you provided it's not safe to cast the textbox.text as a DateTime unless you have some strict input checking. Rather do a DateTime.ParseExact if you know the date format.

pitic 15 Newbie Poster

Sounds great. Where are you stuck?

pitic 15 Newbie Poster

Did you install the MySql Connector on the machine where you are using the application? As i recall, a while back when using mysql and c# I had to install the connector everywhere.

pitic 15 Newbie Poster

== and != are referring to object comparisons. If you want to check wether 2 DateTime values are not equal just do

if (DateTime.Compare(date1, date2) != 0)
{
}
pitic 15 Newbie Poster

I think Momerath is saying this:
You can either install MySql Connector on the machine where you are using the application, or include the dll files for MySql connector in your installer so they are copied over to the machine where you are installing.

pitic 15 Newbie Poster

If you are trying to compare 2 DateTime objects use DateTime.Compare(date1, date2).
Results are:
-1 if date1 < date2
0 if date1 = date2
1 if date1> date2

pitic 15 Newbie Poster

How can i inject the namespace into an xml file which doesn't have one? I scane the file from a 2d barcode, and, the creator decided to not write the namespace info into the xml. So i have to add it after scanning. How can i do that?

pitic 15 Newbie Poster

so i have managed to resolve the java.util.zip.ZipException: invalid entry size exception. Instead of reading the inputstream into a new file then open it as a zip file i have read the input stream directly into a zipoutputstream. That creates a correctly configured zip file and i can extract it from java.

The only problem remains that the barcode is encoded with base256 algorithm and now i can't get a readable output.

        protected void dataAvailable(SerialPortEvent event)
        {
            try
            {
                byte[] decoded;
                if (is.available() > 0) 
                {
                    ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream(winFile));
                    outStream.putNextEntry(new ZipEntry("array"));
                    byte[] buffer = new byte[1024];
                    int bytesRead;
                    while ((bytesRead = is.read(buffer)) > 0) {
                        outStream.write(buffer, 0, bytesRead);
                    }

                    outStream.closeEntry();

                    outStream.close();
                    is.close();   
                    String xml = unzipFile(winFile);
                }                
            }
            catch(Exception exc)
            {
                exc.printStackTrace();
            }
        }

The program is ok... i get the output file, only problem is how do i decode the base256 into utf-8 (my guess) so it creates the zipoutputstream with the xml file inside. (because now it does create it but the xml is encoded to something like PK- Iw¤@\Ś<˙˙˙˙˙˙˙˙ array e -‹= (first part of file only)

As I now the zip file must begin with "PK" and as I see the file inside the zip is called array. This is why I created the ZipEntry called "array". But it puts all the input stream in the file inside the zip. Which I don't know if it's ok.

pitic 15 Newbie Poster

I have a task to create an app that scans a 2D code (DataMatrix) with a usb scanner (set to work as a serial port), then creat a zip file from the inputstream, unzip it and get an xml.

i have managed to scan the code, get the inputstream but i can't unzip it from java. I can open the zip file from explorer, and see a file called "array". If i open it as an xml i can see the info i want but also some bogus characters at the begining and end of file

Here's how the file looks inside: ˙˙˙˙ g<P SC="ABCDE" SN="1000000001" PS="111144" CN="2012" CC="1417856" OU="CAS-B" ID="2012-05-04" CT="CLN" />

here is the dataAvailable event

        protected void dataAvailable(SerialPortEvent event)
        {
            try
            {
                if (is.available() > 0) 
                {
                    int numBytes = is.available();
                    readBufferArray = new byte[numBytes];
                    int readBytes = is.read(readBufferArray);
                    String one = new String(readBufferArray);
                    System.out.println("readBytes " + one);
                }
                FileOutputStream out = new FileOutputStream(winFile, true);
                out.write(readBufferArray);
                out.close();
                String xml = unzipFile(winFile);                
            }
            catch(Exception exc)
            {
                exc.printStackTrace();
            }
        }

Now if I try to exctract the xml from the zip file using this method:

 public static String unzipFile(File fileName)
{
    try
    {
        String destinationname = "d:\\temp\\";
        String outPath = "";
        byte[] buf = new byte[1024];
        ZipInputStream zipinputstream = null;
        ZipEntry zipentry;
        zipinputstream = new ZipInputStream(
            new FileInputStream(fileName.getPath()));

        zipentry = zipinputstream.getNextEntry();
        while (zipentry != null) 
        { 
            //for each entry to be extracted
            String entryName = zipentry.getName();
            System.out.println("entryname "+entryName);
            int n;
            FileOutputStream fileoutputstream;
            File …
pitic 15 Newbie Poster

Hy,

I trying to create a windows forms app that also starts a webservice that hosts some webmethods. The webservice is used by different users that connect to it to generate some data. The webservice, in his turn, connects to a public webserver with a certificate from a usb token.

Now why I'm trying to get this to work is:

  • when my webservice access the public webservice the first time it requires authentification with the certificate from the usb token, which pops-up a window to insert the token PIN number.
  • if i host the webservice in a webserver (IIS) the window never pops up because iis is not interactive
  • i can make the app only window forms based but then i'd have to use tcp protocol which i do not trust for file transfers.
  • web service uses http + forms allow me to popup the pin dialog.

But how can i combine them. In development mode i can instanciate the webservice and call it's functions... but that's only local... How ca i create an instance and make it remotely available.

Thanks

pitic 15 Newbie Poster

Hy,
I have created a webservice (asmx) which has some webmethods. In same project i also have a webpage (aspx) with some multiline texboxes
which i want to use as log output from webmethods.
If i call a webmethod from another prorgram i want to display in the textboxes the oputput of that method. How can i do that? I can populate the textbox but only from the page. The webservice doesn't write anything to it.
I have made a static reference to the webpage and made the textbox public.

public static MainForm instance { get; private set; }

protected void Page_Load(object sender, EventArgs e)
{
    instance = this;
}

And I can access it from the asmx file and set the text property but i can't see any output on the page.

Thanks

pitic 15 Newbie Poster

Hy,
I have created a webservice (asmx) which has some webmethods. In same project i also have a webpage (aspx) with some multiline texboxes
which i want to use as log output from webmethods.
If i call a webmethod from another prorgram i want to display in the textboxes the oputput of that method. How can i do that? I can populate the textbox but only from the page. The webservice doesn't write anything to it.
I have made a static reference to the webpage and made the textbox public.

public static MainForm instance { get; private set; }

protected void Page_Load(object sender, EventArgs e)
{
    instance = this;
}

And I can access it from the asmx file and set the text property but i can't see any output on the page.

Thanks

MOVED TO ASP.NET Click Here

pitic 15 Newbie Poster

as an addition to C#Jaap. if you want to then compare to another string (lets say username and password stored in database) and the char is not all upper/lower case use this:

string username = textbox1.text;
if (username.Equals("string from database", StringComparison.CurrentCultureIgnoreCase))
{
}

if you're using string in languages with special characters use InvariantCultureIgnoreCase

pitic 15 Newbie Poster

i used this to populate

dataGridView1.Rows.Add("1000");
dataGridView1.Rows.Add("1653");
dataGridView1.Rows.Add("dweqf");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("₪ 10,500");
dataGridView1.Rows.Add("קרקע מתוך 0");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("שיקמה");

and i've configured dataGridView1.RightToLeft = RightToLeft.No setting that property to yes does indeed right from right to left but only on some characters. like ("₪ 10,500") is printed as "₪ 10,500". as far as i can see, not all the characters are right to left writing.

when moving cursor through the characters to delete them on some chars "backspace" works as intended (deleting from right to left) but on some it deletes the other way (from left to right). this is the same case with "delete" key.

and it happens inside the the same hebrew char string.

pitic 15 Newbie Poster

i have used the sample data you provided but not from access it was populated in the code.

(i actually don't have access installed)

pitic 15 Newbie Poster

if you need to disable your internet connection the simplest way is to change your gateway
to some ip that doesn't provide the functionality.

ex:

your curent settings:

  • ip:
  • 192.168.1.100

  • netmask:
  • 255.255.255.0

  • gateway:
  • 192.168.1.1

your modified setting:

this method still lets u use the local network. if you want to disable that too just change your ip address too.


sample code to change ip address

public void setIP(string ip_address, string subnet_mask)
        {
            ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection objMOC = objMC.GetInstances();

            foreach (ManagementObject objMO in objMOC)
            {
                if ((bool)objMO["IPEnabled"])
                {
                    try
                    {
                        ManagementBaseObject setIP;
                        ManagementBaseObject newIP =
                            objMO.GetMethodParameters("EnableStatic");

                        newIP["IPAddress"] = new string[] { ip_address };
                        newIP["SubnetMask"] = new string[] { subnet_mask };

                        setIP = objMO.InvokeMethod("EnableStatic", newIP, null);
                    }
                    catch (Exception)
                    {
                        throw;
                    }


                }
            }
        }

sample code to change gateway

public void setGateway(string gateway)
        {
            ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection objMOC = objMC.GetInstances();

            foreach (ManagementObject objMO in objMOC)
            {
                if ((bool)objMO["IPEnabled"])
                {
                    try
                    {
                        ManagementBaseObject setGateway;
                        ManagementBaseObject newGateway =
                            objMO.GetMethodParameters("SetGateways");

                        newGateway["DefaultIPGateway"] = new string[] { gateway };
                        newGateway["GatewayCostMetric"] = new int[] { 1 };

                        setGateway = objMO.InvokeMethod("SetGateways", newGateway, null);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }
pitic 15 Newbie Poster

Hey, sorry for not posting in a while... busy weeks at work.

So, I tried to populate the grid with text you specified, but as far as i can see it writes the text correctly. (meaning it's printed just like in the text file). i uploaded a screenshot for you to check if this is ok.

pitic 15 Newbie Poster

one way (not the best at all) is to create a table, insert the select results and pass that table as datasource to the grid since you are using datasources

and before app exit or whatever, just drop the table

pitic 15 Newbie Poster

i do :twisted:

pitic 15 Newbie Poster

hello there, i have a problem, it might be trivial but i cannot for the life of me understandw what is causing it.

so i have a numeric updown and based on the value, it loops and creates as many txtboxes as the value in hte numupdown. and then i have a loop that reads the text in these but its not working as intended.

    for (int i = 1; i <= numericUpDown1.Value;i++)
        {
            string textname = "txtName"+i;
            TextBox txtTemp = new TextBox();
            txtTemp.Location = new Point(x,y);
            txtTemp.Name = textname;
            txtTemp.Width = 100;
            grpCol.Controls.Add(txtTemp);

         }

this is the txtbox creating code.

and this is the read loop:

        for(int i =1; i <= numericUpDown1.Value; )
            {
                if (childControl.Name.EndsWith(i.ToString()))
                {
           if(childControl.GetType().ToString().Equals("System.Windows.Forms.TextBox"))
                    {
                        txt2.Text += ((TextBox)childControl).Text;
                    }
                    if (childControl.HasChildren)
                    {
                        IterateThroughChildren(childControl);
                    }
                }
                i++;
            }

and so when i run the code and creat 4 txtboxes like this

  txta1        txtb1
|_______|   |________|

  txta2        txtb2
|_______|   |________|

with the values being:

   1            2

   3            4

i get the output 3124, when i want 1234.
sorry if im being incoherent, but couldnt explain it better.

if you read this far... thank you:P

one question: why do you increment i inside the for loop?

pitic 15 Newbie Poster

the code was to test the characters if they are latin ascii or not. in the else clause you have to specify what to do with the non latin characters. please export your table data (or some of it if it's valuable data) in a csv file or text file (preferably column based) so i can test the else clause

pitic 15 Newbie Poster
pitic 15 Newbie Poster

this is not the best practice but it gets the job done if you need it fast.

ArrayList ar1 = new ArrayList();
ArrayList ar2 = new ArrayList();
ArrayList ar3 = new ArrayList();
ArrayList ar4 = new ArrayList();
ArrayList ar5 = new ArrayList();
ArrayList ar6 = new ArrayList();
string filePath = "file.txt";
StreamReader sr = new StreamReader(filePath);
while (sr.ReadLine() != null)
{
    string[] line = sr.ReadLine().Split("\t".ToCharArray());
    for(int i = 0; i < line.Length; i++)
    {
        ar1.Add(line[i]);
        ar2.Add(line[i + 1]);
        ar3.Add(line[i + 2]);
        ar4.Add(line[i + 3]);
        ar5.Add(line[i + 4]);
        break;
    }
 }
sr.Close();

This assumes you know the number of columns in the text file. If you later need to use the values from the array as integers just use Convert.ToInt32(ar1[0]) and so on.

pitic 15 Newbie Poster

Hello all, i want to make icon (shortcut to run my program) on System Tray (usually on Right bottom) with code, i'm using visual studio 2008 c#, on classlibrary project, thanks before :D

add a NotifyIcon control to the form. Then you can code the Form_Resize event to hide the form and the doubleclick event of the notifyicon to show the form.

pitic 15 Newbie Poster

try this to verify ascii code for each character in cell

//DataGridView dgv1 = new DataGridView();
for (int i = 0; i < dgv1.Columns.Count; i++)
            {
                for (int j = 0; j < dgv1.Rows.Count; j++)
                {
                    string cellValue = dgv1[i, j].Value.ToString();
                    foreach (char c in cellValue)
                    {
                        if (Convert.ToInt32(c) < 127)
                        {
                            //this is ascii
                        }
                        else
                        {
                            //this is not ascii
                        }
                    }
                }

of course this assumes your cells contain valid data (string, int...)

pitic 15 Newbie Poster

if you parsed the whole grid cell by cell, you could also parse the text in each cell and check each character's ascii code. if it's between 65-90 and 97-122 these are latin alphabet.

pitic 15 Newbie Poster

Thanks pitic

But it is even Enabled in IE also. It seems it doesn't depend upon the browser.

Any other suggestions

as far as i saw what you're trying to do can't be done with httpwebrequest because the request only downloads html code from the website you provide. try to see if inside the html code you receive there is a script tag with path and try to get the code from the script file not the html.

or open the site in firefox with the firebug addon to catch the script path and send the path to the webrequest


(don't know if this works though)

pitic 15 Newbie Poster

depends on what you're trying to achieve. you can populate comboboxes with values, u can use listview (choose detail view)

pitic 15 Newbie Poster

Hi, I am using HTTPRequest and HTTPResponse to get the page source of a site. and i'm getting a warning message "Enable JavaScript to view your site".

Is there any request i should add to enable JavaScript

since visual studio uses ie engine try enabling it in internet explorer and see if it works

IE settings Tools>> Internet option>> Secourity>> Custom level>> there click on radio button to enable active scripting

pitic 15 Newbie Poster

hello,
I have one text box and button common to 2 tabs containingdatagridviews each.when i click on the button in tab page 1 some data will fill up the text box and same for tabpage 2.
the issue is if i click the button again in tabpage 2,then new values should be filled up in the text box and the old values in text box for tab page 2 should be deleted and tab page 1 values should be retained in the multiline text box
can u please help me with the code

could you please provide an example more specific like: textbox1 on tab1 has "123" click button1... and so on