示例#1
0
        void dataGridView1_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (Convert.ToString(wgrid.dataGridView1.Columns[e.ColumnIndex].Tag) == "photo")
            {
                int customerPrimaryKeyID = 0;
                if (wgrid.dataGridView1.SelectedRows.Count > 0)
                {
                    string northImg = "";
                    string southImg = "";

                    int.TryParse(Convert.ToString(wgrid.dataGridView1.SelectedRows[0].Cells["CUSTOMER_PK_ID"].Value), out customerPrimaryKeyID);

                    objCustomerDba.GetPhotoPath(customerPrimaryKeyID, out northImg, out southImg);

                    frmShowPhoto showPhoto = new frmShowPhoto();
                    showPhoto.NorthPhotoPath      = northImg;
                    showPhoto.SouthPhotoPath      = southImg;
                    showPhoto.lblCarRegNo.Content = wgrid.dataGridView1.SelectedRows[0].Cells["PLATE NO#"].Value.ToString();
                    showPhoto.BringIntoView();

                    showPhoto.Show();
                }
            }
            else // this else for showing dialog with full details
            {
            }
        }
        void dataGridView1_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            try
            {
                if (Convert.ToString(wgrid.dataGridView1.Columns[e.ColumnIndex].Tag) == "photo")
                {
                    int customerPrimaryKeyID = 0;
                    if (wgrid.dataGridView1.SelectedRows.Count > 0)
                    {
                        string northImg = "";
                        string southImg = "";

                        int.TryParse(Convert.ToString(wgrid.dataGridView1.SelectedRows[0].Cells["CUSTOMER_PK_ID"].Value), out customerPrimaryKeyID);

                        GetPhotoPath(customerPrimaryKeyID, out northImg, out southImg);

                        frmShowPhoto showPhoto = new frmShowPhoto();

                        if (!string.IsNullOrEmpty(northImg))
                        {
                            showPhoto.NorthPhotoPath = northImg;
                        }
                        if (!string.IsNullOrEmpty(southImg))
                        {
                            showPhoto.SouthPhotoPath = southImg;
                        }

                        showPhoto.lblCarRegNo.Content = wgrid.dataGridView1.SelectedRows[0].Cells["PLATE NO#"].Value.ToString();
                        showPhoto.lblNorthEES.Content = "North -" + wgrid.dataGridView1.SelectedRows[0].Cells["GATE"].Value.ToString();
                        showPhoto.lblSouthEES.Content = "South -" + wgrid.dataGridView1.SelectedRows[0].Cells["GATE"].Value.ToString();
                        showPhoto.BringIntoView();
                        showPhoto.Show();
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("file not found");
            }
        }