/// <summary> /// 得到一个对象实体 /// </summary> public Model.fmd010 GetModel(string SYBH) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" SYBH,SYMC,BMBH,ZWBH,XB,SR,ZZ,SFZ,SJH,EMAIL,ZT,RLZBH,RLR,RLSJ,RLDMM,GXZBH,GXR,GXSJ,GXDMM "); strSql.Append(" from fmd010 "); strSql.Append(" where SYBH='" + SYBH + "' "); Model.fmd010 model = new Model.fmd010(); DataSet ds = DbHelperMySql.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.fmd010 GetModel(string SYBH) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" SYBH,SYMC,BMBH,ZWBH,XB,SR,ZZ,SFZ,SJH,EMAIL,ZT,RLZBH,RLR,RLSJ,RLDMM,GXZBH,GXR,GXSJ,GXDMM "); strSql.Append(" from fmd010 "); strSql.Append(" where SYBH='" + SYBH + "' "); Model.fmd010 model = new Model.fmd010(); DataSet ds = DbHelperMySql.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.fmd010 DataRowToModel(DataRow row) { Model.fmd010 model = new Model.fmd010(); if (row != null) { if (row["SYBH"] != null) { model.SYBH = row["SYBH"].ToString(); } if (row["SYMC"] != null) { model.SYMC = row["SYMC"].ToString(); } if (row["BMBH"] != null) { model.BMBH = row["BMBH"].ToString(); } if (row["ZWBH"] != null) { model.ZWBH = row["ZWBH"].ToString(); } if (row["XB"] != null) { model.XB = row["XB"].ToString(); } if (row["SR"] != null) { model.SR = row["SR"].ToString(); } if (row["ZZ"] != null) { model.ZZ = row["ZZ"].ToString(); } if (row["SFZ"] != null) { model.SFZ = row["SFZ"].ToString(); } if (row["SJH"] != null) { model.SJH = row["SJH"].ToString(); } if (row["EMAIL"] != null) { model.EMAIL = row["EMAIL"].ToString(); } if (row["ZT"] != null) { model.ZT = row["ZT"].ToString(); } if (row["RLZBH"] != null) { model.RLZBH = row["RLZBH"].ToString(); } if (row["RLR"] != null) { model.RLR = row["RLR"].ToString(); } if (row["RLSJ"] != null) { model.RLSJ = row["RLSJ"].ToString(); } if (row["RLDMM"] != null) { model.RLDMM = row["RLDMM"].ToString(); } if (row["GXZBH"] != null) { model.GXZBH = row["GXZBH"].ToString(); } if (row["GXR"] != null) { model.GXR = row["GXR"].ToString(); } if (row["GXSJ"] != null) { model.GXSJ = row["GXSJ"].ToString(); } if (row["GXDMM"] != null) { model.GXDMM = row["GXDMM"].ToString(); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public string AddSQL(Model.fmd010 model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.SYBH != null) { strSql1.Append("SYBH,"); strSql2.Append("'" + model.SYBH + "',"); } if (model.SYMC != null) { strSql1.Append("SYMC,"); strSql2.Append("'" + model.SYMC + "',"); } if (model.BMBH != null) { strSql1.Append("BMBH,"); strSql2.Append("'" + model.BMBH + "',"); } if (model.ZWBH != null) { strSql1.Append("ZWBH,"); strSql2.Append("'" + model.ZWBH + "',"); } if (model.XB != null) { strSql1.Append("XB,"); strSql2.Append("'" + model.XB + "',"); } if (model.SR != null) { strSql1.Append("SR,"); strSql2.Append("'" + model.SR + "',"); } if (model.ZZ != null) { strSql1.Append("ZZ,"); strSql2.Append("'" + model.ZZ + "',"); } if (model.SFZ != null) { strSql1.Append("SFZ,"); strSql2.Append("'" + model.SFZ + "',"); } if (model.SJH != null) { strSql1.Append("SJH,"); strSql2.Append("'" + model.SJH + "',"); } if (model.EMAIL != null) { strSql1.Append("EMAIL,"); strSql2.Append("'" + model.EMAIL + "',"); } if (model.ZT != null) { strSql1.Append("ZT,"); strSql2.Append("'" + model.ZT + "',"); } if (model.RLZBH != null) { strSql1.Append("RLZBH,"); strSql2.Append("'" + model.RLZBH + "',"); } if (model.RLR != null) { strSql1.Append("RLR,"); strSql2.Append("'" + model.RLR + "',"); } if (model.RLSJ != null) { strSql1.Append("RLSJ,"); strSql2.Append("'" + model.RLSJ + "',"); } if (model.RLDMM != null) { strSql1.Append("RLDMM,"); strSql2.Append("'" + model.RLDMM + "',"); } if (model.GXZBH != null) { strSql1.Append("GXZBH,"); strSql2.Append("'" + model.GXZBH + "',"); } if (model.GXR != null) { strSql1.Append("GXR,"); strSql2.Append("'" + model.GXR + "',"); } if (model.GXSJ != null) { strSql1.Append("GXSJ,"); strSql2.Append("'" + model.GXSJ + "',"); } if (model.GXDMM != null) { strSql1.Append("GXDMM,"); strSql2.Append("'" + model.GXDMM + "',"); } if (model.PORTID != null) { strSql1.Append("PORTID,"); strSql2.Append("'" + model.PORTID + "',"); } if (model.PRINTERID != null) { strSql1.Append("PRINTERID,"); strSql2.Append("'" + model.PRINTERID + "',"); } strSql.Append("insert into fmd010("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); return(strSql.ToString()); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.fmd010 DataRowToModel(DataRow row) { Model.fmd010 model = new Model.fmd010(); if (row != null) { if (row["SYBH"] != null) { model.SYBH = row["SYBH"].ToString(); } if (row["SYMC"] != null) { model.SYMC = row["SYMC"].ToString(); } if (row["BMBH"] != null) { model.BMBH = row["BMBH"].ToString(); } if (row["ZWBH"] != null) { model.ZWBH = row["ZWBH"].ToString(); } if (row["XB"] != null) { model.XB = row["XB"].ToString(); } if (row["SR"] != null) { model.SR = row["SR"].ToString(); } if (row["ZZ"] != null) { model.ZZ = row["ZZ"].ToString(); } if (row["SFZ"] != null) { model.SFZ = row["SFZ"].ToString(); } if (row["SJH"] != null) { model.SJH = row["SJH"].ToString(); } if (row["EMAIL"] != null) { model.EMAIL = row["EMAIL"].ToString(); } if (row["ZT"] != null) { model.ZT = row["ZT"].ToString(); } if (row["RLZBH"] != null) { model.RLZBH = row["RLZBH"].ToString(); } if (row["RLR"] != null) { model.RLR = row["RLR"].ToString(); } if (row["RLSJ"] != null) { model.RLSJ = row["RLSJ"].ToString(); } if (row["RLDMM"] != null) { model.RLDMM = row["RLDMM"].ToString(); } if (row["GXZBH"] != null) { model.GXZBH = row["GXZBH"].ToString(); } if (row["GXR"] != null) { model.GXR = row["GXR"].ToString(); } if (row["GXSJ"] != null) { model.GXSJ = row["GXSJ"].ToString(); } if (row["GXDMM"] != null) { model.GXDMM = row["GXDMM"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public string UpdateSQL(Model.fmd010 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update fmd010 set "); if (model.SYMC != null) { strSql.Append("SYMC='" + model.SYMC + "',"); } if (model.BMBH != null) { strSql.Append("BMBH='" + model.BMBH + "',"); } if (model.ZWBH != null) { strSql.Append("ZWBH='" + model.ZWBH + "',"); } else { strSql.Append("ZWBH= null ,"); } if (model.XB != null) { strSql.Append("XB='" + model.XB + "',"); } else { strSql.Append("XB= null ,"); } if (model.SR != null) { strSql.Append("SR='" + model.SR + "',"); } else { strSql.Append("SR= null ,"); } if (model.ZZ != null) { strSql.Append("ZZ='" + model.ZZ + "',"); } else { strSql.Append("ZZ= null ,"); } if (model.SFZ != null) { strSql.Append("SFZ='" + model.SFZ + "',"); } else { strSql.Append("SFZ= null ,"); } if (model.SJH != null) { strSql.Append("SJH='" + model.SJH + "',"); } else { strSql.Append("SJH= null ,"); } if (model.EMAIL != null) { strSql.Append("EMAIL='" + model.EMAIL + "',"); } else { strSql.Append("EMAIL= null ,"); } if (model.ZT != null) { strSql.Append("ZT='" + model.ZT + "',"); } else { strSql.Append("ZT= null ,"); } if (model.RLZBH != null) { strSql.Append("RLZBH='" + model.RLZBH + "',"); } else { strSql.Append("RLZBH= null ,"); } if (model.RLR != null) { strSql.Append("RLR='" + model.RLR + "',"); } else { strSql.Append("RLR= null ,"); } if (model.RLSJ != null) { strSql.Append("RLSJ='" + model.RLSJ + "',"); } else { strSql.Append("RLSJ= null ,"); } if (model.RLDMM != null) { strSql.Append("RLDMM='" + model.RLDMM + "',"); } else { strSql.Append("RLDMM= null ,"); } if (model.GXZBH != null) { strSql.Append("GXZBH='" + model.GXZBH + "',"); } else { strSql.Append("GXZBH= null ,"); } if (model.GXR != null) { strSql.Append("GXR='" + model.GXR + "',"); } else { strSql.Append("GXR= null ,"); } if (model.GXSJ != null) { strSql.Append("GXSJ='" + model.GXSJ + "',"); } else { strSql.Append("GXSJ= null ,"); } if (model.GXDMM != null) { strSql.Append("GXDMM='" + model.GXDMM + "',"); } else { strSql.Append("GXDMM= null ,"); } if (model.PORTID != null) { strSql.Append("PORTID='" + model.PORTID + "',"); } else { strSql.Append("PORTID= null ,"); } if (model.PRINTERID != null) { strSql.Append("PRINTERID='" + model.PRINTERID + "',"); } else { strSql.Append("PRINTERID= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where SYBH='" + model.SYBH + "' "); return(strSql.ToString()); }