private void btnYes_Click(object sender, EventArgs e)
        {
            SqlConnection connection = null;
            try
            {
                if (cboServiceName.SelectedIndex == -1)
                {
                    MessageBox.Show("请选择要预约的服务!","提示");
                    return;
                }
                else if (dtpAppointmentDate.Text == DateTime.Now.ToLongDateString())
                {
                    connection = dbu.getConnection();
                    SqlDataAdapter sda = new SqlDataAdapter("select sO_stafName,sO_staffOrderId,sO_order,s.s_staffInformationId from tb_staffOrder so,tb_staff s where s_storeName='" + storename + "' and s.s_staffInformationId=so.s_staffInformationId and sO_orderDate=(select max(sO_orderDate) from tb_staffOrder) and convert(varchar(10),sO_orderDate,120)=convert(varchar(10),getdate(),120)", connection);
                    DataSet ds = new DataSet();
                    sda.Fill(ds);
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        if (MessageBox.Show("请给员工排序!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            StaffSort s = new StaffSort();
                            s.ShowDialog();
                        }
                    }
                    else
                    {
                        SqlDataAdapter da = new SqlDataAdapter();
                        SqlCommand command = connection.CreateCommand();
                        command.CommandText = "sp_appointmentService_calculate";
                        command.CommandType = CommandType.StoredProcedure;
                        IDataParameter[] parameters = { new SqlParameter("@appointmentDate", SqlDbType.Date), new SqlParameter("@appointmentStartTime", SqlDbType.Time), new SqlParameter("@appointmentEndTime", SqlDbType.Time), new SqlParameter("@storeName", SqlDbType.NVarChar) };
                        parameters[0].Direction = ParameterDirection.Input;  // 设置为输出参数 
                        parameters[0].Value = dtpAppointmentDate.Text;
                        parameters[1].Direction = ParameterDirection.Input;  // 设置为输出参数 
                        parameters[1].Value = dtpAppointmentTime.Text;
                        parameters[2].Direction = ParameterDirection.Input;  // 设置为输出参数 
                        parameters[2].Value = dtpEndTime.Text;
                        parameters[3].Direction = ParameterDirection.Input;  // 设置为输出参数 
                        parameters[3].Value = storename;
                        command.Parameters.Add(parameters[0]);
                        command.Parameters.Add(parameters[1]);
                        command.Parameters.Add(parameters[2]);
                        command.Parameters.Add(parameters[3]);
                        SqlDataAdapter b = new SqlDataAdapter(command);
                        DataSet db = new DataSet();
                        b.Fill(db);
                        dgvStaff.DataSource = db.Tables[0];
                        if (dgvStaff.Rows.Count == 0)
                        {
                            MessageBox.Show(dtpAppointmentTime.Text + "到" + dtpEndTime.Text + "这段时间内没有空闲的美甲师", "提示");
                        }
                      
                    }
                    dbu.closeConnection();
                }
                else
                {
                    connection = dbu.getConnection();
                    SqlDataAdapter da = new SqlDataAdapter();
                    SqlCommand command = connection.CreateCommand();
                    command.CommandText = "sp_appointmentService_calculate";
                    command.CommandType = CommandType.StoredProcedure;
                    IDataParameter[] parameters = { new SqlParameter("@appointmentDate", SqlDbType.Date), new SqlParameter("@appointmentStartTime", SqlDbType.Time), new SqlParameter("@appointmentEndTime", SqlDbType.Time), new SqlParameter("@storeName", SqlDbType.NVarChar) };
                    parameters[0].Direction = ParameterDirection.Input;  // 设置为输出参数 
                    parameters[0].Value = dtpAppointmentDate.Text;
                    parameters[1].Direction = ParameterDirection.Input;  // 设置为输出参数 
                    parameters[1].Value = dtpAppointmentTime.Text;
                    parameters[2].Direction = ParameterDirection.Input;  // 设置为输出参数 
                    parameters[2].Value = dtpEndTime.Text;
                    parameters[3].Direction = ParameterDirection.Input;  // 设置为输出参数 
                    parameters[3].Value = storename;
                    command.Parameters.Add(parameters[0]);
                    command.Parameters.Add(parameters[1]);
                    command.Parameters.Add(parameters[2]);
                    command.Parameters.Add(parameters[3]);
                    SqlDataAdapter b = new SqlDataAdapter(command);
                    DataSet db = new DataSet();
                    b.Fill(db);
                    dgvStaff.DataSource = db.Tables[0];
                    if (dgvStaff.Rows.Count == 0)
                    {
                        MessageBox.Show(dtpAppointmentTime.Text + "到" + dtpEndTime.Text + "这段时间内没有空闲的美甲师", "提示");
                    }
                  
                }
                dbu.closeConnection();
            }
            catch (Exception ex)
            {
                dbu.closeConnection();
                MessageBox.Show("处理错误请联系管理员,请参考错误消息:" + ex.Message);
            }
         
        }