/// <summary> /// 添加维修实施记录 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddRepairImplement(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维修 //给对象赋值 EccmRepairOrderImplementModel model = new EccmRepairOrderImplementModel(); model.order_id = int.Parse(orderid); model.equCode = "";//该处没有设备编码 model.implement_content = content; model.implement_time = DateTime.Now; model.uid_handle = int.Parse(uid); EccmRepairOrderImplementBLL bll = new EccmRepairOrderImplementBLL(); int id = bll.Add(model); //插入并获取id if (id > 0) //实施内容插入成功 { EccmImplementImgModel imgModel = new EccmImplementImgModel(); imgModel.implement_id = id; imgModel.img_path = imgurl; imgModel.img_type = int.Parse(type);; //1巡检2维保3维修 EccmImplementImgBLL img_bll = new EccmImplementImgBLL(); if (img_bll.Add(imgModel)) //插入实施图片 { EccmRepairOrderModel repairModel = new EccmRepairOrderModel(); repairModel.order_id = int.Parse(orderid); repairModel.r_state = 4;//0未派单1已派单2已接单3处理中4完成 repairModel.r_etime = DateTime.Now; EccmRepairOrderBLL repairBLL = new EccmRepairOrderBLL(); repairBLL.UpdateStates(repairModel);//更改订单为完成 jr.IsSucceed = true; jr.Msg = "添加成功"; } } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(EccmRepairOrderImplementModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into eccm_repair_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);"); strSql.Append("select @@IDENTITY;"); 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; object obj = MySQLHelper.ExecuteScalar(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(EccmRepairOrderImplementModel model) { return(_dal.Add(model)); }