M
madhuralakshmi
Guest
protected void readCOM3()
{
SerialPort sp3 = new SerialPort();
string weight3;
sp3.PortName = "COM3";
sp3.BaudRate = 9600;
sp3.DataBits = 8;
if (!sp3.IsOpen == true)
{
sp3.Close();
}else
{
sp3.Open();
}
weight3 = sp3.ReadLine().ToString();
//label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
label15.Invoke((Action)(() => label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
sp3.Close();
for (int k2 = 0; k2 < dataGridView1.Rows.Count; k2++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k2].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k2].Cells[5].Value = weiht.Text; sh = dataGridView1.Rows[k2].Cells[5].Value.ToString();
for (int k = 0; k < dataGridView1.Rows.Count; k++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k].Cells[5].Value = sh.ToString();
// label1.Text = sh.ToString();
label1.Invoke((Action)(() => label1.Text = sh.ToString()));
if (s >= 0 && s <= 300)
{
// label2.Text = "0.10";
label2.Invoke((Action)(() => label2.Text = "0.10"));
}
else
{
if (s >= 301 && s <= 10000)
{
label2.Invoke((Action)(() => label2.Text = "0.04"));
}
else
{
if (s >= 4001 && s <= 40000)
{
label2.Invoke((Action)(() => label2.Text = "0.02"));
}
else
{
}
}
}
loadt1();
Save();
scanrecode1();
// loadgrid();
loadt11();
}
}
}
}
}
int r1; string sh;
protected void readCOM6()
{
SerialPort sp = new SerialPort();
string weight6;
sp.PortName = "COM6";
sp.BaudRate = 9600;
sp.DataBits = 8;
if (!sp.IsOpen == true)
{
sp.Close();
}
else
{
sp.Open();
}
weight6 = sp.ReadLine().ToString();
label15.Invoke((Action)(() => label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
weiht.Invoke((Action)(() => weiht.Text = weight6.ToString()));
sp.Close();
for (int k2 = 0; k2 < dataGridView1.Rows.Count; k2++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k2].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k2].Cells[5].Value = weiht.Text; sh = dataGridView1.Rows[k2].Cells[5].Value.ToString();
for (int k = 0; k < dataGridView1.Rows.Count; k++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k].Cells[5].Value = sh.ToString();
// label1.Text = sh.ToString();
label1.Invoke((Action)(() => label1.Text = sh.ToString()));
if (s >= 0 && s <= 300)
{
// label2.Text = "0.10";
label2.Invoke((Action)(() => label2.Text = "0.10"));
}
else
{
if (s >= 301 && s <= 10000)
{
label2.Invoke((Action)(() => label2.Text = "0.04"));
}
else
{
if (s >= 4001 && s <= 40000)
{
label2.Invoke((Action)(() => label2.Text = "0.02"));
}
else
{
}
}
}
loadt1();
Save();
scanrecode1();
// loadgrid();
loadt11();
}
}
}
}
}
protected void loadget()
{
Thread thr1 = new Thread(readCOM3); Thread thr2 = new Thread(readCOM6);
thr1.Start(); thr2.Start();
weighttime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
this data should come in datagridview first data will come next time it shows error
Continue reading...
{
SerialPort sp3 = new SerialPort();
string weight3;
sp3.PortName = "COM3";
sp3.BaudRate = 9600;
sp3.DataBits = 8;
if (!sp3.IsOpen == true)
{
sp3.Close();
}else
{
sp3.Open();
}
weight3 = sp3.ReadLine().ToString();
//label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
label15.Invoke((Action)(() => label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
sp3.Close();
for (int k2 = 0; k2 < dataGridView1.Rows.Count; k2++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k2].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k2].Cells[5].Value = weiht.Text; sh = dataGridView1.Rows[k2].Cells[5].Value.ToString();
for (int k = 0; k < dataGridView1.Rows.Count; k++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k].Cells[5].Value = sh.ToString();
// label1.Text = sh.ToString();
label1.Invoke((Action)(() => label1.Text = sh.ToString()));
if (s >= 0 && s <= 300)
{
// label2.Text = "0.10";
label2.Invoke((Action)(() => label2.Text = "0.10"));
}
else
{
if (s >= 301 && s <= 10000)
{
label2.Invoke((Action)(() => label2.Text = "0.04"));
}
else
{
if (s >= 4001 && s <= 40000)
{
label2.Invoke((Action)(() => label2.Text = "0.02"));
}
else
{
}
}
}
loadt1();
Save();
scanrecode1();
// loadgrid();
loadt11();
}
}
}
}
}
int r1; string sh;
protected void readCOM6()
{
SerialPort sp = new SerialPort();
string weight6;
sp.PortName = "COM6";
sp.BaudRate = 9600;
sp.DataBits = 8;
if (!sp.IsOpen == true)
{
sp.Close();
}
else
{
sp.Open();
}
weight6 = sp.ReadLine().ToString();
label15.Invoke((Action)(() => label15.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
weiht.Invoke((Action)(() => weiht.Text = weight6.ToString()));
sp.Close();
for (int k2 = 0; k2 < dataGridView1.Rows.Count; k2++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k2].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k2].Cells[5].Value = weiht.Text; sh = dataGridView1.Rows[k2].Cells[5].Value.ToString();
for (int k = 0; k < dataGridView1.Rows.Count; k++)
{
r1 = dataGridView1.Rows.Count;
if (Convert.ToBoolean(dataGridView1.Rows[k].Cells["Export"].Value) == true)
{
dataGridView1.Rows[k].Cells[5].Value = sh.ToString();
// label1.Text = sh.ToString();
label1.Invoke((Action)(() => label1.Text = sh.ToString()));
if (s >= 0 && s <= 300)
{
// label2.Text = "0.10";
label2.Invoke((Action)(() => label2.Text = "0.10"));
}
else
{
if (s >= 301 && s <= 10000)
{
label2.Invoke((Action)(() => label2.Text = "0.04"));
}
else
{
if (s >= 4001 && s <= 40000)
{
label2.Invoke((Action)(() => label2.Text = "0.02"));
}
else
{
}
}
}
loadt1();
Save();
scanrecode1();
// loadgrid();
loadt11();
}
}
}
}
}
protected void loadget()
{
Thread thr1 = new Thread(readCOM3); Thread thr2 = new Thread(readCOM6);
thr1.Start(); thr2.Start();
weighttime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
this data should come in datagridview first data will come next time it shows error
Continue reading...