Ejemplo n.º 1
0
 private void textBox5_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (textBox5.Text.Length > 0)
         {
             this.dgview.Visible = true;
             dgview.BringToFront();
             Search(90, 70, 400, 200, "Emp Id,Emp Name", "100,0");
             this.dgview.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.employee_MouseDoubleClick);
             Connection3 con3 = new Connection3();
             con3.dataGet3("Select Top(10) EmpId,Name From [dbo].[Employee_Register] where EmpId like '" + textBox5.Text + "%'");
             DataTable dt = new DataTable();
             con3.sda3.Fill(dt);
             dgview.Rows.Clear();
             foreach (DataRow row in dt.Rows)
             {
                 int n = dgview.Rows.Add();
                 dgview.Rows[n].Cells[0].Value = row["EmpId"].ToString();
                 dgview.Rows[n].Cells[1].Value = row["Name"].ToString();
             }
         }
         else
         {
             dgview.Visible = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    if (IfEmployeeExists(textBox5.Text, textBox2.Text))
                    {
                        MessageBox.Show("Employee already Exists");
                    }
                    else
                    {
                        DialogResult dr = MessageBox.Show("Are you sure want to Save Record", "Polkotuwa Stores", MessageBoxButtons.YesNo);

                        if (dr == DialogResult.Yes)
                        {
                            Connection3 con3 = new Connection3();
                            con3.dataSend3("insert into [dbo].[Employee_Register] (Name,Mobile,Email,Dob,BankDetails,Address) values('" + textBox5.Text.ToString() + "', '" + textBox2.Text.ToString() + "', '" + textBox6.Text.ToString() + "', '" + dateTimePicker1.Value.ToString("dd-MM-yyyy") + "', '" + textBox4.Text.ToString() + "', '" + textBox7.Text.ToString() + "', '" + "')");
                            MessageBox.Show("Record Saved Successfully....!!!", "Polkotuwa Stores", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            disp_data();
                        }
                        ClearData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }