private void button4_Click(object sender, EventArgs e) { String name = textBox1.Text; String contact = textBox4.Text; String address = textBox6.Text; String product = textBox2.Text; String delivery_date = dateTimePicker1.Value.ToString("yyyy-MM-dd"); String accessory = textBox3.Text; String explanation = textBox5.Text; SqlConnection sqlConnection = new SqlConnection(@"Data Source=DESKTOP-R7MNN89\SQLEXPRESS;Initial Catalog=IBSHR;User ID=sa;Password=nrkdrk"); sqlConnection.Open(); using (sqlConnection) { using (SqlCommand command = new SqlCommand("UPDATE TechnicalRecord SET owner=@owner,contact=@contact," + "address=@address,product=@product,delivery_date=@delivery_date,accessory=@accessory," + "explanation=@explanation where id = @id", sqlConnection)) { command.Parameters.AddWithValue("@id", productId); command.Parameters.Add("@owner", name); command.Parameters.Add("@contact", contact); command.Parameters.Add("@address", address); command.Parameters.Add("@product", product); command.Parameters.Add("@delivery_date", delivery_date); command.Parameters.Add("@accessory", accessory); command.Parameters.Add("@explanation", explanation); command.ExecuteNonQuery(); UpdateDialogForm updateDialogForm = new UpdateDialogForm(); DialogResult dialogResult = updateDialogForm.ShowDialog(); if (dialogResult == DialogResult.OK) { //do processing } else { //do processing } } this.Close(); } }
private void button2_Click(object sender, EventArgs e) { String id = label2.Text; Boolean processed; Boolean approval; Boolean forwarding; String operation = textBox1.Text; String reception_date = dateTimePicker1.Value.ToString("yyyy-MM-dd"); String fee = textBox3.Text; String completion_date = dateTimePicker2.Value.ToString("yyyy-MM-dd"); String operations_carried = textBox7.Text; String referral_clarification = textBox2.Text; if (checkBox1.Checked == true) { processed = true; } else { processed = false; } if (checkBox3.Checked == true) { approval = true; } else { approval = false; } if (checkBox2.Checked == true) { forwarding = true; } else { forwarding = false; } SqlConnection sqlConnection = new SqlConnection(@"Data Source=DESKTOP-R7MNN89\SQLEXPRESS;Initial Catalog=IBSHR;User ID=sa;Password=nrkdrk"); sqlConnection.Open(); using (sqlConnection) { using (SqlCommand command = new SqlCommand("UPDATE TechnicalOperations SET TRId=@TRId,processed=@processed," + "approval=@approval,operation=@operation,reception_date=@reception_date,fee=@fee," + "completion_date=@completion_date,operations_carried=@operations_carried,forwarding=@forwarding," + "referral_clarification=@referral_clarification,delivery=@delivery where id = @id", sqlConnection)) { command.Parameters.AddWithValue("@id", productId); command.Parameters.AddWithValue("@TRId", id); command.Parameters.Add("@processed", processed); command.Parameters.Add("@approval", approval); command.Parameters.Add("@operation", operation); command.Parameters.Add("@reception_date", reception_date); command.Parameters.Add("@fee", fee); command.Parameters.Add("@completion_date", completion_date); command.Parameters.Add("@operations_carried", operations_carried); command.Parameters.Add("@forwarding", forwarding); command.Parameters.Add("@referral_clarification", referral_clarification); command.Parameters.Add("@delivery", true); command.ExecuteNonQuery(); UpdateDialogForm updateDialogForm = new UpdateDialogForm(); DialogResult dialogResult = updateDialogForm.ShowDialog(); if (dialogResult == DialogResult.OK) { //do processing } else { //do processing } } this.Close(); } }