/// <summary> /// 添加巡检实施 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddInspectionImplement(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "添加失败", RedirectUrl = string.Empty }; //获取传递参数 string orderid = context.Request.Params["orderid"]; string ordersn = context.Request.Params["ordersn"]; string content = context.Request.Params["content"]; HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; string imgurl = context.Request.Params["imgurl"]; string type = context.Request.Params["type"];//1巡检2维保3维修 //给对象赋值 EccmInspectionOrderImplementModel model = new EccmInspectionOrderImplementModel(); model.order_id = int.Parse(orderid); model.equCode = "";//该处没有设备编码 model.implement_content = content; model.implement_time = DateTime.Now; model.uid_handle = int.Parse(uid); EccmInspectionOrderImplementBLL bll = new EccmInspectionOrderImplementBLL(); int id = bll.Add(model); //插入并获取id if (id > 0) //实施内容插入成功 { EccmImplementImgModel img_model = new EccmImplementImgModel(); img_model.implement_id = id; img_model.img_path = imgurl; img_model.img_type = int.Parse(type);; //1巡检2维保3维修 EccmImplementImgBLL img_bll = new EccmImplementImgBLL(); if (img_bll.Add(img_model)) //插入实施图片 { EccmInspectionOrderModel inspection_model = new EccmInspectionOrderModel(); inspection_model.order_id = int.Parse(orderid); inspection_model.order_stats = 4;//0未派单1已派单2已接单3处理中4完成 inspection_model.order_finish_time = DateTime.Now; EccmInspectionOrderBLL inspection_bll = new EccmInspectionOrderBLL(); inspection_bll.UpdateStates(inspection_model);//更改订单为完成 jr.IsSucceed = true; jr.Msg = "添加成功"; } } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(EccmInspectionOrderImplementModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into eccm_inspection_order_implement("); strSql.Append("order_id,equCode,implement_content,implement_time,uid_handle,ext1,ext2,ext3)"); strSql.Append(" values ("); strSql.Append("@order_id,@equCode,@implement_content,@implement_time,@uid_handle,@ext1,@ext2,@ext3)"); MySqlParameter[] parameters = { new MySqlParameter("@order_id", MySqlDbType.Int32, 11), new MySqlParameter("@equCode", MySqlDbType.VarChar, 50), new MySqlParameter("@implement_content", MySqlDbType.Text), new MySqlParameter("@implement_time", MySqlDbType.DateTime), new MySqlParameter("@uid_handle", MySqlDbType.Int32, 11), new MySqlParameter("@ext1", MySqlDbType.VarChar, 50), new MySqlParameter("@ext2", MySqlDbType.VarChar, 50), new MySqlParameter("@ext3", MySqlDbType.VarChar, 50) }; parameters[0].Value = model.order_id; parameters[1].Value = model.equCode; parameters[2].Value = model.implement_content; parameters[3].Value = model.implement_time; parameters[4].Value = model.uid_handle; parameters[5].Value = model.ext1; parameters[6].Value = model.ext2; parameters[7].Value = model.ext3; int rows = MySQLHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { string sql = "select max(implement_id) from eccm_inspection_order_implement;";//获取实施id int i = Convert.ToInt32(MySQLHelper.ExecuteScalar(sql, null)); return(i); } else { return(0); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(EccmInspectionOrderImplementModel model) { return(_dal.Add(model)); }