public bool DownResidents(List <resident_base_infoBean> list) { int rt = 0; List <string> _sqlList = new List <string>(); for (int j = 0; j < list.Count; j++) { string sql = ""; ////先判断有没有数据,有就做更新处理,没有就插入 //if(HaveData(list[j].id)) //{ sql = string.Format("delete from resident_base_info where id='{0}'", list[j].id); _sqlList.Add(sql); //} #region insert sql = @"insert into resident_base_info (id,archive_no,pb_archive,name,sex, birthday,age,id_number,card_pic,company,phone,link_name,link_phone, resident_type,address,residence_address,nation,blood_group,blood_rh, education,profession,marital_status,pay_type,pay_other,drug_allergy, allergy_other,exposure,disease_other,is_hypertension,is_diabetes, is_psychosis,is_tuberculosis,is_heredity,heredity_name,is_deformity, deformity_name,is_poor,kitchen,fuel,other_fuel,drink,other_drink,toilet, poultry,medical_code,photo_code,aichive_org,doctor_id,doctor_name, create_archives_name,is_signing,province_code,province_name,city_code, city_name,county_code,county_name,towns_code,towns_name,village_code, village_name,status,remark,create_user,create_name,create_time,create_org, create_org_name,update_user,update_name,upload_status) values ('" + list[j].id + "','" + list[j].archive_no + "', '" + list[j].pb_archive + "','" + list[j].name + "','" + list[j].sex + "','" + list[j].birthday + "','" + list[j].age + "','" + list[j].id_number + "','" + list[j].CardPic + "','" + list[j].company + "','" + list[j].phone + "','" + list[j].link_name + "','" + list[j].link_phone + "','" + list[j].resident_type + "','" + list[j].address + "','" + list[j].residence_address + "', '" + list[j].nation + "', '" + list[j].blood_group + "', '" + list[j].blood_rh + "', '" + list[j].education + "', '" + list[j].profession + "', '" + list[j].marital_status + "', '" + list[j].pay_type + "', '" + list[j].pay_other + "', '" + list[j].drug_allergy + "', '" + list[j].allergy_other + "', '" + list[j].exposure + "', '" + list[j].disease_other + "', '" + list[j].is_hypertension + "', '" + list[j].is_diabetes + "', '" + list[j].is_psychosis + "', '" + list[j].is_tuberculosis + "', '" + list[j].is_heredity + "', '" + list[j].heredity_name + "', '" + list[j].is_deformity + "', '" + list[j].deformity_name + "', '" + list[j].is_poor + "', '" + list[j].kitchen + "', '" + list[j].fuel + "', '" + list[j].other_fuel + "', '" + list[j].drink + "', '" + list[j].other_drink + "', '" + list[j].toilet + "', '" + list[j].poultry + "', '" + list[j].medical_code + "', '" + list[j].photo_code + "', '" + list[j].aichive_org + "', '" + list[j].doctor_id + "', '" + list[j].doctor_name + "', '" + list[j].create_name + "', '" + list[j].is_signing + "', '" + list[j].province_code + "', '" + list[j].province_name + "', '" + list[j].city_code + "', '" + list[j].city_name + "', '" + list[j].county_code + "', '" + list[j].county_name + "', '" + list[j].towns_code + "', '" + list[j].towns_name + "', '" + list[j].village_code + "', '" + list[j].village_name + "', '" + list[j].status + "', '" + list[j].remark + "', '" + list[j].create_user + "', '" + list[j].create_name + "', '" + list[j].create_time + "', '" + list[j].create_org + "', '" + list[j].create_org_name + "', '" + list[j].update_user + "', '" + list[j].update_name + "', '1')"; #endregion _sqlList.Add(sql); } rt = DbHelperMySQL.ExecuteSqlTran(_sqlList); return(rt == 0 ? false : true); }
public int UpdateOldestimateTran(string r, string barcode, string idnumber, string examid, string stag) { int ret = 0; List <string> _lst = new List <string>(); String sql = string.Format(@"update zkhw_tj_bgdc set lnrzlnlpg='{0}' where bar_code = '{1}' and id_number='{2}'", r, barcode, idnumber); _lst.Add(sql); sql = string.Format(@"update physical_examination_record set base_selfcare_estimate='{0}' where id='{1}'", stag, examid); _lst.Add(sql); ret = DbHelperMySQL.ExecuteSqlTran(_lst); return(ret); }
public bool aUpersonalBasicInfo(bean.resident_base_infoBean hm, string id, DataTable goodsList, DataTable goodsList0, DataTable goodsList1, DataTable goodsList2, DataTable goodsList3, int intbian) { int ret = 0; String sql = ""; String sql0 = ""; String sql1 = ""; String sql2 = ""; String sql3 = ""; String sql4 = ""; if (id == "") { #region 新插入 id = Result.GetNewId(); sql = @"insert into resident_base_info (id,archive_no,pb_archive,name,sex,birthday,id_number,address,nation,company,phone,link_name,link_phone,resident_type,residence_address,blood_group,blood_rh,education,profession,marital_status,pay_type,pay_other,drug_allergy,allergy_other,exposure,disease_other,is_hypertension,is_diabetes,is_psychosis,is_tuberculosis,is_heredity,heredity_name,is_deformity,deformity_name,is_poor,kitchen,fuel,other_fuel,drink,other_drink,toilet,poultry,medical_code,photo_code,aichive_org,doctor_name,upload_status,upload_time,create_user,create_name,create_time,create_org,create_org_name,is_signing,update_time,is_gravida) values "; sql += @" ('" + id + "','" + hm.archive_no + "', '" + hm.pb_archive + "', '" + hm.name + "', '" + hm.sex + "', '" + hm.birthday + "', '" + hm.id_number + "', '" + hm.address + "', '" + hm.nation + "','" + hm.company + "', '" + hm.phone + "', '" + hm.link_name + "', '" + hm.link_phone + "', '" + hm.resident_type + "', '" + hm.address + "', '" + hm.blood_group + "', '" + hm.blood_rh + "', '" + hm.education + "', '" + hm.profession + "','" + hm.marital_status + "', '" + hm.pay_type + "', '" + hm.pay_other + "', '" + hm.drug_allergy + "', '" + hm.allergy_other + "', '" + hm.exposure + "', '" + hm.disease_other + "', '" + hm.is_hypertension + "', '" + hm.is_diabetes + "', '" + hm.is_psychosis + "','" + hm.is_tuberculosis + "', '" + hm.is_heredity + "', '" + hm.heredity_name + "', '" + hm.is_deformity + "', '" + hm.deformity_name + "', '" + hm.is_poor + "', '" + hm.kitchen + "', '" + hm.fuel + "', '" + hm.other_fuel + "', '" + hm.drink + "','" + hm.other_drink + "', '" + hm.toilet + "', '" + hm.poultry + "', '" + hm.medical_code + "', '" + hm.photo_code + "', '" + basicInfoSettings.organ_name + "', '" + hm.is_signing + "', '" + hm.synchro_time + "', '" + hm.create_user + "','" + hm.create_name + "', '" + hm.create_time + "', '" + hm.create_org + "', '" + hm.create_org_name + "'," + hm.is_signing + "," + hm.update_time + "," + hm.is_gravida + ")"; if (goodsList.Rows.Count > 0) { for (int i = 0; i < goodsList.Rows.Count; i++) { if (i == 0) { sql0 += "insert into resident_diseases(archive_no,id_number,name,resident_base_info_id,disease_name,disease_date,disease_type,note) values ('" + hm.archive_no + "','" + hm.id_number + "','" + hm.name + "','" + id + "','" + goodsList.Rows[i]["disease_name"] + "','" + goodsList.Rows[i]["disease_date"] + "','" + goodsList.Rows[i]["disease_type"] + "','" + goodsList.Rows[i]["disease_note"] + "')"; } else { sql0 += ",('" + hm.archive_no + "','" + hm.id_number + "','" + hm.name + "','" + id + "','" + goodsList.Rows[i]["disease_name"] + "','" + goodsList.Rows[i]["disease_date"] + "','" + goodsList.Rows[i]["disease_type"] + "','" + goodsList.Rows[i]["disease_note"] + "')"; } } } if (goodsList0.Rows.Count > 0) { for (int i = 0; i < goodsList0.Rows.Count; i++) { if (i == 0) { sql1 += "insert into operation_record(resident_base_info_id,operation_name,operation_time,operation_code) values ('" + id + "','" + goodsList0.Rows[i]["operation_name"] + "','" + goodsList0.Rows[i]["operation_time"] + "','" + goodsList0.Rows[i]["operation_code"] + "')"; } else { sql1 += ",('" + id + "','" + goodsList0.Rows[i]["operation_name"] + "','" + goodsList0.Rows[i]["operation_time"] + "','" + goodsList0.Rows[i]["operation_code"] + "')"; } } } if (goodsList1.Rows.Count > 0) { for (int i = 0; i < goodsList1.Rows.Count; i++) { if (i == 0) { sql2 += "insert into traumatism_record(resident_base_info_id,traumatism_name,traumatism_time,traumatism_code) values ('" + id + "','" + goodsList1.Rows[i]["traumatism_name"] + "','" + goodsList1.Rows[i]["traumatism_time"] + "','" + goodsList1.Rows[i]["traumatism_code"] + "')"; } else { sql2 += ",('" + id + "','" + goodsList1.Rows[i]["traumatism_name"] + "','" + goodsList1.Rows[i]["traumatism_time"] + "','" + goodsList1.Rows[i]["traumatism_code"] + "')"; } } } if (goodsList2.Rows.Count > 0) { for (int i = 0; i < goodsList2.Rows.Count; i++) { if (i == 0) { sql3 += "insert into metachysis_record(resident_base_info_id,metachysis_reasonn,metachysis_time,metachysis_code) values ('" + id + "','" + goodsList2.Rows[i]["metachysis_reasonn"] + "','" + goodsList2.Rows[i]["metachysis_time"] + "','" + goodsList2.Rows[i]["metachysis_code"] + "')"; } else { sql3 += ",('" + id + "','" + goodsList2.Rows[i]["metachysis_reasonn"] + "','" + goodsList2.Rows[i]["metachysis_time"] + "','" + goodsList2.Rows[i]["metachysis_code"] + "')"; } } } if (goodsList3.Rows.Count > 0) { for (int i = 0; i < goodsList3.Rows.Count; i++) { if (i == 0) { sql4 += "insert into family_record(resident_base_info_id,relation,disease_name,disease_type) values ('" + id + "','" + goodsList3.Rows[i]["relation"] + "','" + goodsList3.Rows[i]["disease_name"] + "','" + goodsList3.Rows[i]["disease_type"] + "')"; } else { sql4 += ",('" + id + "','" + goodsList3.Rows[i]["relation"] + "','" + goodsList3.Rows[i]["disease_name"] + "','" + goodsList3.Rows[i]["disease_type"] + "')"; } } } #endregion ret = DbHelperMySQL.ExecuteSql(sql); if (ret == 0) { return(false); } if (sql0 != "") { DbHelperMySQL.ExecuteSql(sql0); } if (sql1 != "") { DbHelperMySQL.ExecuteSql(sql1); } if (sql2 != "") { DbHelperMySQL.ExecuteSql(sql2); } if (sql3 != "") { DbHelperMySQL.ExecuteSql(sql3); } if (sql4 != "") { DbHelperMySQL.ExecuteSql(sql4); } return(ret == 0 ? false : true); } else { List <string> _lst = new List <string>(); #region 更新 sql = @"update resident_base_info set name='" + hm.name + "', address='" + hm.address + "', id_number='" + hm.id_number + "',nation='" + hm.nation + "',company='" + hm.company + "',phone= '" + hm.phone + "',link_name= '" + hm.link_name + "',link_phone= '" + hm.link_phone + "',resident_type= '" + hm.resident_type + "',residence_address='" + hm.residence_address + "',blood_group= '" + hm.blood_group + "',blood_rh='" + hm.blood_rh + "',education='" + hm.education + "',profession='" + hm.profession + "',marital_status='" + hm.marital_status + "',pay_type='" + hm.pay_type + "',pay_other= '" + hm.pay_other + "',drug_allergy='" + hm.drug_allergy + "',allergy_other='" + hm.allergy_other + "',exposure= '" + hm.exposure + "',disease_other='" + hm.disease_other + "',is_hypertension='" + hm.is_hypertension + "',is_diabetes= '" + hm.is_diabetes + "',is_psychosis='" + hm.is_psychosis + "',is_tuberculosis='" + hm.is_tuberculosis + "',is_heredity= '" + hm.is_heredity + "',heredity_name= '" + hm.heredity_name + "',is_deformity='" + hm.is_deformity + "',deformity_name='" + hm.deformity_name + "',is_poor= '" + hm.is_poor + "',kitchen='" + hm.kitchen + "',fuel='" + hm.fuel + "',other_fuel='" + hm.other_fuel + "',drink= '" + hm.drink + "',other_drink='" + hm.other_drink + "',toilet= '" + hm.toilet + "',poultry= '" + hm.poultry + "',medical_code='" + hm.medical_code + "',is_signing= '" + hm.is_signing + "',update_user='******',update_name='" + hm.update_name + "',update_time='" + hm.update_time + "',upload_status=0,is_gravida=" + hm.is_gravida + " where id = '" + id + "'"; _lst.Add(sql); sql0 = @"delete from resident_diseases where resident_base_info_id = '" + id + "';"; sql1 = @"delete from operation_record where resident_base_info_id = '" + id + "';"; sql2 = @"delete from traumatism_record where resident_base_info_id = '" + id + "';"; sql3 = @"delete from metachysis_record where resident_base_info_id = '" + id + "';"; sql4 = @"delete from family_record where resident_base_info_id = '" + id + "';"; if (goodsList.Rows.Count > 0) { for (int i = 0; i < goodsList.Rows.Count; i++) { if (i == 0) { sql0 += "insert into resident_diseases(archive_no,id_number,name,resident_base_info_id,disease_name,disease_date,disease_type,note) values ('" + hm.archive_no + "','" + hm.id_number + "','" + hm.name + "','" + id + "','" + goodsList.Rows[i]["disease_name"] + "','" + goodsList.Rows[i]["disease_date"] + "','" + goodsList.Rows[i]["disease_type"] + "','" + goodsList.Rows[i]["disease_note"] + "')"; } else { sql0 += ",('" + hm.archive_no + "','" + hm.id_number + "','" + hm.name + "','" + id + "','" + goodsList.Rows[i]["disease_name"] + "','" + goodsList.Rows[i]["disease_date"] + "','" + goodsList.Rows[i]["disease_type"] + "','" + goodsList.Rows[i]["disease_note"] + "')"; } } } if (goodsList0.Rows.Count > 0) { for (int i = 0; i < goodsList0.Rows.Count; i++) { if (i == 0) { sql1 += "insert into operation_record(resident_base_info_id,operation_name,operation_time,operation_code) values ('" + id + "','" + goodsList0.Rows[i]["operation_name"] + "','" + goodsList0.Rows[i]["operation_time"] + "','" + goodsList0.Rows[i]["operation_code"] + "')"; } else { sql1 += ",('" + id + "','" + goodsList0.Rows[i]["operation_name"] + "','" + goodsList0.Rows[i]["operation_time"] + "','" + goodsList0.Rows[i]["operation_code"] + "')"; } } } if (goodsList1.Rows.Count > 0) { for (int i = 0; i < goodsList1.Rows.Count; i++) { if (i == 0) { sql2 += "insert into traumatism_record(resident_base_info_id,traumatism_name,traumatism_time,traumatism_code) values ('" + id + "','" + goodsList1.Rows[i]["traumatism_name"] + "','" + goodsList1.Rows[i]["traumatism_time"] + "','" + goodsList1.Rows[i]["traumatism_code"] + "')"; } else { sql2 += ",('" + id + "','" + goodsList1.Rows[i]["traumatism_name"] + "','" + goodsList1.Rows[i]["traumatism_time"] + "','" + goodsList1.Rows[i]["traumatism_code"] + "')"; } } } if (goodsList2.Rows.Count > 0) { for (int i = 0; i < goodsList2.Rows.Count; i++) { if (i == 0) { sql3 += "insert into metachysis_record(resident_base_info_id,metachysis_reasonn,metachysis_time,metachysis_code) values ('" + id + "','" + goodsList2.Rows[i]["metachysis_reasonn"] + "','" + goodsList2.Rows[i]["metachysis_time"] + "','" + goodsList2.Rows[i]["metachysis_code"] + "')"; } else { sql3 += ",('" + id + "','" + goodsList2.Rows[i]["metachysis_reasonn"] + "','" + goodsList2.Rows[i]["metachysis_time"] + "','" + goodsList2.Rows[i]["metachysis_code"] + "')"; } } } if (goodsList3.Rows.Count > 0) { for (int i = 0; i < goodsList3.Rows.Count; i++) { string relation = ""; if (goodsList3.Rows[i]["relation"].ToString() == "父亲") { relation = "1"; } else if (goodsList3.Rows[i]["relation"].ToString() == "母亲") { relation = "2"; } else if (goodsList3.Rows[i]["relation"].ToString() == "兄弟姐妹") { relation = "3"; } else if (goodsList3.Rows[i]["relation"].ToString() == "子女") { relation = "4"; } if (i == 0) { sql4 += "insert into family_record(resident_base_info_id,relation,disease_name,disease_type) values ('" + id + "','" + relation + "','" + goodsList3.Rows[i]["disease_name"] + "','" + goodsList3.Rows[i]["disease_type"] + "')"; } else { sql4 += ",('" + id + "','" + relation + "','" + goodsList3.Rows[i]["disease_name"] + "','" + goodsList3.Rows[i]["disease_type"] + "')"; } } } #endregion #region 身份证、名字变化就要改变别的表 if (intbian >= 2) { sql = string.Format("update zkhw_tj_bc set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_ncg set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_sgtz set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_sh set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_xcg set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_xdt set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_xy set id_number='{0}' Where aichive_no='{1}'", hm.id_number, hm.archive_no); _lst.Add(sql); } if (intbian > 0) { sql = string.Format("update physical_examination_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update children_health_record set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update children_tcm_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update diabetes_follow_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update elderly_selfcare_estimate set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update elderly_tcm_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update fuv_hypertension set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update gravida_after_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update gravida_follow_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update gravida_info set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update neonatus_info set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update poor_follow_record set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update psychosis_info set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update sign_service_info set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update tuberculosis_follow_record set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update tuberculosis_info set name='{0}', id_number='{1}' Where archive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_bgdc set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); sql = string.Format("update zkhw_tj_jk set name='{0}', id_number='{1}' Where aichive_no='{2}'", hm.name, hm.id_number, hm.archive_no); _lst.Add(sql); } #endregion ret = DbHelperMySQL.ExecuteSqlTran(_lst); if (ret == 0) { return(false); } if (sql0 != "") { DbHelperMySQL.ExecuteSql(sql0); } if (sql1 != "") { DbHelperMySQL.ExecuteSql(sql1); } if (sql2 != "") { DbHelperMySQL.ExecuteSql(sql2); } if (sql3 != "") { DbHelperMySQL.ExecuteSql(sql3); } if (sql4 != "") { DbHelperMySQL.ExecuteSql(sql4); } return(ret == 0 ? false : true); } }