/// <summary> /// 设备请求条码 /// </summary> public static RootObject BarCodeRequest(string M_WORKSTATION_SN, EnumQRCodeType qrcodeType, string CONTROL_TYPE, ref string jsonStr) { List <ContentDetail> CList = new List <ContentDetail>(); ContentDetail tail = new ContentDetail(); tail.M_FLAG = 11; // tail.M_WORKSTATION_SN = "Y00100101"; tail.M_WORKSTATION_SN = M_WORKSTATION_SN; CList.Add(tail); //上传参数 string strJson = WShelper.ReturnJsonData("OK", CONTROL_TYPE, CList); object objJson = strJson; object[] addParams = new object[] { objJson }; if (SysCfgModel.MesOfflineMode == true)//离线模式将上报数据存储到数据库 { RootObject rObj = new RootObject(); DBAccess.Model.QRCodeModel qrCode = bllQrCode.RequireQrCode(qrcodeType.ToString()); if (qrCode == null) { ContentDetail offlienTail = new ContentDetail(); offlienTail.M_SN = ""; rObj.M_COMENT = new List <ContentDetail>(); rObj.M_COMENT.Add(offlienTail); rObj.CONTROL_TYPE = ""; rObj.RES = "离线条码申请失败!"; return(rObj); } else { ContentDetail offlienTail = new ContentDetail(); offlienTail.M_SN = qrCode.QRCode; rObj.M_COMENT = new List <ContentDetail>(); rObj.M_COMENT.Add(offlienTail); rObj.CONTROL_TYPE = ""; rObj.RES = "OK!离线条码申请成功:" + qrCode.QRCode; qrCode.PintStatus = EnumQrCodeApplyStatus.已申请.ToString(); bllQrCode.Update(qrCode); return(rObj); } } else { object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams); string strRES = result.ToString(); RootObject rObj = new RootObject(); rObj = JsonConvert.DeserializeObject <RootObject>(strRES); jsonStr = strRES; return(rObj); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBAccess.Model.QRCodeModel GetModel(string QRCode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" QRCode,QRType,PintStatus,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 "); strSql.Append(" from QRCode "); strSql.Append(" where QRCode='" + QRCode + "' "); DBAccess.Model.QRCodeModel model = new DBAccess.Model.QRCodeModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBAccess.Model.QRCodeModel DataRowToModel(DataRow row) { DBAccess.Model.QRCodeModel model = new DBAccess.Model.QRCodeModel(); if (row != null) { if (row["QRCode"] != null) { model.QRCode = row["QRCode"].ToString(); } if (row["QRType"] != null) { model.QRType = row["QRType"].ToString(); } if (row["PintStatus"] != null) { model.PintStatus = row["PintStatus"].ToString(); } if (row["Reserve1"] != null) { model.Reserve1 = row["Reserve1"].ToString(); } if (row["Reserve2"] != null) { model.Reserve2 = row["Reserve2"].ToString(); } if (row["Reserve3"] != null) { model.Reserve3 = row["Reserve3"].ToString(); } if (row["Reserve4"] != null) { model.Reserve4 = row["Reserve4"].ToString(); } if (row["Reserve5"] != null) { model.Reserve5 = row["Reserve5"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DBAccess.Model.QRCodeModel model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.QRCode != null) { strSql1.Append("QRCode,"); strSql2.Append("'" + model.QRCode + "',"); } if (model.QRType != null) { strSql1.Append("QRType,"); strSql2.Append("'" + model.QRType + "',"); } if (model.PintStatus != null) { strSql1.Append("PintStatus,"); strSql2.Append("'" + model.PintStatus + "',"); } if (model.Reserve1 != null) { strSql1.Append("Reserve1,"); strSql2.Append("'" + model.Reserve1 + "',"); } if (model.Reserve2 != null) { strSql1.Append("Reserve2,"); strSql2.Append("'" + model.Reserve2 + "',"); } if (model.Reserve3 != null) { strSql1.Append("Reserve3,"); strSql2.Append("'" + model.Reserve3 + "',"); } if (model.Reserve4 != null) { strSql1.Append("Reserve4,"); strSql2.Append("'" + model.Reserve4 + "',"); } if (model.Reserve5 != null) { strSql1.Append("Reserve5,"); strSql2.Append("'" + model.Reserve5 + "',"); } strSql.Append("insert into QRCode("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DBAccess.Model.QRCodeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update QRCode set "); if (model.QRType != null) { strSql.Append("QRType='" + model.QRType + "',"); } if (model.PintStatus != null) { strSql.Append("PintStatus='" + model.PintStatus + "',"); } if (model.Reserve1 != null) { strSql.Append("Reserve1='" + model.Reserve1 + "',"); } else { strSql.Append("Reserve1= null ,"); } if (model.Reserve2 != null) { strSql.Append("Reserve2='" + model.Reserve2 + "',"); } else { strSql.Append("Reserve2= null ,"); } if (model.Reserve3 != null) { strSql.Append("Reserve3='" + model.Reserve3 + "',"); } else { strSql.Append("Reserve3= null ,"); } if (model.Reserve4 != null) { strSql.Append("Reserve4='" + model.Reserve4 + "',"); } else { strSql.Append("Reserve4= null ,"); } if (model.Reserve5 != null) { strSql.Append("Reserve5='" + model.Reserve5 + "',"); } else { strSql.Append("Reserve5= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where QRCode='" + model.QRCode + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }