To get shown image name frim image capture control in windows application

Last Reply 10 days ago By pandeyism

Posted 10 days ago

Problem is when i updating some fiels then image is been updated a bydefault  a image

so i need same image should be updated which is showing in image capture box.

private void InsertGatepassEntry(int flag)
{
    string Image;
    string ImagePaths;
    string imagename;
    try
    {
        List<int> returnVal = new List<int>();
        int VendorPassId = Variable.hdnVendorPassId;
        string GatepassNo = string.Empty;

        string ContName = txtCmpNm.Text.Trim();
        string ContAdd = txtCmpAddress.Text.Trim();
        string VendorName = txtVendorname.Text.Trim();
        string VendorAdd = txtvendorAddress.Text.Trim();
        string IdentityNo = txtPanAadhar.Text.Trim();
        string BloodGroup = txtBldGrp.Text.Trim();
        string VisitsTo = txtvisitsto.Text;
        string VendorContact = txtVendorContactno.Text.Trim();
        string VendorIssueDate = txtIssuedate.Text.Trim();
        string VendorValidityDate = txtvaliddate.Text.Trim();
        string StayingLocation = txtPurPoses.Text.Trim();
        imagename = ofdImageUpload.SafeFileName;
        string Timein = txttimeins.Text.Trim();
        string Duration = "0";
        string GenVendorId = string.Empty;
        int CreatedBy = Variable.UserId;
        if (imagename != null || imagename != "") //----------------Check If image is Selected from Computer's Hard Drive------------------
        {
            if (imgcaptures.Image != null)
            {
                DataTable dtDatepart = GatePassEntry.GetCurrentDate();
                string pathDatePart = dtDatepart.Rows[0]["CurrentDate"].ToString(); //System.DateTime.Now.ToString("dd-MM-yyyy");
                pathDatePart = pathDatePart.Replace('-', '_');
                string picname = imagename;
                Bitmap imgImage = new Bitmap(imgcaptures.Image);
                ImagePaths = (ImagePath + txtVendorname.Text.Replace(' ', '_') + "_" + txtVendorContactno.Text + "__" + pathDatePart + imagename + ".jpg");

                //  Vendor_9199777256__28_01_2019
                //Create an object of Bitmap class
                //  imgImage.Dispose();                                             //, System.Drawing.Imaging.ImageFormat.Jpeg
                if (File.Exists(ImagePaths))
                {
                    Image = ImagePath + txtVendorname.Text.Replace(' ', '_').Replace('.', '_').Replace('/', '_') + "_" + txtVendorContactno.Text + "_" + "_" + pathDatePart + imagename + ".jpg";
                }
                else
                {
                    imgImage.Save(ImagePath + txtVendorname.Text.Replace(' ', '_').Replace('.', '_').Replace('/', '_') + "_" + txtVendorContactno.Text + "_" + "_" + pathDatePart + imagename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    Image = ImagePath + txtVendorname.Text.Replace(' ', '_').Replace('.', '_').Replace('/', '_') + "_" + txtVendorContactno.Text + "_" + "_" + pathDatePart + imagename + ".jpg";
                }
                switch (GatePassEntry.InsertGatepassEntryVendor(flag, VendorPassId, ContName, ContAdd, VendorName, VendorAdd, IdentityNo, Timein, VisitsTo, VendorContact, BloodGroup, VendorIssueDate, Image, VendorValidityDate, StayingLocation, CreatedBy, ref GatepassNo, ref GenVendorId))
                {
                        case AppCode.Operation.Operation.ProjectCreateStatus.Insertrow:
                        MessageBox.Show("Record Saved successfully!");
                        lblgtpassno.Text = Variable.GenGatePassNo;
                        Bitmap barcode = CreateBarcode("*" + lblgtpassno.Text + "*");
                        PictureBarCode.Image = barcode;
                        PictureBarCode.Visible = true;
                        btnprints.Visible = true;
                        clear();
                        break;
                        case AppCode.Operation.Operation.ProjectCreateStatus.updateRow:
                        MessageBox.Show("Record Update successfully!");
                        lblgtpassno.Text = Variable.GenGatePassNo;
                        Bitmap barcode2 = CreateBarcode("*" + lblgtpassno.Text + "*");
                        PictureBarCode.Image = barcode2;
                        PictureBarCode.Visible = true;
                        btnprints.Visible = true;
                        clear();
                        break;
                        case AppCode.Operation.Operation.ProjectCreateStatus.DuplicateName:
                        MessageBox.Show("Duplicate Record !");
                        break;
                }
            }
            else
            {
                MessageBox.Show("Please capture or browse an image First !");
            }
        }
    }
}
You are viewing reply posted by: pandeyism 10 days ago.