单击按钮时关闭另一个项目中的表单

时间:2017-10-26 08:55:41

标签: c# visual-studio multiple-projects

 private void _btnAccept_Click(object sender, EventArgs e)
    {
        LogInForm.UserOntrip _pnl = new LogInForm.UserOntrip(_FNAME);
        _pnl.Show();
        _btnAccept.Hide();
        _btnCancel.Hide();
        button1.Show();

        string _query2 = "select DContactno from DriverTbl where DUsername = @USERNAME";
        string _query3 = "select VehicleRegitrationNumber from DriverTbl where DUsername = @USERNAME";

        SqlConnection _sqlcnn = new SqlConnection("Data Source=MELIODAS;Initial Catalog=WeGo;Integrated Security=True; MultipleActiveResultSets=True ");
        _sqlcnn.Open();

        try
        {
            SqlDataReader _reader = null;
            SqlCommand _cmd = new SqlCommand("select DFname from DriverTbl where DUsername=@USERNAME", _sqlcnn);

            SqlParameter _param = new SqlParameter();
            _param.ParameterName = "@USERNAME";
            _param.Value = _FNAME;

            _cmd.Parameters.Add(_param);

            _reader = _cmd.ExecuteReader();       
            while (_reader.Read())
            {
                _pnl._txtboxDriverName.Text = _reader.GetString(0);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        using (SqlCommand _sqlcmd = new SqlCommand(_query2, _sqlcnn))
        {
            try
            {
                SqlDataReader _reader = null;

                SqlParameter _param1 = new SqlParameter();
                _param1.ParameterName = "@USERNAME";
                _param1.Value = _FNAME;

                _sqlcmd.Parameters.Add(_param1);

                _reader = _sqlcmd.ExecuteReader();       
                while (_reader.Read())
                {
                    _pnl._txtboxDContact.Text = _reader.GetString(0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        _pnl._txtboxOrigin.Text = _txtboxOrigin.Text;
        _pnl._txtboxDestination.Text = _txtboxDestination.Text;

        using (SqlCommand _sqlcmd = new SqlCommand(_query3, _sqlcnn))
        {
            try
            {
                SqlDataReader _reader = null;

                SqlParameter _param1 = new SqlParameter();
                _param1.ParameterName = "@USERNAME";
                _param1.Value = _FNAME;

                _sqlcmd.Parameters.Add(_param1);

                _reader = _sqlcmd.ExecuteReader();
                while (_reader.Read())
                {
                    _pnl._txtboxBodyNum.Text = _reader.GetString(0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        _pnl._lblPrice.Text = _lblPrice.Text;
        _pnl._lblVechType.Text = _lblTransType.Text;
    }

    private void button1_Click(object sender, EventArgs e)
    {

        LogInForm.UserOntrip _user = new LogInForm.UserOntrip(_FNAME);
        _user.Hide();

        Form2 _form2 = new Form2(_FNAME);
        _form2.Show();
        this.Hide();
    }

我想隐藏或关闭LogInForm.UserOntrip表单。 UserOntrip表单来自LogInForm项目,我在驱动程序端项目中运行它。

1st:当来自driverside的表单打开时,有一个接受和关闭按钮,如果接受,将出现一个完成按钮,我推荐的2个按钮将被隐藏。 第二:如果我点击完成按钮,那么在第一个中打开的表格将被关闭,与在驱动程序中打开的当前表格相同

我应该在代码上添加什么,这样如果我点击按钮2表格将被关闭。 我的系统就像一个超级棒。

谢谢

0 个答案:

没有答案