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);
}
}
{
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);
}
}
解决方案 »
- 快捷键于自定义控件冲突
- 为什么我的C#2005在属性窗口上方没有代码窗口和设计窗口切换的按钮
- C#socket发中文信息出现乱码如何解决?
- 问个简单的问题,SQL查询,读取数据库里的第二条记录在页面上显示
- Winio如何模拟按键操作?
- 组件问题,欢迎指导!我要做一个组件:包含ip地址组件,金额组件,日期组件,等....
- c#中 Midea Player 如何实现循环播放
- 请问:在事件里使用MessageBox,只是在上面多加了一个条件控制,为什么点击取消会执行多次???
- 如何返回OleDbDataReader的第一条记录?,50分
- 关于databinding的问题
- vs2010 没有 ManagementObject类
- MVC3中如何增加一个区域(AREA)
懒成这样 自己写的破代码都不愿意调试