CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    46

    C#Net2008 - How to transfer data from Load FORM back to Calling FORM

    Hi Friends

    I need your help again.
    Due to technical Logical Specfication by System Analyst request to create 2 FORMs, FRMPayRoll and FRMPopUpEmployeeRef.

    On FRMPayRoll, click on the Button to Load FRMPopUpEmployeeRef. Apparently, this FORM FRMPopUpEmployeeRef is being used by many FORMS within the Payroll Application. All the FORMs retreive the same data from it.


    On Loaded FORM FRMPopUpEmployeeRef, Exit the FORM after selected the specific employee from the datagridview1
    and transfer the employee name, EmployeeID , Wages and BankAccount back to the calling FORM FRMPayRoll.

    -------------------------------------------------------------------------------------------------------------
    Here are the error messages :


    Error 1 Cannot convert method group 'PropEmployeeId' to non-delegate type 'string'. Did you intend to invoke the method?

    Error 2 Cannot convert method group 'PropEmployeeName' to non-delegate type 'string'. Did you intend to invoke the method?

    Error 3 Cannot convert method group 'PropWages' to non-delegate type 'string'. Did you intend to invoke the method?

    Error 4 Cannot convert method group 'PropBankAccount' to non-delegate type 'string'. Did you intend to invoke the method?
    ------------------------------------------------------------------------------------------------

    FORM FRMPayRoll Coding

    private void btnEmployeeRef_Click(object sender, EventArgs e)
    {

    FRMPopUpEmployeeRef FM = new FRMPopUpEmployeeRef();


    FM.ShowDialog();

    Boolean bolFlag = FM.PropSelect();

    if (bolFlag == true)
    {
    this.txtEmployeeID.Text = convert.tostring(FM.PropEmployeeID);
    this.txtEmployeeName.Text = convert.tostring (FM.PropEmployeeName);
    this.txtEmployeeWages.Text = Convert.ToString(FM.PropWages);
    this.txtEmployeeBankAcct.Text = Convert.ToString(FM.PropBankAccount);
    }

    }

    ================================

    LOADED POP UP FORM FRMPopUpEmployeeRef Coding


    // common variables on FRMPopUpEmployeeRef
    private Boolean bolSelected; // confirm selection
    private int intEmployeeID; // Employee ID
    private string strEmployeeName; // employee name
    private int intWages ; // employee wages
    private string strBankAccount; // employee Bank Account


    private void datagridviewProduct_Click(Object sender, DataGridViewCellEventArgs e)
    // retrive all column from selected row or cells in datagridview
    {
    int intRowIndex = this.dataGridViewProduct.CurrentRow.Index;

    if (intRowIndex != -1)
    {
    intEmployeeID = (int) this.dataGridViewEmployee.CurrentRow.Cells[0].Value;
    strEmployeeName = this.dataGridViewEmployee.CurrentRow.Cells[1].Value.ToString();
    intWages = (int) this.dataGridViewEmployee.CurrentRow.Cells[2].Value;
    strBankAccount = this.dataGridViewEmployee.CurrentRow.Cells[3].Value.tostring();

    //exit by default
    bolSelected = true;
    this.Close();
    }
    }


    #region " --- Transfer Selected data back to Calling FORM --- "

    public bool PropSelect()
    { return bolSelected; }

    public int PropEmployeeID()
    { return intEmployeeID; }

    public string PropEmployeeName()
    { return strEmployeeName; }

    public int PropWages()
    { return intWages; }

    public string PropBankAccount()
    { return strBankAccount; }


    #endregion

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: C#Net2008 - How to transfer data from Load FORM back to Calling FORM

    I might be completely wrong about this (in a way I hope I am...) but try replacing this
    Code:
    if (bolFlag == true)
    {
       this.txtEmployeeID.Text = convert.tostring(FM.PropEmployeeID);
       this.txtEmployeeName.Text = convert.tostring (FM.PropEmployeeName);
       this.txtEmployeeWages.Text = Convert.ToString(FM.PropWages);
       this.txtEmployeeBankAcct.Text = Convert.ToString(FM.PropBankAccount);
    }
    with this...
    Code:
    if (bolFlag == true)
    {
       this.txtEmployeeID.Text = Convert.ToString(FM.PropEmployeeID());
       this.txtEmployeeName.Text = Convert.ToString (FM.PropEmployeeName());
       this.txtEmployeeWages.Text = Convert.ToString(FM.PropWages());
       this.txtEmployeeBankAcct.Text = Convert.ToString(FM.PropBankAccount());
    }
    Minor points...

    1. Assume something happened when putting the code in forum as the call to Convert.ToString was incorrect in two places...

    2. You can use code tags to format code in the post. They are simple to use...[code]<your code here>[ /code] (Remove the extra space at the beginning of the closing tag.

    Major point...

    I'm curious as to how you came about this code. Is this a project you're working on? Are you working on your own? The problem seems obvious to me and I would have thought that it would have been obvious to you too. Perhaps there is something I'm missing...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured