/// <summary> /// 增加一条数据 /// </summary> public bool Add(ALineScrewDB.dbModel model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.测试时间 != null) { strSql1.Append("测试时间,"); strSql2.Append("'" + model.测试时间 + "',"); } if (model.二维码 != null) { strSql1.Append("二维码,"); strSql2.Append("'" + model.二维码 + "',"); } if (model.螺丝1马头结果 != null) { strSql1.Append("螺丝1马头结果,"); strSql2.Append("'" + model.螺丝1马头结果 + "',"); } if (model.螺丝1马头扭矩 != null) { strSql1.Append("螺丝1马头扭矩,"); strSql2.Append("'" + model.螺丝1马头扭矩 + "',"); } if (model.螺丝1马头角度 != null) { strSql1.Append("螺丝1马头角度,"); strSql2.Append("'" + model.螺丝1马头角度 + "',"); } if (model.螺丝1图片路径 != null) { strSql1.Append("螺丝1图片路径,"); strSql2.Append("'" + model.螺丝1图片路径 + "',"); } if (model.螺丝2马头结果 != null) { strSql1.Append("螺丝2马头结果,"); strSql2.Append("'" + model.螺丝2马头结果 + "',"); } if (model.螺丝2马头扭矩 != null) { strSql1.Append("螺丝2马头扭矩,"); strSql2.Append("'" + model.螺丝2马头扭矩 + "',"); } if (model.螺丝2马头角度 != null) { strSql1.Append("螺丝2马头角度,"); strSql2.Append("'" + model.螺丝2马头角度 + "',"); } if (model.螺丝2图片路径 != null) { strSql1.Append("螺丝2图片路径,"); strSql2.Append("'" + model.螺丝2图片路径 + "',"); } if (model.螺丝3马头结果 != null) { strSql1.Append("螺丝3马头结果,"); strSql2.Append("'" + model.螺丝3马头结果 + "',"); } if (model.螺丝3马头扭矩 != null) { strSql1.Append("螺丝3马头扭矩,"); strSql2.Append("'" + model.螺丝3马头扭矩 + "',"); } if (model.螺丝3马头角度 != null) { strSql1.Append("螺丝3马头角度,"); strSql2.Append("'" + model.螺丝3马头角度 + "',"); } if (model.螺丝3图片路径 != null) { strSql1.Append("螺丝3图片路径,"); strSql2.Append("'" + model.螺丝3图片路径 + "',"); } if (model.螺丝4马头结果 != null) { strSql1.Append("螺丝4马头结果,"); strSql2.Append("'" + model.螺丝4马头结果 + "',"); } if (model.螺丝4马头扭矩 != null) { strSql1.Append("螺丝4马头扭矩,"); strSql2.Append("'" + model.螺丝4马头扭矩 + "',"); } if (model.螺丝4马头角度 != null) { strSql1.Append("螺丝4马头角度,"); strSql2.Append("'" + model.螺丝4马头角度 + "',"); } if (model.螺丝4图片路径 != null) { strSql1.Append("螺丝4图片路径,"); strSql2.Append("'" + model.螺丝4图片路径 + "',"); } strSql.Append("insert into db("); 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 = DbHelperOleDb.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ALineScrewDB.dbModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update db set "); if (model.测试时间 != null) { strSql.Append("测试时间='" + model.测试时间 + "',"); } else { strSql.Append("测试时间= null ,"); } if (model.螺丝1马头结果 != null) { strSql.Append("螺丝1马头结果='" + model.螺丝1马头结果 + "',"); } else { strSql.Append("螺丝1马头结果= null ,"); } if (model.螺丝1马头扭矩 != null) { strSql.Append("螺丝1马头扭矩='" + model.螺丝1马头扭矩 + "',"); } else { strSql.Append("螺丝1马头扭矩= null ,"); } if (model.螺丝1马头角度 != null) { strSql.Append("螺丝1马头角度='" + model.螺丝1马头角度 + "',"); } else { strSql.Append("螺丝1马头角度= null ,"); } if (model.螺丝1图片路径 != null) { strSql.Append("螺丝1图片路径='" + model.螺丝1图片路径 + "',"); } else { strSql.Append("螺丝1图片路径= null ,"); } if (model.螺丝2马头结果 != null) { strSql.Append("螺丝2马头结果='" + model.螺丝2马头结果 + "',"); } else { strSql.Append("螺丝2马头结果= null ,"); } if (model.螺丝2马头扭矩 != null) { strSql.Append("螺丝2马头扭矩='" + model.螺丝2马头扭矩 + "',"); } else { strSql.Append("螺丝2马头扭矩= null ,"); } if (model.螺丝2马头角度 != null) { strSql.Append("螺丝2马头角度='" + model.螺丝2马头角度 + "',"); } else { strSql.Append("螺丝2马头角度= null ,"); } if (model.螺丝2图片路径 != null) { strSql.Append("螺丝2图片路径='" + model.螺丝2图片路径 + "',"); } else { strSql.Append("螺丝2图片路径= null ,"); } if (model.螺丝3马头结果 != null) { strSql.Append("螺丝3马头结果='" + model.螺丝3马头结果 + "',"); } else { strSql.Append("螺丝3马头结果= null ,"); } if (model.螺丝3马头扭矩 != null) { strSql.Append("螺丝3马头扭矩='" + model.螺丝3马头扭矩 + "',"); } else { strSql.Append("螺丝3马头扭矩= null ,"); } if (model.螺丝3马头角度 != null) { strSql.Append("螺丝3马头角度='" + model.螺丝3马头角度 + "',"); } else { strSql.Append("螺丝3马头角度= null ,"); } if (model.螺丝3图片路径 != null) { strSql.Append("螺丝3图片路径='" + model.螺丝3图片路径 + "',"); } else { strSql.Append("螺丝3图片路径= null ,"); } if (model.螺丝4马头结果 != null) { strSql.Append("螺丝4马头结果='" + model.螺丝4马头结果 + "',"); } else { strSql.Append("螺丝4马头结果= null ,"); } if (model.螺丝4马头扭矩 != null) { strSql.Append("螺丝4马头扭矩='" + model.螺丝4马头扭矩 + "',"); } else { strSql.Append("螺丝4马头扭矩= null ,"); } if (model.螺丝4马头角度 != null) { strSql.Append("螺丝4马头角度='" + model.螺丝4马头角度 + "',"); } else { strSql.Append("螺丝4马头角度= null ,"); } if (model.螺丝4图片路径 != null) { strSql.Append("螺丝4图片路径='" + model.螺丝4图片路径 + "',"); } else { strSql.Append("螺丝4图片路径= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where 二维码='" + model.二维码 + "' "); int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }