public static void deletePutPlan(PutPlan putPlan) { string insert = "delete from Put_plan where MName='" + putPlan.getMoiveName()+ "' and SName='" + putPlan.getScreenName() + "' and time = '" + putPlan.getTime() + "' and PlanDay = '"+putPlan.getPlanDay()+"'"; DbHelperSQL.ExecuteSql(insert); }
public static PutPlan getSname(String moive,String time) { PutPlan putPlan = new PutPlan(); putPlan.setScreenName((int)DbHelperSQL.GetSingle( "select SName from Put_Plan where MName='" + moive + "' and time='" + time + "'")); putPlan.setTime(Convert.ToDateTime(time)); putPlan.setMoiveName(moive); return putPlan; }
public static void putPlanAdd(PutPlan putPlan) { string insert = "insert into Put_Plan(MName,SName,time,PlanDay,timefinish) values ('" + putPlan.getMoiveName() + "'," + putPlan.getScreenName() + ",'" + putPlan.getTime() + "','"+putPlan.getPlanDay()+"','"+putPlan.getFinishTime()+"')"; DbHelperSQL.ExecuteSql(insert); }
//排片添加 private void button7_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null) { int sname = Convert.ToInt16(comboBox2.SelectedItem.ToString()); string mname = comboBox1.SelectedItem.ToString(); DateTime time = Convert.ToDateTime(textBox5.Text); PutPlan putPlan = new PutPlan(mname,sname,time); SqlPutPlan.putPlanAdd(putPlan); MessageBox.Show("添加成功"); } else { MessageBox.Show("请选择完整数据"); } }
//排片删除 private void button12_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Parent.Parent != null) { int sname =Convert.ToInt16(treeView1.SelectedNode.Parent.Parent.Text); string mname = treeView1.SelectedNode.Parent.Text; DateTime time = Convert.ToDateTime(treeView1.SelectedNode.Text); PutPlan putPlan = new PutPlan(mname,sname,time); SqlPutPlan.deletePutPlan(putPlan); MessageBox.Show("删除成功"); } else { MessageBox.Show("请选择你要删除的排片信息。"); } }
//排片添加 private void button7_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null) { //添加限制。不能添加以前日期的排片 DateTime lookDay = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM-dd")); DateTime today = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); if (lookDay < today) { MessageBox.Show("无法添加过期日期的排片信息!!"); return; } int sname = Convert.ToInt16(comboBox2.SelectedItem.ToString()); string mname = comboBox1.SelectedItem.ToString(); DateTime time = Convert.ToDateTime(textBox5.Text); string planDay = dateTimePicker1.Value.ToString("yyyy-MM-dd"); //判断添加时间段是否符合要求 int moiveLength = SqlMoive.getLengthByMoive(mname); String time1 = SqlPutPlan.changeTime(moiveLength);//把电影时长转化成time数据 time1 = SqlPutPlan.add(time1, textBox5.Text.Trim());//要添加的电影的结束时间 DateTime addFinishTime = Convert.ToDateTime(time1);//转换成datetime //得到在要插入的电影中前面第一个电影的开始时间和结束时间 DateTime begin = Convert.ToDateTime("00:00:00"); DateTime finish = Convert.ToDateTime("00:00:00"); DateTime nextbegin = Convert.ToDateTime("00:00:00"); DataSet begintime = SqlPutPlan.getbeginTimeByPlandayScressName(planDay, "" + sname); foreach (DataRow row1 in begintime.Tables[0].Rows) { if (time > Convert.ToDateTime(row1["time"].ToString())) { //MessageBox.Show(row1["time"].ToString()); begin = Convert.ToDateTime(row1["time"].ToString()); finish = Convert.ToDateTime(row1["timefinish"].ToString()); break; } } //插入电影的开始时间小于查询到的电影的结束时间,则插入失败 if (finish > time) { MessageBox.Show("电影时间重叠,排片失败!!"); return; } //插入电影的结束时间大于下一个电影的开始时间,则插入失败 DataSet begintime2 = SqlPutPlan.getbeginTimeByPlandayScressNamey(planDay, "" + sname); foreach (DataRow row1 in begintime2.Tables[0].Rows) { if (begin < Convert.ToDateTime(row1["time"].ToString())) { nextbegin = Convert.ToDateTime(row1["time"].ToString()); break; } } if (nextbegin != Convert.ToDateTime("00:00:00")) { if (addFinishTime > nextbegin) { //MessageBox.Show(Convert.ToString(begin)); //MessageBox.Show(Convert.ToString(nextbegin)); //MessageBox.Show(Convert.ToString(addFinishTime)); MessageBox.Show("电影时间重叠,排片失败!!"); return; } } PutPlan putPlan = new PutPlan(mname, sname, time, planDay,addFinishTime); SqlPutPlan.putPlanAdd(putPlan); MessageBox.Show("添加成功"); } else { MessageBox.Show("请选择完整数据"); } }
//排片删除 private void button12_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Parent.Parent != null) { DateTime lookDay = Convert.ToDateTime(dateTimePicker3.Value.ToString("yyyy-MM-dd")); DateTime today = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); if (lookDay < today) { MessageBox.Show("无法删除过期日期的排片信息!!"); return; } int sname =Convert.ToInt16(treeView1.SelectedNode.Parent.Parent.Text); string mname = treeView1.SelectedNode.Parent.Text; DateTime time = Convert.ToDateTime(treeView1.SelectedNode.Text); String planDay = dateTimePicker3.Value.ToString("yyyy-MM-dd"); PutPlan putPlan = new PutPlan(mname,sname,time,planDay,time); SqlPutPlan.deletePutPlan(putPlan); MessageBox.Show("删除成功"); } else { MessageBox.Show("请选择你要删除的排片信息。"); } }