/// <summary> /// 显示巡逻处理情况的次数 /// </summary> private void ShowTimes(decimal deptid) { //判断第几次巡逻:如果巡逻开始日期不是当前日期为第一次巡逻; //如果当前日期下有一条数据则为第二次巡逻; //如果当前日期下数据记录总数与巡逻次数相同:显示下班,交接班内容 string sqlwhere = "1=1 AND PATROLTYPE='人工巡逻' AND to_char(BEGINTIME,'yyyy-MM-dd')=to_char(sysdate,'yyyy-MM-dd')"; DataTable dt = handlingbll.GetList(sqlwhere); if (dt.Rows.Count > 0) { //巡逻次数 int times = Convert.ToInt32(dt.Rows[0]["TIMES"]); int counts = handlingbll.getCount() + 1;//当前记录数的下一记录 if (counts < times) { int count = dt.Rows.Count + 1; this.LabheadName.Text = "第" + count + "次巡查"; } else { this.LabheadName.Text = "第" + times + "次巡查"; this.divShift.Style.Add("display", "block"); } decimal pid = Convert.ToDecimal(dt.Rows[0]["PID"]); Entity.BASE_PATROL model = bll.GetModel(pid); SetPatrolEntity(model); } else { this.LabheadName.Text = "第1次巡查"; } }
/// <summary> /// 获取人工巡逻日志实体数据 /// </summary> /// <returns></returns> private Entity.BASE_PATROL GetPartolEntity() { Entity.BASE_PATROL model = new Entity.BASE_PATROL(); model.PATROLID = Convert.ToInt32(hidPrimary.Value); //id,主键 DropDownList ddr = (DropDownList)this.Department1.FindControl("ddlDepartment"); //找到用户控件中的子控件 if (ViewState["id"] != null) { model.DEPTID = 1;//默认单位编号 } else { model.DEPTID = Convert.ToInt32(ddr.SelectedValue); //巡查中队 } model.RESPUSER = txtRESPUSER.Text; //巡查负责人 model.PATROLUSER = txtPATROLUSER.Text; //巡查人员 model.BUSNUMBER = txtBUSNUMBER.Text; //巡逻车牌号 model.MILEAGE = Convert.ToInt32(txtMILEAGE.Text); //巡查里程 model.WEATHER = txtWEATHER.Text; //天气 // model.LOG = txtLog.Text; //巡查处理情况 model.WITHIN = txtWITHIN.Text; //移交内业处理事项 model.NEXTWITHIN = txtNEXTWITHIN.Text; //移交下班处理事项 model.GOODS = txtGOODS.Text; //移交器材 model.SHIFTCAPTAIN = txtSHIFTCAPTAIN.Text; //交班中队长 model.ACCEPTCAPTAIN = txtACCEPTCAPTAIN.Text; //接班中对长 model.ACCEPTBUSNUMBER = txtACCEPTBUSNUMBER.Text; //接班巡逻车牌号 //model.BEGINTIME = DateTime.Parse(txtBEGINTIME.Text); //巡查开始时间 //model.ENDTIME = DateTime.Parse(txtENDTIME.Text); //巡查结束时间 //model.TICKTIME = DateTime.Parse(this.txtTickTime.Text); //交接班时间 model.BUSKM = Convert.ToInt32(txtBUSKM.Text); //接班巡逻车里程表 // model.ACCEPT = 0; //接收人 // model.TRANSFER = 0; //移交人 return(model); }
private void SetPatrolEntity(Entity.BASE_PATROL model) { hidPrimary.Value = model.PATROLID.ToString(); DropDownList ddr = (DropDownList)this.Department1.FindControl("ddlDepartment");//找到用户控件中的子控件 if (model.DEPTID == 0) { ddr.SelectedValue = "1"; } else { ddr.SelectedValue = model.DEPTID.ToString(); } txtRESPUSER.Text = model.RESPUSER; txtPATROLUSER.Text = model.PATROLUSER; txtBUSNUMBER.Text = model.BUSNUMBER; txtMILEAGE.Text = model.MILEAGE.ToString(); // txtWEATHER.Text = model.LOG; // txtLog.Text = model.LOG; txtWITHIN.Text = model.WITHIN; txtNEXTWITHIN.Text = model.NEXTWITHIN; txtGOODS.Text = model.GOODS; txtSHIFTCAPTAIN.Text = model.SHIFTCAPTAIN; txtACCEPTCAPTAIN.Text = model.ACCEPTCAPTAIN; txtACCEPTBUSNUMBER.Text = model.ACCEPTBUSNUMBER; //txtBEGINTIME.Text = model.BEGINTIME.ToString("yyyy-MM-dd"); // txtENDTIME.Text = model.ENDTIME.ToString("yyyy-MM-dd"); txtBUSKM.Text = model.BUSKM.ToString(); }
private void PatrolAdd(Entity.BASE_PATROL model) { decimal Pid = Convert.ToDecimal(bll.GetMaxID()); //获取最新添加的巡逻日志编号 string sqlwhere = "1=1 and PID=" + Pid + " and to_char(BEGINTIME,'yyyy-MM-dd')=to_char(sysdate,'yyyy-MM-dd')"; //查询当前巡逻日志下是否有巡查处理情况 if (handlingbll.GetList(sqlwhere).Rows.Count > 0) { Entity.BASE_HANDLING handlingmodel = GetHandlingEntity(Pid, 3); handlingbll.Add(handlingmodel);//添加巡查处理情况 if (this.divShift.Style.Value == "block") { bll.update(model); } } else { int a = bll.Add(model);//添加人工巡逻日志 if (a > 0) { decimal newPid = Convert.ToDecimal(bll.GetMaxID()); //获取最新添加的巡逻日志编号 Entity.BASE_HANDLING handlingmodel = GetHandlingEntity(newPid, 3); handlingbll.Add(handlingmodel); //添加巡查处理情况 } else { //提示添加巡逻日志失败 } } }
/// <summary> /// 获取最大ID编号 /// </summary> /// <returns></returns> public string GetMaxID() { StringBuilder strSql = new StringBuilder(); strSql.Append("select max(PATROLID) as ID"); strSql.Append(" from BASE_PATROL "); Entity.BASE_PATROL entity = new Entity.BASE_PATROL(); DataTable dt = OracleHelper.Query(CommandType.Text, strSql.ToString()); string id = string.Empty; if (dt.Rows.Count > 0) { if (null == dt.Rows[0]["ID"] || "" == dt.Rows[0]["ID"].ToString()) { id = "-1"; } else { id = dt.Rows[0]["ID"].ToString(); } } else { id = "-1"; } return(id); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Entity.BASE_PATROL entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BASE_PATROL("); strSql.Append("PATROLID,DEPTID,RESPUSER,PATROLUSER,BUSNUMBER,MILEAGE,WEATHER,WITHIN,NEXTWITHIN,ACCEPTCAPTAIN,SHIFTCAPTAIN,ACCEPTBUSNUMBER,TICKTIME,BUSKM,GOODS,STATE,ATTENTION,REMARK"); strSql.Append(") values ("); strSql.Append(":PATROLID,:DEPTID,:RESPUSER,:PATROLUSER,:BUSNUMBER,:MILEAGE,:WEATHER,:WITHIN,:NEXTWITHIN,:ACCEPTCAPTAIN,:SHIFTCAPTAIN,:ACCEPTBUSNUMBER,:TICKTIME,:BUSKM,:GOODS,:STATE,:ATTENTION,:REMARK"); strSql.Append(") "); OracleParameter[] parameters = { new OracleParameter(":PATROLID", OracleType.Number, 4), new OracleParameter(":DEPTID", OracleType.Number, 4), new OracleParameter(":RESPUSER", OracleType.VarChar, 20), new OracleParameter(":PATROLUSER", OracleType.VarChar, 20), new OracleParameter(":BUSNUMBER", OracleType.VarChar, 20), new OracleParameter(":MILEAGE", OracleType.Number, 4), new OracleParameter(":WEATHER", OracleType.VarChar, 50), new OracleParameter(":WITHIN", OracleType.VarChar, 500), new OracleParameter(":NEXTWITHIN", OracleType.VarChar, 500), new OracleParameter(":ACCEPTCAPTAIN", OracleType.VarChar, 20), new OracleParameter(":SHIFTCAPTAIN", OracleType.VarChar, 20), new OracleParameter(":ACCEPTBUSNUMBER", OracleType.VarChar, 20), new OracleParameter(":TICKTIME", OracleType.DateTime), new OracleParameter(":BUSKM", OracleType.Number, 4), new OracleParameter(":GOODS", OracleType.VarChar, 500), new OracleParameter(":STATE", OracleType.Number, 4), new OracleParameter(":ATTENTION", OracleType.VarChar, 500), new OracleParameter(":REMARK", OracleType.VarChar, 500) }; parameters[0].Value = entity.PATROLID; parameters[1].Value = entity.DEPTID; parameters[2].Value = entity.RESPUSER; parameters[3].Value = entity.PATROLUSER; parameters[4].Value = entity.BUSNUMBER; parameters[5].Value = entity.MILEAGE; parameters[6].Value = entity.WEATHER; parameters[7].Value = entity.WITHIN; parameters[8].Value = entity.NEXTWITHIN; parameters[9].Value = entity.ACCEPTCAPTAIN; parameters[10].Value = entity.SHIFTCAPTAIN; parameters[11].Value = entity.ACCEPTBUSNUMBER; parameters[12].Value = entity.TICKTIME; parameters[13].Value = entity.BUSKM; parameters[14].Value = entity.GOODS; parameters[15].Value = entity.STATE; parameters[16].Value = entity.ATTENTION; parameters[17].Value = entity.REMARK; return(OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (null != Request.QueryString["id"] || "" != Request.QueryString["id"]) { decimal Epid = Convert.ToDecimal(Request.QueryString["id"]); ViewState["id"] = Request.QueryString["id"]; Entity.BASE_PATROL model = bll.GetModel(Epid); DataTable dt = handlingbll.GetList("1=1 and PID=" + Epid); this.deptname.InnerHtml = getDeptName(model.DEPTID); this.AcceptNumber.InnerHtml = model.ACCEPTBUSNUMBER; //接班巡逻车牌号; this.RespUser.InnerHtml = model.RESPUSER; //巡查负责人 this.shiftDeptName.InnerHtml = model.SHIFTCAPTAIN; //交班中队长 this.AcceptDeptname.InnerHtml = model.ACCEPTCAPTAIN; //接班中队长 this.GOODS.InnerHtml = model.GOODS; //移交器材 this.PatrolUser.InnerHtml = model.PATROLUSER; //巡查人员 this.Weather.InnerHtml = model.WEATHER; //天气 this.WITHIN.InnerHtml = model.WITHIN; //移交内业处理事项 this.NEXTWITHIN.InnerHtml = model.NEXTWITHIN; //移交下班处理事项 this.Mileage.InnerHtml = model.MILEAGE.ToString(); //巡查里程 this.busNumber.InnerHtml = model.BUSNUMBER; //巡逻车牌号 this.BUSKM.InnerHtml = model.BUSKM.ToString(); //接班巡逻车里程表 this.starttime.InnerHtml = model.TICKTIME.ToLongTimeString(); //交接班时间 //this.endtime.InnerHtml = model.ENDTIME.ToShortDateString(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { this.result.InnerHtml += "<br/>第" + i + 1 + "次巡逻" + dt.Rows[i]["BEGINTIME"]; this.result.InnerHtml += "至" + dt.Rows[i]["ENDTIME"]; this.result.InnerHtml += "<br/>" + dt.Rows[i]["CONTENT"]; this.result.InnerHtml += "<br/>注:" + dt.Rows[i]["REMARK"] + "<br/>"; } } } else { this.result.InnerHtml = ""; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { Entity.BASE_PATROL model = GetPartolEntity(); if (model != null) { if (ViewState["id"] == null) { PatrolAdd(model);//添加人工巡逻日志 } else { bll.update(model); } Response.Redirect("ArtificialPatrol.aspx", true); } else { return; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (null == Request.QueryString["id"] || "" == Request.QueryString["id"]) { //添加状态页面 this.LabName.Text = "添加人工巡逻日志"; ShowTimes(1); } else { //编辑状态绑定 this.LabName.Text = "编辑人工巡逻日志"; decimal pid = Convert.ToDecimal(Request.QueryString["id"]); ViewState["id"] = Request.QueryString["id"]; Entity.BASE_PATROL model = bll.GetModel(pid); SetPatrolEntity(model); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entity.BASE_PATROL GetEntity(decimal PATROLID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PATROLID, DEPTID, RESPUSER, PATROLUSER, BUSNUMBER, MILEAGE, WEATHER, WITHIN, NEXTWITHIN, ACCEPTCAPTAIN, SHIFTCAPTAIN, ACCEPTBUSNUMBER, TICKTIME, BUSKM, GOODS, STATE, ATTENTION, REMARK "); strSql.Append(" from BASE_PATROL "); strSql.Append(" where PATROLID=:PATROLID "); OracleParameter[] parameters = { new OracleParameter(":PATROLID", OracleType.Number, 4) }; parameters[0].Value = PATROLID; Entity.BASE_PATROL entity = new Entity.BASE_PATROL(); DataTable dt = OracleHelper.Query(CommandType.Text, strSql.ToString(), parameters); if (dt.Rows.Count > 0) { if (dt.Rows[0]["PATROLID"].ToString() != "") { entity.PATROLID = decimal.Parse(dt.Rows[0]["PATROLID"].ToString()); } if (dt.Rows[0]["DEPTID"].ToString() != "") { entity.DEPTID = decimal.Parse(dt.Rows[0]["DEPTID"].ToString()); } entity.RESPUSER = dt.Rows[0]["RESPUSER"].ToString(); entity.PATROLUSER = dt.Rows[0]["PATROLUSER"].ToString(); entity.BUSNUMBER = dt.Rows[0]["BUSNUMBER"].ToString(); if (dt.Rows[0]["MILEAGE"].ToString() != "") { entity.MILEAGE = decimal.Parse(dt.Rows[0]["MILEAGE"].ToString()); } entity.WEATHER = dt.Rows[0]["WEATHER"].ToString(); entity.WITHIN = dt.Rows[0]["WITHIN"].ToString(); entity.NEXTWITHIN = dt.Rows[0]["NEXTWITHIN"].ToString(); entity.ACCEPTCAPTAIN = dt.Rows[0]["ACCEPTCAPTAIN"].ToString(); entity.SHIFTCAPTAIN = dt.Rows[0]["SHIFTCAPTAIN"].ToString(); entity.ACCEPTBUSNUMBER = dt.Rows[0]["ACCEPTBUSNUMBER"].ToString(); if (dt.Rows[0]["TICKTIME"].ToString() != "") { entity.TICKTIME = DateTime.Parse(dt.Rows[0]["TICKTIME"].ToString()); } if (dt.Rows[0]["BUSKM"].ToString() != "") { entity.BUSKM = decimal.Parse(dt.Rows[0]["BUSKM"].ToString()); } entity.GOODS = dt.Rows[0]["GOODS"].ToString(); if (dt.Rows[0]["STATE"].ToString() != "") { entity.STATE = decimal.Parse(dt.Rows[0]["STATE"].ToString()); } entity.ATTENTION = dt.Rows[0]["ATTENTION"].ToString(); entity.REMARK = dt.Rows[0]["REMARK"].ToString(); return(entity); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Entity.BASE_PATROL entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BASE_PATROL set "); strSql.Append(" PATROLID = :PATROLID , "); strSql.Append(" DEPTID = :DEPTID , "); strSql.Append(" RESPUSER = :RESPUSER , "); strSql.Append(" PATROLUSER = :PATROLUSER , "); strSql.Append(" BUSNUMBER = :BUSNUMBER , "); strSql.Append(" MILEAGE = :MILEAGE , "); strSql.Append(" WEATHER = :WEATHER , "); strSql.Append(" WITHIN = :WITHIN , "); strSql.Append(" NEXTWITHIN = :NEXTWITHIN , "); strSql.Append(" ACCEPTCAPTAIN = :ACCEPTCAPTAIN , "); strSql.Append(" SHIFTCAPTAIN = :SHIFTCAPTAIN , "); strSql.Append(" ACCEPTBUSNUMBER = :ACCEPTBUSNUMBER , "); strSql.Append(" TICKTIME = :TICKTIME , "); strSql.Append(" BUSKM = :BUSKM , "); strSql.Append(" GOODS = :GOODS , "); strSql.Append(" STATE = :STATE , "); strSql.Append(" ATTENTION = :ATTENTION , "); strSql.Append(" REMARK = :REMARK "); strSql.Append(" where PATROLID=:PATROLID "); OracleParameter[] parameters = { new OracleParameter(":PATROLID", OracleType.Number, 4), new OracleParameter(":DEPTID", OracleType.Number, 4), new OracleParameter(":RESPUSER", OracleType.VarChar, 20), new OracleParameter(":PATROLUSER", OracleType.VarChar, 20), new OracleParameter(":BUSNUMBER", OracleType.VarChar, 20), new OracleParameter(":MILEAGE", OracleType.Number, 4), new OracleParameter(":WEATHER", OracleType.VarChar, 50), new OracleParameter(":WITHIN", OracleType.VarChar, 500), new OracleParameter(":NEXTWITHIN", OracleType.VarChar, 500), new OracleParameter(":ACCEPTCAPTAIN", OracleType.VarChar, 20), new OracleParameter(":SHIFTCAPTAIN", OracleType.VarChar, 20), new OracleParameter(":ACCEPTBUSNUMBER", OracleType.VarChar, 20), new OracleParameter(":TICKTIME", OracleType.DateTime), new OracleParameter(":BUSKM", OracleType.Number, 4), new OracleParameter(":GOODS", OracleType.VarChar, 500), new OracleParameter(":STATE", OracleType.Number, 4), new OracleParameter(":ATTENTION", OracleType.VarChar, 500), new OracleParameter(":REMARK", OracleType.VarChar, 500) }; parameters[0].Value = entity.PATROLID; parameters[1].Value = entity.DEPTID; parameters[2].Value = entity.RESPUSER; parameters[3].Value = entity.PATROLUSER; parameters[4].Value = entity.BUSNUMBER; parameters[5].Value = entity.MILEAGE; parameters[6].Value = entity.WEATHER; parameters[7].Value = entity.WITHIN; parameters[8].Value = entity.NEXTWITHIN; parameters[9].Value = entity.ACCEPTCAPTAIN; parameters[10].Value = entity.SHIFTCAPTAIN; parameters[11].Value = entity.ACCEPTBUSNUMBER; parameters[12].Value = entity.TICKTIME; parameters[13].Value = entity.BUSKM; parameters[14].Value = entity.GOODS; parameters[15].Value = entity.STATE; parameters[16].Value = entity.ATTENTION; parameters[17].Value = entity.REMARK; int rows = OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条人工巡逻日志信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool update(Entity.BASE_PATROL model) { return(dal.Update(model)); }
/// <summary> /// 添加一条人工巡逻日志信息 /// </summary> /// <param name="model"></param> public int Add(Entity.BASE_PATROL model) { return(dal.Add(model)); }