/// <summary> /// 执行插件SQL语句 /// </summary> public bool ExeSqlStr(string dirPath, string xPath) { bool result = true; List <string> ls = ReadChildNodesValue(dirPath + DTKeys.FILE_PLUGIN_XML_CONFING, xPath); if (ls != null) { ArrayList al = new ArrayList(); foreach (string str in ls) { al.Add(str); } if (!DbHelperMySql.ExecuteSqlTran(al)) { result = false; } } return(result); }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { Hashtable sqllist = new Hashtable(); //List<CommandInfo> sqllist = new List<CommandInfo>(); //删除站点OAtuh应用 StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "site_oauth"); strSql1.Append(" where oauth_id=@oauth_id"); MySqlParameter[] parameters1 = { new MySqlParameter("@oauth_id", MySqlDbType.Int32, 4) }; parameters1[0].Value = id; //CommandInfo cmd = new CommandInfo(strSql1.ToString(), parameters1); sqllist.Add(strSql1.ToString(), parameters1); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "oauth_app "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters[0].Value = id; //cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(strSql.ToString(), parameters); bool result = DbHelperMySql.ExecuteSqlTran(sqllist); if (result) { return(true); } else { return(false); } }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { Hashtable sqllist = new Hashtable(); //删除订单商品 //List<CommandInfo> sqllist = new List<CommandInfo>(); StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "order_goods where order_id=@order_id"); MySqlParameter[] parameters2 = { new MySqlParameter("@order_id", MySqlDbType.Int32, 4) }; parameters2[0].Value = id; //CommandInfo cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(strSql2.ToString(), parameters2); //删除订单主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "orders where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters[0].Value = id; //cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(strSql.ToString(), parameters); //return DbHelperMySql.ExecuteSqlTran(sqllist) > 0; bool result = DbHelperMySql.ExecuteSqlTran(sqllist); if (result) { return(true); } else { return(false); } }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { Hashtable sqllist = new Hashtable(); //删除会员组价格 StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "user_group_price "); strSql1.Append(" where group_id=@group_id "); MySqlParameter[] parameters1 = { new MySqlParameter("@group_id", MySqlDbType.Int32, 4) }; parameters1[0].Value = id; sqllist.Add(strSql1.ToString(), parameters1); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "user_groups "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters[0].Value = id; sqllist.Add(strSql.ToString(), parameters); bool result = DbHelperMySql.ExecuteSqlTran(sqllist); if (result) { return(true); } else { return(false); } }
/// <summary> /// 删除一条数据,及子表所有相关数据 /// </summary> public bool Delete(int id) { Hashtable sqllist = new Hashtable(); //删除管理角色权限 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "manager_role_value "); strSql.Append(" where role_id=@role_id"); MySqlParameter[] parameters = { new MySqlParameter("@role_id", MySqlDbType.Int32, 4) }; parameters[0].Value = id; sqllist.Add(strSql.ToString(), parameters); //删除管理角色 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "manager_role "); strSql2.Append(" where id=@id"); MySqlParameter[] parameters2 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters2[0].Value = id; sqllist.Add(strSql2.ToString(), parameters2); bool result = DbHelperMySql.ExecuteSqlTran(sqllist); if (result) { return(true); } else { return(false); } }
/// <summary> /// 删除当次出库的数据 /// </summary> /// <param name="CKZLBH"></param> /// <returns></returns> public bool deleteWLCK(string CKZLBH) { bool bResult = false; List <string> listStrSQL = new List <string>(); StringBuilder strSql = new StringBuilder(); strSql.Append(" update "); strSql.Append(" ffd070 a "); strSql.Append(" left join ffd020 b "); strSql.Append(" on a.LOTNO=if(a.TXMQF='1',b.XDLOTNO,if(a.TXMQF='2',b.DDLOTNO,b.XLOTNO)) "); strSql.Append(" set b.CKWCQF='0', "); strSql.Append(" b.CKRBH='', "); strSql.Append(" b.CKRQ='', "); strSql.Append(" b.CKZLBH=NULL "); strSql.Append(" where a.CKZLBH='" + CKZLBH + "'; "); listStrSQL.Add(strSql.ToString()); strSql = new StringBuilder(); strSql.Append(" delete from ffd070 where CKZLBH='" + CKZLBH + "'; "); listStrSQL.Add(strSql.ToString()); int iRet = DbHelperMySql.ExecuteSqlTran(listStrSQL); bResult = iRet == -1 ? false : true; return(bResult); }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { //获取用户旧数据 Model.users model = GetModel(id); if (model == null) { return(false); } Hashtable sqllist = new Hashtable(); //删除积分记录 StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "user_point_log "); strSql1.Append(" where user_id=@id"); MySqlParameter[] parameters1 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters1[0].Value = id; sqllist.Add(strSql1.ToString(), parameters1); //删除金额记录 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "user_amount_log "); strSql2.Append(" where user_id=@id"); MySqlParameter[] parameters2 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters2[0].Value = id; sqllist.Add(strSql2.ToString(), parameters2); //删除附件购买记录 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "user_attach_log"); strSql3.Append(" where user_id=@id"); MySqlParameter[] parameters3 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters3[0].Value = id; sqllist.Add(strSql3.ToString(), parameters3); //删除短消息 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_message "); strSql4.Append(" where post_user_name=@post_user_name or accept_user_name=@accept_user_name"); MySqlParameter[] parameters4 = { new MySqlParameter("@post_user_name", MySqlDbType.VarChar, 100), new MySqlParameter("@accept_user_name", MySqlDbType.VarChar, 100) }; parameters4[0].Value = model.user_name; parameters4[1].Value = model.user_name; sqllist.Add(strSql4.ToString(), parameters4); //删除申请码 StringBuilder strSql5 = new StringBuilder(); strSql5.Append("delete from " + databaseprefix + "user_code "); strSql5.Append(" where user_id=@id"); MySqlParameter[] parameters5 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters5[0].Value = id; sqllist.Add(strSql5.ToString(), parameters5); //删除登录日志 StringBuilder strSql6 = new StringBuilder(); strSql6.Append("delete from " + databaseprefix + "user_login_log "); strSql6.Append(" where user_id=@id"); MySqlParameter[] parameters6 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters6[0].Value = id; sqllist.Add(strSql6.ToString(), parameters6); //删除OAuth授权用户信息 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "user_oauth "); strSql8.Append(" where user_id=@id"); MySqlParameter[] parameters8 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters8[0].Value = id; sqllist.Add(strSql8.ToString(), parameters8); //删除用户充值表 StringBuilder strSql9 = new StringBuilder(); strSql9.Append("delete from " + databaseprefix + "user_recharge "); strSql9.Append(" where user_id=@id"); MySqlParameter[] parameters9 = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters9[0].Value = id; sqllist.Add(strSql9.ToString(), parameters9); //删除用户主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "users "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters[0].Value = id; sqllist.Add(strSql.ToString(), parameters); bool result = DbHelperMySql.ExecuteSqlTran(sqllist); if (result) { return(true); } else { return(false); } }
//保存按钮 private void btnSave_Click(object sender, EventArgs e) { if (cboGlMc.Text.strReplace().IsNullOrEmpty()) { ComForm.DspMsg("W002", "管理名称"); cboGlMc.Focus(); return; } if (txtMcKey.Text.strReplace().IsNullOrEmpty()) { ComForm.DspMsg("W002", "名称KEY"); txtMcKey.Focus(); return; } if (txtZsMc.Text.strReplace().IsNullOrEmpty()) { ComForm.DspMsg("W002", "正式名称"); txtZsMc.Focus(); return; } if (ComConst.LING == ComForm.DspMsg("Q004", "")) { try { List <string> lisSql = new List <string>(); _modelFMD000.GLBH = cboGlMc.getValue() + txtMcKey.Text.strReplace(); _modelFMD000.ZSMC = txtZsMc.Text.strReplace(); _modelFMD000.SLMC = txtSxMc.Text.strReplace(); if (_bllFMD000.Exists(_modelFMD000.GLBH)) { lisSql.Add(DBHelper.Del(TableName, "and GLBH='" + _modelFMD000.GLBH + "'")); } //插入数据 _modelFMD000.RLZBH = ComForm.strUserName; _modelFMD000.RLR = PublicFun.GetSystemDateTime(Const.Date, Const.dateStyle_YMD); _modelFMD000.RLSJ = PublicFun.GetSystemDateTime(Const.Time, string.Empty); _modelFMD000.RLDMM = systemdate.Get_SysDNBH(); lisSql.Add(DBHelper.Add(TableName, _modelFMD000)); if (DbHelperMySql.ExecuteSqlTran(lisSql) != -1) { ComForm.DspMsg("M002", ""); } else { ComForm.DspMsg("E001", ""); ComForm.InsertErrLog("数据插入失败!", this.Name); } cboGlMc.Focus(); } catch (Exception ew) { ComForm.DspMsg("E001", ""); ComForm.InsertErrLog(ew.ToString(), this.Name); return; } txtMcKey.Text = string.Empty; txtZsMc.Text = string.Empty; txtSxMc.Text = string.Empty; fillSPD(); } }
/// <summary> /// 获得绑定CboBox的出库指令数据 /// </summary> /// <returns></returns> public bool SaveWLCK(Model.ffd050 modelFFD050, List <string> listStrX, List <string> listStrDD, List <string> listStrXD) { List <string> listStrSQL = new List <string>(); StringBuilder strSQL = new StringBuilder(); strSQL.Append("delete from ffd070 "); strSQL.Append("where CKZLBH='" + modelFFD050.CKZLBH + "'; "); listStrSQL.Add(strSQL.ToString()); //修改订单时,先将原有数据清空 strSQL = new StringBuilder(); strSQL.Append("update ffd020 "); strSQL.Append("set CKRBH=NULL "); strSQL.Append(" ,CKWCQF='0' "); strSQL.Append(" ,DMQF='" + modelFFD050.DMQF + "' "); strSQL.Append(" ,CKZLBH=NULL "); strSQL.Append(" ,CKRQ=NULL "); strSQL.Append(" where CKZLBH='" + modelFFD050.CKZLBH + "' "); listStrSQL.Add(strSQL.ToString()); strSQL = new StringBuilder(); strSQL.Append("update ffd050 "); strSQL.Append("set CKRQ='" + modelFFD050.CKRQ + "' "); strSQL.Append(" ,CKDDZ='" + modelFFD050.CKDDZ + "' "); strSQL.Append(" ,CKWCS=" + modelFFD050.CKWCS + " "); strSQL.Append(" ,WCQF='" + modelFFD050.WCQF + "' "); strSQL.Append(" ,DMQF='" + modelFFD050.DMQF + "' "); strSQL.Append(" ,GXZBH='" + modelFFD050.GXZBH + "' "); strSQL.Append(" ,GXR='" + modelFFD050.GXR + "' "); strSQL.Append(" ,GXSJ='" + modelFFD050.GXSJ + "' "); strSQL.Append(" ,GXDMM='" + modelFFD050.GXDMM + "' "); strSQL.Append(" where CKZLBH='" + modelFFD050.CKZLBH + "'; "); listStrSQL.Add(strSQL.ToString()); strSQL = new StringBuilder(); string strXLotNO = spliceStrLotNO(listStrX).Trim(); string strDDLotNO = spliceStrLotNO(listStrDD).Trim(); string strXDLotNO = spliceStrLotNO(listStrXD).Trim(); if (!string.IsNullOrEmpty(strXLotNO) || !string.IsNullOrEmpty(strDDLotNO) || !string.IsNullOrEmpty(strXDLotNO)) { strSQL.Append("update ffd020 "); strSQL.Append("set CKRBH='" + modelFFD050.CKDDZ + "' "); strSQL.Append(" ,CKWCQF='1' "); strSQL.Append(" ,DMQF='" + modelFFD050.DMQF + "' "); strSQL.Append(" ,CKZLBH='" + modelFFD050.CKZLBH + "' "); strSQL.Append(" ,CKRQ='" + modelFFD050.CKRQ + "' "); strSQL.Append(" where 1<>1 "); if (!string.IsNullOrEmpty(strXLotNO)) { strSQL.Append("or XLOTNO in (" + strXLotNO + ") "); } if (!string.IsNullOrEmpty(strDDLotNO)) { strSQL.Append("or DDLOTNO in (" + strDDLotNO + ") "); } if (!string.IsNullOrEmpty(strXDLotNO)) { strSQL.Append("or XDLOTNO in (" + strXDLotNO + ") "); } listStrSQL.Add(strSQL.ToString()); } if (!string.IsNullOrEmpty(strXLotNO)) { strSQL = new StringBuilder(); strSQL.Append(" insert into ffd070 "); strSQL.Append(" select distinct "); strSQL.Append(" '" + modelFFD050.CKZLBH + "', "); strSQL.Append(" XLOTNO, "); strSQL.Append(" '" + modelFFD050.CKRQ + "', "); strSQL.Append(" substring(XLOTNO,4,1), "); strSQL.Append(" substring(XLOTNO, LOCATE(',',XLOTNO)+1), "); strSQL.Append(" '" + modelFFD050.CKDDZ + "', "); strSQL.Append(" '" + modelFFD050.GXZBH + "', "); strSQL.Append(" '" + modelFFD050.GXR + "', "); strSQL.Append(" '" + modelFFD050.GXSJ + "', "); strSQL.Append(" '" + modelFFD050.GXDMM + "', "); strSQL.Append(" NULL GXZBH, "); strSQL.Append(" NULL GXR, "); strSQL.Append(" NULL GXSJ, "); strSQL.Append(" NULL GXDMM "); strSQL.Append(" from ffd020 "); strSQL.Append("where 1=1 "); strSQL.Append("and XLOTNO in (" + strXLotNO + ") "); listStrSQL.Add(strSQL.ToString()); } if (!string.IsNullOrEmpty(strDDLotNO)) { strSQL = new StringBuilder(); strSQL.Append(" insert into ffd070 "); strSQL.Append(" select distinct "); strSQL.Append(" '" + modelFFD050.CKZLBH + "', "); strSQL.Append(" DDLOTNO, "); strSQL.Append(" '" + modelFFD050.CKRQ + "', "); strSQL.Append(" substring(DDLOTNO,4,1), "); strSQL.Append(" substring(DDLOTNO, LOCATE(',',DDLOTNO)+1), "); strSQL.Append(" '" + modelFFD050.CKDDZ + "', "); strSQL.Append(" '" + modelFFD050.GXZBH + "', "); strSQL.Append(" '" + modelFFD050.GXR + "', "); strSQL.Append(" '" + modelFFD050.GXSJ + "', "); strSQL.Append(" '" + modelFFD050.GXDMM + "', "); strSQL.Append(" NULL, "); strSQL.Append(" NULL, "); strSQL.Append(" NULL, "); strSQL.Append(" NULL "); strSQL.Append(" from ffd020 "); strSQL.Append("where 1=1 "); strSQL.Append("and DDLOTNO in (" + strDDLotNO + ") "); listStrSQL.Add(strSQL.ToString()); } if (!string.IsNullOrEmpty(strXDLotNO)) { strSQL = new StringBuilder(); strSQL.Append(" insert into ffd070 "); strSQL.Append(" select distinct "); strSQL.Append(" '" + modelFFD050.CKZLBH + "', "); strSQL.Append(" XDLOTNO, "); strSQL.Append(" '" + modelFFD050.CKRQ + "', "); strSQL.Append(" substring(XDLOTNO,4,1), "); strSQL.Append(" substring(XDLOTNO, LOCATE(',',XDLOTNO)+1), "); strSQL.Append(" '" + modelFFD050.CKDDZ + "', "); strSQL.Append(" '" + modelFFD050.GXZBH + "', "); strSQL.Append(" '" + modelFFD050.GXR + "', "); strSQL.Append(" '" + modelFFD050.GXSJ + "', "); strSQL.Append(" '" + modelFFD050.GXDMM + "', "); strSQL.Append(" NULL, "); strSQL.Append(" NULL, "); strSQL.Append(" NULL, "); strSQL.Append(" NULL "); strSQL.Append(" from ffd020 "); strSQL.Append("where 1=1 "); strSQL.Append("and XDLOTNO in (" + strXDLotNO + ") "); listStrSQL.Add(strSQL.ToString()); } int iRet = DbHelperMySql.ExecuteSqlTran(listStrSQL); return(iRet == -1 ? false : true); //return listStrSQL; }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(string channel_name, int channel_id, int article_id) { //取得相册MODEL List <Model.article_albums> albumsList = new DAL.MySql.article_albums(databaseprefix).GetList(channel_id, article_id); //取得附件MODEL List <Model.article_attach> attachList = new DAL.MySql.article_attach(databaseprefix).GetList(channel_id, article_id); //删除图片相册 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums"); strSql2.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters2 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters2[0].Value = channel_id; parameters2[1].Value = article_id; Hashtable sqllist = new Hashtable(); //List<CommandInfo> sqllist = new List<CommandInfo>(); //CommandInfo cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(strSql2.ToString(), parameters2); //删除附件 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach"); strSql3.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters3 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters3[0].Value = channel_id; parameters3[1].Value = article_id; //cmd = new CommandInfo(strSql3.ToString(), parameters3); sqllist.Add(strSql3.ToString(), parameters3); //删除用户组价格 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price"); strSql4.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters4 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters4[0].Value = channel_id; parameters4[1].Value = article_id; //cmd = new CommandInfo(strSql4.ToString(), parameters4); sqllist.Add(strSql4.ToString(), parameters4); //删除Tags标签关系 StringBuilder strSql7 = new StringBuilder(); strSql7.Append("delete from " + databaseprefix + "article_tags_relation"); strSql7.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters7 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters7[0].Value = channel_id; parameters7[1].Value = article_id; //cmd = new CommandInfo(strSql7.ToString(), parameters7); sqllist.Add(strSql7.ToString(), parameters7); //删除评论 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "article_comment"); strSql8.Append(" where channel_id=@channel_id and article_id=@article_id "); SqlParameter[] parameters8 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters8[0].Value = channel_id; parameters8[1].Value = article_id; //cmd = new CommandInfo(strSql8.ToString(), parameters8); sqllist.Add(strSql8.ToString(), parameters8); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + DTKeys.TABLE_CHANNEL_ARTICLE + channel_name); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = article_id; //cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(strSql.ToString(), parameters); bool rowsAffected = DbHelperMySql.ExecuteSqlTran(sqllist); if (rowsAffected) { new DAL.MySql.article_albums(databaseprefix).DeleteFile(albumsList); //删除图片 new DAL.MySql.article_attach(databaseprefix).DeleteFile(attachList); //删除附件 return(true); } else { return(false); } }