marcocanary
New Member
\[code\]public partial class Form1 : Form { SqlConnection connection; DataTable dtable; SqlDataAdapter adapter; string conn = "Data Source=BALA;Initial Catalog=reference;Persist Security Info=True;User ID=sa;Password=mips123"; //string command = "select Name,email,mobile,space(30) as wishfor from reference WHERE DATEPART(d,dob)=DATEPART(d,GETDATE())AND DATEPART(m,dob) = DATEPART(m, GETDATE())And DATEPART(d,Weddingdate)=DATEPART(d,GETDATE())AND DATEPART(m,Weddingdate) = DATEPART(m, GETDATE())"; // string command = "select uid,email,name,mobile,CASE WHEN (DATEPART(d, dob) = DATEPART(d, GETDATE()) and DATEPART(d, Weddingdate)=DATEPART(d, GETDATE()))Then 'B/M'WHEN DATEPART(d, dob) = DATEPART(d, GETDATE()) then 'B'WHEN DATEPART(d, Weddingdate) = DATEPART(d, GETDATE()) then 'M'END AS WISH from reference where (DATEPART(d, dob) = DATEPART(d, GETDATE()) or DATEPART(d, Weddingdate)=DATEPART(d, GETDATE()))"; string command = "select uid,email,name,mobile,CASE WHEN ((DATEPART(d, dob) = DATEPART(d, GETDATE()) and DATEPART(d, Weddingdate)=DATEPART(d, GETDATE()))AND((DATEPART(M, dob) = DATEPART(M, GETDATE()) and DATEPART(M, Weddingdate)=DATEPART(M, GETDATE()))))Then 'B/M'WHEN (DATEPART(d, dob) = DATEPART(d, GETDATE())AND(DATEPART(M, dob) = DATEPART(m, GETDATE()))) then 'B'WHEN (DATEPART(d, Weddingdate) = DATEPART(d, GETDATE())AND DATEPART(M, Weddingdate) = DATEPART(M, GETDATE())) then 'M'END AS WISH from reference where ((DATEPART(d, dob) = DATEPART(d, GETDATE()) or DATEPART(d, Weddingdate)=DATEPART(d, GETDATE())And ((DATEPART(M, dob) = DATEPART(M, GETDATE()) And DATEPART(M, Weddingdate)=DATEPART(M, GETDATE())))))"; public Form1() { InitializeComponent(); //DataGridViewLinkColumn link=new DataGridViewLinkColumn(); } private void Form1_Load(object sender, EventArgs e) { connection = new SqlConnection(conn); connection.Open(); adapter = new SqlDataAdapter(command,connection); dtable = new DataTable(); SqlCommandBuilder cmd = new SqlCommandBuilder(adapter); adapter.Fill(dtable); dataGridView1.DataSource = dtable; //DataGridViewLinkColumn link = new DataGridViewLinkColumn(); //link.UseColumnTextForLinkValue = http://stackoverflow.com/questions/14051568/true; //link.HeaderText ="Send"; //link.DataPropertyName = "Click"; //link.Text = "Send Wish"; //dataGridView1.Columns.Add(link); DataGridViewLinkColumn links = new DataGridViewLinkColumn(); links.HeaderText = "Hello"; links.UseColumnTextForLinkValue = http://stackoverflow.com/questions/14051568/true; links.Text ="Email me"; links.ActiveLinkColor = Color.White; links.LinkBehavior = LinkBehavior.SystemDefault; links.LinkColor = Color.Blue; links.TrackVisitedState = true; links.VisitedLinkColor = Color.YellowGreen; links.UseColumnTextForLinkValue = http://stackoverflow.com/questions/14051568/true; dataGridView1.Columns.Add(links); // connection.Close(); //string grdid = Int32.Parse(dataGridView1.SelectedRow.Cells[1].Text.ToString()); //string grdid = dataGridView1.Columns[3].ToString(); //if (grdid =="B/M") //{ //} //else if (grdid == "B") //{ //} //else if (grdid == "M") //{ //} //else //{ //} } private void dataGridView1_CellMouseClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString() == "Email me") { MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString()); } else { MessageBox.Show("You Clicked another Cell"); } } }\[/code\]this is my code if i click the "Email me " the process not done ,plz help me any on ..