Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TeknikKart TeknikKart1 = new TeknikKart();

            TeknikKart1.Show();
            this.Hide();
        }
        private void txtTaskEkle_Click(object sender, EventArgs e)
        {
            if (txtDurumID.Text == " " || txtTaskName.Text == "" || txtUserID.Text == " " || richTextBox1.Text == " " || richTextBox2.Text == " ")
            {
                MessageBox.Show("Lutfen tum alanları doldurunuz");
            }
            else
            {
                int    d1 = int.Parse(txtDurumID.Text);
                int    d2 = int.Parse(txtUserID.Text);
                string d3 = richTextBox2.Text;
                if (baglanti.State == ConnectionState.Closed)
                {
                    baglanti.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = baglanti;

                    cmd.CommandText = "INSERT INTO Tasks(TaskName,isAcıklama,Notlar,DurumID,UserID,BaşlangıçTarihi) VALUES('" + txtTaskName.Text + "','" + richTextBox1.Text + "','" + richTextBox2.Text + "','" + int.Parse(txtDurumID.Text) + "','" + int.Parse(txtUserID.Text) + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "'); select @@identity";



                    //TaskID ALIYORUZ
                    modified = int.Parse(cmd.ExecuteScalar().ToString());
                    cmd.Dispose();

                    baglanti.Close();
                }
                //TaskStates
                if (baglanti.State == ConnectionState.Closed)
                {
                    baglanti.Open();
                    SqlCommand cmd2 = new SqlCommand();
                    cmd2.Connection = baglanti;

                    cmd2.CommandText = "INSERT INTO TaskStatess(TaskID,DurumID,Notlar,TaskStateDate,userID) VALUES('" + modified + "','" + d1 + "','" + d3 + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + d2 + "')";



                    cmd2.ExecuteNonQuery();
                    cmd2.Dispose();

                    baglanti.Close();
                }

                TeknikKart TeknikKart = new TeknikKart();
                TeknikKart.Show();
                this.Hide();
            }
        }