hi my name is vishal for past 1 week i have been breaking my head on how to show picture box datas in c# windows forms usingSystem.Diagnostics.Process.Start.?
i have a label inside picturebox and a StrokeScribe control which i also inside picturebox.
label name:lblPID,enabled:true and visible:true
StrokeScribe control name:barCOrg,enabled:true and visible:true
picturebox name:pictureBox1,enabled:true and visible:true
Given below is my code in c# windows forms with sql server2008 using StrokeScribe control:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace DRRS_CSharp
{
public partial class frmDialyzer : Form
{
int dStepIndex;
int pUserID;
public frmDialyzer()
{
InitializeComponent();
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
string PatientPull = ("Select p.patient_id as patient_id,n.patient_first_name as patient_fname,n.patient_last_name as patient_lname from patient_name n,patient_id p where n.patient_id=p.patient_id and n.status=1 and p.patient_id not in (Select patient_id from dialyser where deleted_status=0)");
SqlCommand cmd = new SqlCommand(PatientPull);
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
PatientPull = dr[1].ToString() + "_" + dr[2].ToString() + "(" + "0000" + dr[0].ToString() + ")";
cboPatientID.Items.Add(PatientPull);
}
dr.Close();
}
private void btnNext_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string str;
string value = ("Select max(agn) from dialyser");
cmd = new SqlCommand(value, conn);
str = cmd.ExecuteScalar().ToString();
conn.Close();
if (str == DBNull.Value.ToString())
{
txtDID.Text = "1";
}
else
{
txtDID.Text = (string.Format("0000"+(Convert.ToInt32(str) + 1).ToString()));
}
}
private void cboPatientID_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboPatientID.SelectedIndex != -1)
{
btnSearch.Enabled = true;
btnAssign.Enabled = true;
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd = new SqlCommand("Select * from patient_name where status=1 and patient_id=" + cboPatientID.GetItemText(cboPatientID.SelectedIndex) + "'", conn);
if (txtDID.Text.Length > 5)
{
txtDID.Text = txtDID.Text.Substring(5);
}
lblPID.Text = string.Format(cboPatientID.Text);
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string str;
string value = ("Select max(agn) from dialyser");
cmd = new SqlCommand(value, conn);
str = cmd.ExecuteScalar().ToString();
conn.Close();
if (str == DBNull.Value.ToString())
{
txtDID.Text = "1";
}
else
{
txtDID.Text = (string.Format("0000" + (Convert.ToInt32(str) + 1).ToString()));
}
barCOrg.Alphabet=STROKESCRIBELib.enumAlphabet.CODE128;
barCOrg.CtlText = txtDID.Text;
int rc = 0;
rc = barCOrg.SavePicture("bar2.bmp", STROKESCRIBELib.enumFormats.BMP, barCOrg.Width, barCOrg.Height);
if (rc > 0)
{
MessageBox.Show(barCOrg.ErrorDescription);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
btnNext.Enabled = true;
button1.Enabled = true;
txtDID.Enabled = false;
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string str;
string value = ("Select max(agn) from dialyser");
cmd = new SqlCommand(value, conn);
str = cmd.ExecuteScalar().ToString();
conn.Close();
if (str == DBNull.Value.ToString())
{
txtDID.Text = "1";
}
else
{
txtDID.Text = (string.Format("0000" + (Convert.ToInt32(str) + 1).ToString()));
}
barCOrg.Alphabet = STROKESCRIBELib.enumAlphabet.CODE128;
barCOrg.CtlText = txtDID.Text;
int rc = 0;
rc = barCOrg.SavePicture("bar2.bmp", STROKESCRIBELib.enumFormats.BMP, barCOrg.Width, barCOrg.Height);
if (rc > 0)
{
MessageBox.Show(barCOrg.ErrorDescription);
}
}
private void btnAssign_Click(object sender, EventArgs e)
{
string dFieldName = "";
Boolean vEmptyB = false;
if (cboManufacturer.Text.ToString().Trim() == "")
{
vEmptyB = true;
dFieldName = "Please select a Manufacturer";
}
else if (cboequipmentType.Text.ToString().Trim() == "")
{
vEmptyB = true;
dFieldName = "Please select size of dialyzer";
}
else if (txtMFRRefNo.Text.ToString().Trim() == "")
{
vEmptyB = true;
dFieldName = "Please enter reference number of the dialyzer";
}
else if (txtMFRLotNo.Text.ToString().Trim() == "")
{
vEmptyB = true;
dFieldName = "Please enter lot number of the dialyzer";
}
else if (txtPVol.Text.ToString().Trim() == "")
{
vEmptyB = true;
dFieldName = "Please enter packed volume of the dialyzer";
}
else if (cboPatientID.SelectedIndex == -1)
{
vEmptyB = true;
dFieldName = "Please select Patient ID";
}
if (vEmptyB == true)
{
MessageBox.Show(dFieldName + "should not be empty");
return;
}
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
int autoGenId = -1;
cmd = new SqlCommand("Insert into dialyser(dialyserID,manufacturer,mfr_ref_number,mfr_lot_number,mfr_date,exp_date,start_date,closed_status,deleted_status,packed_volume,dialyzer_size,patient_id,row_upd_date,user_id)" + "Values(@dialyserID,@manufacturer,@mfr_ref_number,@mfr_lot_number,@mfr_date,@exp_date,@start_date,@closed_status,@deleted_status,@packed_volume,@dialyzer_size,@patient_id,GetDate(),@user_id);Select @autoGenId = SCOPE_IDENTITY();", conn);
cmd.Parameters.AddWithValue("@dialyserID", txtDID.Text.ToString());
cmd.Parameters.AddWithValue("@manufacturer", cboManufacturer.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_ref_number", txtMFRRefNo.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_lot_number", txtMFRLotNo.Text.ToString());
cmd.Parameters.AddWithValue("@mfr_date", dtMFRDate.Value);
cmd.Parameters.AddWithValue("@exp_date", dtExpDate.Value);
cmd.Parameters.AddWithValue("@start_date", dtStartDate.Value);
cmd.Parameters.AddWithValue("@closed_status", 0);
cmd.Parameters.AddWithValue("@deleted_status", 0);
cmd.Parameters.AddWithValue("@packed_volume", txtPVol.Text.ToString());
cmd.Parameters.AddWithValue("@dialyzer_size", cboequipmentType.Text.ToString());
cmd.Parameters.AddWithValue("@patient_id", cboPatientID.SelectedIndex);
cmd.Parameters.AddWithValue("@user_id", pUserID);
cmd.Parameters.Add("@autoGenId", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
autoGenId = Convert.ToInt32(cmd.Parameters["@autoGenId"].Value);
((MDIParent1)this.MdiParent).updateUserActivities(autoGenId, 4, cboManufacturer.Text + "Dialyzer detail was added successfully");
if (MessageBox.Show("Dialyzer detail was added successfully.Do you want to print the barcode dialyzerID?", "DRRS", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
System.Diagnostics.Process.Start("bar2.bmp");
}
this.Close();
}The above code executes well with no problem at all.!
i get to see image/created image of StrokeScribe control(barCOrg) inSystem.Diagnostics.Process.Start.
But i dont get to see datas of label(lblPID) control in System.Diagnostics.Process.Start.
where bar2.bmp is name of image file to which i create and save mybarCOrg(barcode image) from c# windows forms with sql server2008 using StrokeScribe control.
So my problem is how to show/integrate picturebox(pictureBox1) control datas which containslabel(lblPID) and StrokeScribe control(barCOrg) inSystem.Diagnostics.Process.Start? I know that i have do some modifications in my c# code given above but i dont know how to do it.
I am aware that i have to use other shell commands(shell functions also) if necessary in c# windows forms for this purpose,
Can anyone help me please! Any help/guidance in solving this problem would be greatly appreciated.! Can some one help
me please.I am at the risk of losing my job.
vishal