返回数据表时代码跳转不正常

时间:2013-04-26 03:34:13

标签: c#-4.0

您好我有一个MDI表格的c#代码,例如 -

private void tlstrpmenuAppointments_Click(object sender, EventArgs e)
{
    Appointments AppointmentsObject = new Appointments(Controller.Ulink1);
    AppointmentsObject.MdiParent = FrmMainConsole.ActiveForm;
    AppointmentsObject.Show();
}

此MDI有一个名为Appointments的子表单,其中包含以下代码 -

private void Appointments_Load(object sender, EventArgs e)
    {
        cmbSearchColoumn.SelectedIndex = 0;

        lblDoctorName.Text =lblDoctorName.Text+" "+ dt.Rows[0].ItemArray[1].ToString() + " " + dt.Rows[0].ItemArray[2].ToString() + " " + dt.Rows[0].ItemArray[3].ToString();

        //Load todays Time Slots-
        DataTable temp = new DataTable();

        // **THE PROBLEM LIES IN THE FOLLOWING STATEMENT**
        temp = appointmentsCLObject.GetTimeSlots(docid);
       // THIS CALLS THE BAL STATED BELOW THIS CODE.

        cmbTimeSlotsAvailable.DisplayMember = temp.Columns[1].ToString();
        cmbTimeSlotsAvailable.ValueMember = temp.Columns[0].ToString();
        cmbTimeSlotsAvailable.DataSource = temp;
        cmbTimeSlotsAvailable.SelectedIndex = 0;

        //Loading Patient Lists for Consulting.
        dt1 = appointmentsCLObject.GetAppointments(DateTime.Now, Convert.ToInt16(cmbTimeSlotsAvailable.SelectedValue), docid);
        dtgridAppointments.DataSource = dt1;
    }

BAL是AS Follows -

public DataTable GetTimeSlots(int Docid)
    {
        DateTime dt=new DateTime();
        dt = DateTime.Now;
        DataTable dtable= appointmentMLObject.GetTimeSlots(Docid,(int)dt.DayOfWeek);
        DataTable ReturnTable = new DataTable();
        foreach (DataRow rw in dtable.Rows)
        {
            ReturnTable.Rows.Add(rw[0].ToString(),rw[1].ToString()+" "+rw[2].ToString());
        }

        // **PROBLEM START**
        return ReturnTable;
    }

**当调用return语句时,代码不会返回其调用方法! (??) 相反,它返回到已创建此子表单对象的MDI。

返回语句

AppointmentsObject.Show();

向我显示没有数据的表格。

0 个答案:

没有答案