Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

how to create a barcode of type ean-13 in c# windows forms with sql server 2008 using StrokeScribe control.

$
0
0

Hi my name is vishal.For past 10 days i have been going nuts over of how to create barcode in c# windows forms with sql server 2008 using StrokeScribe control of version 4.3.2. i have done some coding here with some group boxes with no success.

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 STROKESCRIBECLSLib;
using System.Data.SqlClient;
namespace DRRS_in_Csharp
{
    public partial class Dialyzer : Form
    {
        Int32 dStepIndex;
         long pUserID = 1;
         SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
         SqlCommand cmd;
         SqlDataAdapter drp;
         DataSet ds;
         string str;
         DataTable dt;
        public Dialyzer()
        {
            InitializeComponent();
             SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            string SqlDataPull=("Select p.patient_id as patient_id,n.patient_first_name as patient_fname,n.patient_last_name as patient_lname from PATIENT_NAME6 n,PATIENT_ID6 p where n.patient_id=p.patient_id");
            SqlCommand cmd=new SqlCommand(SqlDataPull);
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                SqlDataPull=dr[0].ToString()+dr[1].ToString()+dr[2].ToString();
                cboPatientID.Items.Add(SqlDataPull);
            }
            dr.Close();

            string SqlDataPull1=("Select ManufacturerName from EQUIPMENTDATA");
            cmd=new SqlCommand(SqlDataPull1);
            cmd.Connection=conn;
            cmd.CommandType=CommandType.Text;
            dr=cmd.ExecuteReader();
            while(dr.Read())
            {
                SqlDataPull1 = dr[0].ToString(); 
                cboManufacturer.Items.Add(SqlDataPull1);
            }            
        }
        private void cboequipment_Type_Click(object sender,EventArgs e)
        {
            if(cboManufacturer.SelectedIndex==-1)
            {
                return;
            }
             SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
                    if (conn.State != ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandType = CommandType.Text;
            DataTable dt=new DataTable();
            cmd=new SqlCommand("Select * from EQUIPMENTDATA where ManufacturerName='"+cboManufacturer.Text+"' and volume='"+cboequipmentType.Text+"'",conn);
               // cmd=new SqlCommand("Select * from APPPREFER",conn);
                //if(dt.Rows.Count==-1)
                //{
                //    txtPVol.Text=cmd.Parameters.AddWithValue("@bundle_volume",SqlDbType.NText).Value.ToString();
                //}
        }
        private void cboManufacturer_Click(object sender,EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
              DataTable dt = new DataTable();
            dt.Clear();
            SqlDataAdapter adp = new SqlDataAdapter();

            cmd=new SqlCommand("Select volume from EQUIPMENTDATA where ManufacturerName='" + cboManufacturer.Text + "'",conn);
             adp = new SqlDataAdapter(cmd);
             adp.Fill(dt);  
        }
        private void cboPatientID_Click(object sender,EventArgs e)
        {
            if(cboPatientID.SelectedIndex!=-1)
            {
                btnSearch.Enabled=true;
                button3.Enabled=true;
                 SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;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 patient_id="+cboPatientID.GetItemText(cboPatientID.SelectedIndex)+"'",conn);
                if(txtDID.Text.Length>5)
                {
                    txtDID.Text=txtDID.Text.Substring(0,5);
                }
                DataTable dt=new DataTable();
                if(dt.Rows.Count==-1)
                {
                    if((cmd.Parameters.AddWithValue("@virology",SqlDbType.Int).Value.GetHashCode()==0))
                    {
                        txtDID.Text=txtDID.Text+1;
                    }
                        else
                        {
                        txtDID.Text=txtDID.Text+0;
                    }
                }
                    else
                    {
                        txtDID.Text=txtDID.Text+0;
                    }
                lblPID.Text=cboPatientID.Text.Substring(cboPatientID.Text.IndexOf(cboPatientID.Text,1));
                barCDialyzer.Alphabet=STROKESCRIBELib.enumAlphabet.AZTEC;
                barCDialyzer.CtlText=txtDID.Text+(char)9;
                barCOrg.Alphabet=STROKESCRIBELib.enumAlphabet.AZTEC;
                barCOrg.CtlText=txtDID.Text+(char)9;
                int rc=0;
                 rc =barCOrg.SavePicture("D:\\Workarea\vishal\vishal c#\\DRRS in Csharp\\DRRS in Csharp\bar1.bmp", STROKESCRIBELib.enumFormats.BMP,barCOrg.BitmapW,barCOrg.BitmapH);
                if(rc>0)
                {
                    MessageBox.Show(barCOrg.ErrorDescription);
                }
                else
                {
                    btnSearch.Enabled=false;
                    button3.Enabled=false;
                }
        }
        }
private void button1_Click(object sender, EventArgs e)
        {
            if(txtDID.Tag.ToString()=="0")
            {
                btnNext.Enabled=true;
                button1.Enabled=false;
                txtDID.Enabled=false;
                barCDialyzer.Alphabet=STROKESCRIBELib.enumAlphabet.AZTEC;
                barCDialyzer.CtlText=txtDID.Text+(char)9;
                 barCOrg.Alphabet=STROKESCRIBELib.enumAlphabet.AZTEC;
                barCOrg.CtlText=txtDID.Text+(char)9;
                int rc = 0;
                rc = barCOrg.SavePicture("D:\\Workarea\vishal\vishal c#\\DRRS in Csharp\\DRRS in Csharp\bar1.bmp", STROKESCRIBELib.enumFormats.BMP, barCOrg.BitmapW, barCOrg.BitmapH);
                if (rc > 0)
                {
                    MessageBox.Show(barCOrg.ErrorDescription);
                }
        }
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (fmeDEntry.Visible == true)
            {
                fmeDEntry.Visible = false;
            }
            if (optDEntry1.Checked == false)
            {
                fmeBarCode.Visible = false;
                fmeStep1.Visible = true;
                
            }
            
            {
                if (dStepIndex == 0)
                {
                    string dFieldName = "";
                    Boolean vEmptyB = false;
                    if (cboManufacturer.SelectedIndex == -1)
                    {
                        vEmptyB = true;
                        dFieldName = "Please select a manufacturer";
                    }
                    else if (cboequipmentType.SelectedIndex == -1)
                    {
                        vEmptyB = true;
                        dFieldName = "Please select size of dialyzer";
                    }
                    else if (txtMFRRefNo.Text.ToString().Trim() == "")
                    {
                        vEmptyB = true;
                        dFieldName = "Please enter equipment reference number";
                    }
                    else if (txtMFRLotNo.Text.ToString().Trim() == "")
                    {
                        vEmptyB = true;
                        dFieldName = "Please enter equipment lot number";
                    }
                    else if (txtPVol.Text.ToString().Trim() == "")
                    {
                        vEmptyB = true;
                        dFieldName = "Please enter packed_volume of equipment";
                    }
                    if (vEmptyB == true)
                    {
                        MessageBox.Show(dFieldName + "should not be empty");
                        return;
                    }
                    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
                    if (conn.State != ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandType = CommandType.Text;
                    string dDID = "";
                    cmd = new SqlCommand("select max(agn) from DIALYSER", conn);
                    cmd = new SqlCommand("Insert into DIALYSER(agn)" + "Values(@agn)", conn);
                    DataTable dt = new DataTable();
                    if (dt.Rows.Count != -1)
                    {

                        if (cmd.Parameters.AddWithValue("@agn", SqlDbType.Int).Value is DBNull)
                        {
                            dDID = "1";
                        }
                        else
                        {
                            dDID = cmd.Parameters.AddWithValue("@agn", SqlDbType.Int).Value.ToString() + 1;
                            txtDID.Text = txtDID.Text.Replace(dDID.PadLeft(5), dDID.Length.ToString()) + dDID;
                        }
                    }
                    else
                    {
                        txtDID.Text = txtDID.Text.Replace(dDID.PadLeft(5), dDID.Length.ToString()) + dDID;
                    }
                }
                    fmeStep1.Visible = false;
                    fmeStep2.Visible = true;
                    fmeStep3.Visible = false;
                    btnNext.Enabled = false;
                    button1.Enabled = false;
                    txtDID.Focus();
                    }
                }
        private void fmeStep3_Enter(object sender, EventArgs e)
        {
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string dPatientID;
            dPatientID=cboPatientID.GetItemText(cboPatientID.SelectedIndex);
            Patient p=new Patient();
            p.loadPatient(dPatientID);

        }

        private void button3_Click(object sender, EventArgs e)
        {
            string dFieldName = "";
            Boolean vEmptyB=false;
            if(cboManufacturer.SelectedIndex==-1)
            {
                vEmptyB = true;
                dFieldName = "Please select a manufacturer";
            }
            else if(cboequipmentType.SelectedIndex==-1)
            {
                vEmptyB = true;
                dFieldName = "Please select size of equipment";
            }
            else if(txtMFRRefNo.Text.ToString().Trim()=="")
            {
                vEmptyB = true;
                dFieldName = "Equipment reference number should not be empty";
            }
            else if(txtMFRLotNo.Text.ToString().Trim()=="")
            {
                vEmptyB = true;
                dFieldName = "Equipment lot number should not be empty";
            }
           else if(txtPVol.Text.ToString().Trim()=="")
            {
                vEmptyB = true;
                dFieldName = "Packed volume of the equipment should not be empty";
           }
            else if(cboPatientID.SelectedIndex==-1)
            {
                vEmptyB = true;
                dFieldName = "Please select a patient";
            }
               if (vEmptyB==true)
            {
                MessageBox.Show(dFieldName+"should not be empty");
                return;
            }
              SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            cmd=new SqlCommand("Insert into DIALYSER(dialyserID,manufacturer,mfr_ref_number,mfr_lot_number,mfr_date,exp_date,start_date,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,@packed_volume,@dialyzer_size,@patient_id,GetDate(),@user_id)",conn);
            cmd.Parameters.AddWithValue("@dialyserID",txtDID.Text);
            cmd.Parameters.AddWithValue("@manufacturer",cboManufacturer.SelectedIndex);
            cmd.Parameters.AddWithValue("@mfr_ref_number",txtMFRRefNo.Text);
            cmd.Parameters.AddWithValue("@mfr_lot_number",txtMFRLotNo.Text);
            cmd.Parameters.AddWithValue("@mfr_date",dtMFRDate.Value);
            cmd.Parameters.AddWithValue("@exp_date",dtMFRexpDate.Value);
            cmd.Parameters.AddWithValue("@start_date",dtMFRstartDate.Value);
            cmd.Parameters.AddWithValue("@packed_volume",txtPVol.Text);
            cmd.Parameters.AddWithValue("@dialyzer_size",cboequipmentType.SelectedIndex);
            cmd.Parameters.AddWithValue("@patient_id",cboPatientID.GetItemText(cboPatientID.SelectedIndex));
            cmd.Parameters.AddWithValue("@user_id",pUserID);
            cmd.ExecuteNonQuery();
            ((MDIParent5)this.MdiParent).updateUserActivities(pUserID, 4,txtDID.Text + "Dialyzer detail was successfully assigned to patient="+cboPatientID.SelectedIndex+"");
            conn.Close();
            this.Close();

        }
 private void GetData(string ID)
        {
            DataTable dt = new DataTable();
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            conn.Open();
            SqlCommand cmd = new SqlCommand("Select * from EQUIPMENTDATA where ManufacturerName='" + cboManufacturer.Text + "' and volume='" + cboequipmentType.Text + "' and packed_volume='" + txtPVol.Text + "'", conn);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                cboequipmentType.Text = dt.Rows[3]["volume"].ToString();
                txtPVol.Text = dt.Rows[5]["packed_volume"].ToString();
            }
            conn.Close();
        }
        private void Dialyzer_Load(object sender, EventArgs e)
        {
            dtMFRDate.MinDate = dtMFRDate.Value;
            dStepIndex=0;
            fmeStep1.Visible=true;
            fmeStep2.Visible=false;
            fmeStep3.Visible=false;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

  private void txtDID_LostFocus(object sender, EventArgs e)
        {
            if (txtDID.Text.ToString().Trim() == "")
            {
                MessageBox.Show("Please enter Dialyzer ID to create", "DRRS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDID.Focus();
            }
            else
            {
                checkDialyzerID();
            }
        }
        private void checkDialyzerID()
        {
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            DataTable dt = new DataTable();
            cmd=new SqlCommand("Select * from DIALYSER where dialyserID="+txtDID.Text+"",conn);
            if (dt.Rows.Count != -1)
            {
                MessageBox.Show("The DialyzerID already exists.Please try with another", "DRRS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDID.Text = "";
                txtDID.Focus();
                txtDID.Tag = 1;
            }
            else
            {
                txtDID.Tag = 0;
                button1.Enabled = true;
                button1.Focus();
            }
            conn.Close();

        }
        private void dtMFRDate_ValueChanged(object sender, EventArgs e)
        {
            dtMFRstartDate.MinDate = Convert.ToDateTime("21/10/2013");
        }
        private void txtPVol_KeyPress(object sender, KeyPressEventArgs e)
        {

            // allows only numbers

            if (!char.IsNumber(e.KeyChar))
            {

                e.Handled = true;

            }

        }
 private void cboManufacturer_SelectedIndexChanged(object sender, EventArgs e)
        {
            GetData(cboManufacturer.SelectedItem.ToString());
             
        }
        private void cboequipmentType_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan46;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            str = "Select distinct(volume) from EQUIPMENTDATA where Manufacturername='" + cboManufacturer.Text + "'";
            cmd = new SqlCommand(str, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                txtPVol.Text = reader["packed_volume"].ToString();
            }
            conn.Close();
            reader.Close();

        }
  private void button5_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

Now that i Dialyzer is name of my form.I have 4 group boxes named fmeStep3,fmeStep2,fmeDEntry,fmeStep1. Now to problem i am facing is after processing of fmeDEntry and fmeStep1 i get fmeStep2 with no controls visible to user(except cancel button) i want to see this fmeStep2(group box) because i processing of this group box will be able to what dialyzer Id have i created. Then after processing of this group box will i be able to assign dialyzer Id to respective patients which i have done it in fmeStep3. I have 2 StrokeScribe controls named barCDialyzer and barCOrg. I am using StrokeScribe control version 4.3.2 and i cant upgrade my StrokeScribe control since it's my Boss orders that i create barcode of type ean-13 using StrokeScribe control of version 4.3.2.

Given below are properties of my barCOrg control.

AccessibeRole: Default

AlowDrop: false

Alphabet: EAN13

AztecECL:23

AztecMinLayer:1

BitmapH:1

BiwmapW:115

CausesValidation: true

CheckDigit:8

CodabarHasCheckDigit:false

Code11CheckDigits:1

Code39HasCheckDigit:false

Code39Ratio:2

CodePage:3

CompactPDF417:false

ECI:0

Enabled:true

GraphicsMode:Advanced

HBorderSize:10

I2of5Ratio:2

ISBN10:false

ITF14BearerBox:false

ITF14BearerWidth:5

ProcessTilde:false

QrECL:L

QrMinVersion:1

QuietZone2D:1

SaCount:0

SaID:0

SaPos:0

ShowText:true

TextJustify:true

TextOffset:0

UTF8:false

VBorderPercent:5

Visible:true:

Similarly for another StrokeScribe control named barCDialyzer it's properties which is in fmeStep2:

AccessibeRole: Default

AlowDrop: false

Alphabet: EAN13

AztecECL:23

AztecMinLayer:1

BitmapH:1

BiwmapW:115

CausesValidation: true

CheckDigit:8

CodabarHasCheckDigit:false

Code11CheckDigits:1

Code39HasCheckDigit:false

Code39Ratio:2

CodePage:3

CompactPDF417:false

ECI:0

Enabled:true

GraphicsMode:Advanced

HBorderSize:10

I2of5Ratio:2

ISBN10:false

ITF14BearerBox:false

ITF14BearerWidth:5

ProcessTilde:false

QrECL:L

QrMinVersion:1

QuietZone2D:1

SaCount:0

SaID:0

SaPos:0

ShowText:true

TextJustify:true

TextOffset:0

UTF8:false

VBorderPercent:5

Visible:true:

Can anyone tell me where have i gone wrong in processing of barcode of type ean-13 in c# windows forms with sql server 2008 using StrokeScribe control of version 4.3.2? Can anyone help me guide me on how to solve this problem?


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>