Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            UpdatedV.Clear();
            SqlError.Clear();
            SqlDataReader dataReader;

            sql = $"SELECT  * FROM [DC_PreProd_Box_Validation].[dbo].[tblBox] where BoxID = {TxtBoxID.Text} ";
            try
            {
                SqlConnection sqlConnection = new SqlConnection(connection);
                sqlConnection.Open();
                command    = new SqlCommand(sql, sqlConnection);
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    if (TxtTarget.Text == LastTarget)
                    {
                        LastTarget     = (string)dataReader.GetValue(5);
                        TxtTarget.Text = (string)dataReader.GetValue(5);
                    }
                    else
                    {
                        var IsYes = MessageBox.Show($"Do you want to change the target to: {TxtTarget.Text} ?", "Changing target", MessageBoxButtons.YesNo);
                        if (IsYes == DialogResult.Yes)
                        {
                            Update_Target();
                            LastTarget = TxtTarget.Text;
                        }
                        else
                        {
                            TxtTarget.Text = (string)dataReader.GetValue(5);
                        }
                    }
                }
                if (!dataReader.HasRows)
                {
                    LastTarget = "";
                    TxtTarget.Clear();
                    SqlError.SetError(TxtBoxID, "Box not found");
                }
                dataReader.Close();
                command.Dispose();
                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                SqlError.SetError(TxtBoxID, ex.Message);
            }
        }
Пример #2
0
 private void TxtTarget_TextChanged(object sender, EventArgs e)
 {
     UpdatedV.Clear();
 }