/// <summary> /// 删除 /// </summary> /// <param name="id"></param> public ReturnModel Delete(int id) { StringBuilder sbSql = new StringBuilder(); using (IDbConnection conn = new DapperConnection().DbConnection) { var transaction = conn.BeginTransaction(); try { sbSql.Append($"DELETE FROM WJ_TCBQ WHERE GLID={id}"); conn.Execute(sbSql.ToString(), null, transaction); sbSql.Clear(); sbSql.Append($"DELETE FROM WJ_TC WHERE ID={id}"); conn.Execute(sbSql.ToString(), null, transaction); transaction.Commit(); return(new ReturnModel { Code = 200, Msg = "删除成功" }); } catch (Exception e) { transaction.Rollback(); Log.WriteLog(e.Message); return(new ReturnModel { Code = 201, Msg = "删除失败" }); } } }
/// <summary> /// 同步组合项目 /// </summary> /// <param name="li"></param> public void InsertOrUpdate(List <XtZhxmbModel> li) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "select zhxmbh from xt_zhxmb a where yybh='" + li[0].yybh + "'"; List <XtZhxmbModel> liOld = conn.Query <XtZhxmbModel>(sql, null).ToList(); string sqlcz = ""; IDbTransaction transaction = conn.BeginTransaction(); foreach (XtZhxmbModel model in li) { string zhxmms = string.IsNullOrEmpty(model.zhxmms) ? "" : model.zhxmms; int i = liOld.Where(p => p.zhxmbh == model.zhxmbh.Trim()).Count(); if (i > 0) { sqlcz = "update xt_zhxmb set zhxmmc=@zhxmmc,zhxmms=@zhxmms,zhxmjg=@zhxmjg,xb=@xb,sffk=@sffk,sfqy=@sfqy,zhxmksbh=@zhxmksbh,zhxmksmc=@zhxmksmc, sxrs=@sxrs,updatetime=getdate() where yybh=@yybh and zhxmbh=@zhxmbh and zhxmbh=@zhxmbh;"; conn.Execute(sqlcz, model, transaction); } else { sqlcz = "insert into xt_zhxmb(yybh,zhxmbh,zhxmmc,zhxmms,zhxmjg,xb,sffk,sfqy,zhxmksbh,zhxmksmc,createtime,updatetime,sxrs) values(@yybh, @zhxmbh, @zhxmmc,@zhxmms,@zhxmjg,@xb,@sffk,@sfqy,@zhxmksbh,@zhxmksmc,getdate(),getdate(),@sxrs);"; conn.Execute(sqlcz, model, transaction); } } transaction.Commit(); } }
public void CreateOrder(List <OrderModel> li) { using (IDbConnection conn = new DapperConnection().DbConnection) { IDbTransaction transaction = conn.BeginTransaction(); foreach (OrderModel model in li) { string ddbh = new DdJbxxService().GetDdbh(); int sfjx = 0; string sql = @"insert into dd_jbxx(ddbh,dsfdd,dsfbzid,ddzt,tcid,tcmc,dwbh,tcjg, jxbjg,ddze,intime,sfout,outtime,dh,xm,xb,hz, zjlx,zjhm,yykssj,yyjssj,sfdj,djtime,sfbg,bgtime, djlsh,sfjx,jxlist,sfjs,csrq,nl,remark,yybh,ddly,dwmc,jsbz,ygzh,trade_no,ysjsj) values(@ddbh,@dsfdd,@dsfbzid,2,@tcid,@tcmc,@dwbh,@tcjg, 0,@ddze,getdate(),0,'1970-01-01',@dh,@xm,@xb,@hz, @zjlx,@zjhm,@yysj,@yysj,0,'1970-01-01',0,'1970-01-01', '',@sfjx,@jxlist,0,@csrq,@nl,'',@yybh,0,@dwmc,0,'',@trade_no,@ysjsj) "; int id = conn.Execute(sql, new { ddbh = ddbh, dsfdd = model.outOrderCode, dsfbzid = model.dsfbzId, tcid = model.appointmentPackageCode, tcmc = model.appointmentPackageName, dwbh = model.deptID, tcjg = model.ddJe, ddze = model.ddJe, dh = model.customerMobilePhone, xm = model.customerName, xb = model.customerGender, hz = model.customerMedicalStatus, zjlx = model.customerIDType, zjhm = model.customerIDCard, yysj = model.appointmentDate, sfjx = sfjx, jxlist = "", csrq = model.customerBirthday, nl = model.customerAge, yybh = model.yybh, dwmc = model.deptNm, trade_no = "", ysjsj = model.ysjsj }, transaction); string sqlDetail = "insert into dd_zhxm(ddbh,zhxmbh,zhxmmc,jg,sfjx,sfdj) select '" + ddbh + "',b.zhxmbh,b.zhxmmc,b.zhxmjg,0,0 from xt_tc_zhxmb a join xt_zhxmb b on a.yybh=b.yybh and a.zhxmbh=b.zhxmbh where a.yybh='" + model.yybh + "' and a.tcbh='" + model.appointmentPackageCode + "' and a.dwbh='" + model.deptID + "'"; conn.Execute(sqlDetail, null, transaction); } transaction.Commit(); } }
/// <summary> /// 创建中间平台订单 /// </summary> /// <param name="model"></param> /// <param name="tcmc"></param> /// <param name="nl"></param> /// <returns></returns> public int CreateOrder(PreOrder model, string tcmc, string ddbh, string dwmc, decimal ysjsj = 0) { int sfjx = 0; string jxlist = ""; string jxlist2 = ""; if (model.items != null && model.items.Count > 0) { sfjx = 1; foreach (var item in model.items) { if (item.isAdd == 1) { jxlist += item.itemCode + ","; jxlist2 += "'" + item.itemCode + "',"; } } } jxlist = jxlist.TrimEnd(','); jxlist2 = jxlist2.TrimEnd(','); string sql = @"insert into dd_jbxx(ddbh,dsfdd,dsfbzid,ddzt,tcid,tcmc,dwbh,tcjg,jxbjg,ddze,intime,sfout,outtime,dh,xm,xb,hz,zjlx,zjhm,yykssj,yyjssj,sfdj,djtime,sfbg,bgtime,djlsh,sfjx,jxlist,sfjs,csrq,nl,remark,yybh,ddly,dwmc,jsbz,ygzh,trade_no,ysjsj) values(@ddbh,@dsfdd,@dsfbzid,2,@tcid,@tcmc,@dwbh,@tcjg, 0,@ddze,getdate(),0,'1970-01-01',@dh,@xm,@xb,@hz, @zjlx,@zjhm,@yysj,@yysj,0,'1970-01-01',0,'1970-01-01', '',@sfjx,@jxlist,0,@csrq,@nl,'',@yybh,0,@dwmc,0,'',@trade_no,@ysjsj) "; using (IDbConnection conn = new DapperConnection().DbConnection) { IDbTransaction transaction = conn.BeginTransaction(); int id = conn.Execute(sql, new { ddbh = ddbh, dsfdd = model.outOrderCode, dsfbzid = model.interfaceNum, tcid = model.appointmentPackageCode, tcmc = tcmc, dwbh = model.deptID, tcjg = model.ddJe, ddze = model.ddJe, dh = model.customerMobilePhone, xm = model.customerName, xb = model.customerGender, hz = model.customerMedicalStatus, zjlx = model.customerIDType, zjhm = model.customerIDCard, yysj = model.appointmentDate, sfjx = sfjx, jxlist = jxlist, csrq = model.customerBirthday, nl = model.customerAge, yybh = model.yybh, dwmc = dwmc, trade_no = string.IsNullOrEmpty(model.tradeNo)?"":model.tradeNo, ysjsj = ysjsj }, transaction); string sqlDetail = "insert into dd_zhxm(ddbh,zhxmbh,zhxmmc,jg,sfjx,sfdj) select '" + ddbh + "',b.zhxmbh,b.zhxmmc,b.zhxmjg,0,0 from xt_tc_zhxmb a join xt_zhxmb b on a.yybh=b.yybh and a.zhxmbh=b.zhxmbh where a.yybh='" + model.yybh + "' and a.tcbh='" + model.appointmentPackageCode + "' and a.dwbh='" + model.deptID + "'"; if (jxlist2.Length > 1) { string sqlDetailJx = "insert into dd_zhxm(ddbh,zhxmbh,zhxmmc,jg,sfjx,sfdj) select '" + ddbh + "',b.zhxmbh,b.zhxmmc,b.zhxmjg,1,0 from xt_zhxmb b where b.yybh='" + model.yybh + "' and b.zhxmbh in (" + jxlist2 + ")"; conn.Execute(sqlDetailJx, null, transaction); } conn.Execute(sqlDetail, null, transaction); transaction.Commit(); return(id); } }
/// <summary> /// 保存加项包 /// </summary> /// <param name="model"></param> /// <returns></returns> public int SaveJxb(QyJxbJbxxModel model) { int i = 0; using (IDbConnection conn = new DapperConnection().DbConnection) { List <QyJxbTcModel> litc = new List <QyJxbTcModel>(); foreach (string a in model.tcbhs.Split(',')) { XttcbModel item = new XttcbService().GetTc(model.yybh, a); litc.Add(new QyJxbTcModel() { yybh = model.yybh, tcbh = item.tcbh, tcmc = item.tcmc }); } List <QyJxbZhxmModel> lizhxm = new List <QyJxbZhxmModel>(); foreach (string a in model.zhxmbhs.Split(',')) { XtZhxmbModel item = new XtzhxmService().GetZhxm(model.yybh, a); lizhxm.Add(new QyJxbZhxmModel() { yybh = model.yybh, jg = item.zhxmjg, zhxmbh = item.zhxmbh, zhxmmc = item.zhxmmc }); } IDbTransaction transaction = conn.BeginTransaction(); if (model.id == 0) { string sql = "insert into qy_jxbjbxx(yybh,qybh,qymc,jxbmc,lrjs,syrq,sfqy,jg,xb,jsj,createtime,updatetime) values(@yybh,@qybh,@qymc,@jxbmc,@lrjs,@syrq,@sfqy,@jg,@xb,@jsj,getdate(),getdate());SELECT SCOPE_IDENTITY()"; string id = conn.ExecuteScalar(sql, model, transaction).ToString(); model.id = int.Parse(id); } else { string sql = "delete from qy_jxbzhxm where jxbid=@id;delete from qy_jxbtc where jxbid=@id; update qy_jxbjbxx set jxbmc=@jxbmc,lrjs=@lrjs,syrq=@syrq,sfqy=@sfqy,jg=@jg,xb=@xb,jsj=@jsj,updatetime=getdate() where id=@id"; conn.Execute(sql, model, transaction).ToString(); } string sqlZhxm = "insert into qy_jxbzhxm(jxbid,yybh,zhxmbh,zhxmmc,jg)values(" + model.id + ",@yybh,@zhxmbh,@zhxmmc,@jg)"; conn.Execute(sqlZhxm, lizhxm, transaction); string sqlTc = "insert into qy_jxbtc(jxbid,yybh,tcbh,tcmc)values(" + model.id + ",@yybh,@tcbh,@tcmc)"; conn.Execute(sqlTc, litc, transaction); transaction.Commit(); i = 1; } return(model.id); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> public ReturnModel Delete(int id) { using (IDbConnection conn = new DapperConnection().DbConnection) { var transaction = conn.BeginTransaction(); try { StringBuilder sbSql = new StringBuilder(); sbSql.Append("DELETE FROM WJ_WJTM WHERE ID=@ID;"); sbSql.Append("DELETE FROM WJ_TMXXBQ WHERE XXID IN (SELECT ID FROM WJ_TMXX WHERE TMID=@ID);"); sbSql.Append("DELETE FROM WJ_TMXX WHERE TMID=@ID;"); conn.Execute(sbSql.ToString(), new { ID = id }, transaction); transaction.Commit(); return(new ReturnModel { Code = 200, Msg = "删除成功" }); } catch (Exception ex) { transaction.Rollback(); Log.WriteLog(ex.Message); return(new ReturnModel { Code = 201, Msg = "删除失败" }); } } }
/// <summary> /// 更改状态 /// </summary> /// <param name="id"></param> public ReturnModel ResetPassword(int id, string mm) { try { string sql = $"UPDATE xt_zhb SET mm=@mm WHERE Id=@Id"; using (IDbConnection conn = new DapperConnection().DbConnection) { int rows = conn.Execute(sql, new { Id = id, mm = mm }); if (rows > 0) { return(new ReturnModel { Code = 200, Msg = "操作成功" }); } else { return(new ReturnModel { Code = 201, Msg = "操作失败" }); } } } catch (Exception ex) { Log.WriteLog(ex.Message); return(new ReturnModel { Code = 201, Msg = "操作失败" }); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(DdTksqjlbModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dd_tksqjlb set "); strSql.Append("ddbh=@ddbh,"); strSql.Append("jylsbh=@jylsbh,"); strSql.Append("tkje=@tkje,"); strSql.Append("sqtksj=@sqtksj,"); strSql.Append("tksj=@tksj,"); strSql.Append("zffs=@zffs,"); strSql.Append("tklsh=@tklsh,"); strSql.Append("trade_no=@trade_no,"); strSql.Append("refund_no=@refund_no,"); strSql.Append("tkyy=@tkyy,"); strSql.Append("tkzt=@tkzt,"); strSql.Append("yybh=@yybh,"); strSql.Append("dwbh=@dwbh,"); strSql.Append("ddje=@ddje"); strSql.Append(" where id=@id"); using (IDbConnection conn = new DapperConnection().DbConnection) { conn.Execute(strSql.ToString(), model); } }
/// <summary> /// 批量删除 /// </summary> /// <param name="ids"></param> public ReturnModel DelList(string ids) { try { var list = ids.Split(','); string sql = "DELETE FROM xt_jsglb WHERE Id IN @ids"; using (IDbConnection conn = new DapperConnection().DbConnection) { int rows = conn.Execute(sql, new { ids = list }); if (rows > 0) { return(new ReturnModel { Code = 200, Msg = "删除成功" }); } else { return(new ReturnModel { Code = 201, Msg = "删除失败" }); } } } catch (Exception ex) { Log.WriteLog(ex.Message); return(new ReturnModel { Code = 201, Msg = "删除失败" }); } }
public void Test(string sql) { using (IDbConnection conn = new DapperConnection().DbConnection) { conn.Execute(sql, null); } }
public ReturnModel BatchComplete(string ddbhs, int ddzt) { using (IDbConnection conn = new DapperConnection().DbConnection) { var transaction = conn.BeginTransaction(); try { List <string> listDdbh = ddbhs.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); var sbSql = new StringBuilder(); sbSql.Append("update dd_jbxx_new set ddzt=@Ddzt where ddbh in @Ddbh;"); if (ddzt.Equals(7)) { sbSql.Append("update dd_zhxm set sfdj=1 where ddbh in @Ddbh;"); } conn.Execute(sbSql.ToString(), new { Ddzt = ddzt, Ddbh = listDdbh }, transaction); transaction.Commit(); return(new ReturnModel { Code = 200, Msg = "保存成功" }); } catch (Exception ex) { transaction.Rollback(); Log.WriteLog("批量完成失败" + ex.Message); return(new ReturnModel { Code = 201, Msg = "保存失败" }); } } }
/// <summary> /// 单独删除 /// </summary> /// <param name="id"></param> public ReturnModel Del(int id) { try { string sql = "DELETE FROM xt_jsglb WHERE Id=@Id"; using (IDbConnection conn = new DapperConnection().DbConnection) { int rows = conn.Execute(sql, new { Id = id }); if (rows > 0) { return(new ReturnModel { Code = 200, Msg = "删除成功" }); } else { return(new ReturnModel { Code = 201, Msg = "删除失败" }); } } } catch (Exception ex) { Log.WriteLog(ex.Message); return(new ReturnModel { Code = 201, Msg = "删除失败" }); } }
/// <summary> /// 更改状态 /// </summary> /// <param name="id"></param> public ReturnModel UpdateStatus(int id, int zt) { try { string sql = $"UPDATE xt_zhb SET zt={zt} WHERE Id=@Id"; using (IDbConnection conn = new DapperConnection().DbConnection) { int rows = conn.Execute(sql, new { Id = id }); if (rows > 0) { string result = zt == 1 ? "已启用" : "已停用"; return(new ReturnModel { Code = 200, Msg = result }); } else { return(new ReturnModel { Code = 201, Msg = "操作失败" }); } } } catch (Exception ex) { Log.WriteLog(ex.Message); return(new ReturnModel { Code = 201, Msg = "操作失败" }); } }
/// <summary> /// 取消订单 /// </summary> /// <param name="id"></param> public void Delete(string ddbh) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update dd_jbxx_new set ddzt=8,remark='客户主动取消订单' where ddbh=@ddbh"; conn.Execute(sql, new { ddbh = ddbh }); } }
/// <summary> /// 修改备注 /// </summary> /// <param name="id"></param> /// <param name="remark"></param> public void UpdatOrderremark(string ddbh, string remark) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update dd_jbxx_new set remark=@remark where ddbh=@ddbh"; conn.Execute(sql, new { remark = remark, ddbh = ddbh }); } }
public void UpdatOrderdaojiantest(string ddbh, string djtime) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update dd_jbxx set ddzt=6,sfdj=1,djtime=@djtime where ddbh=@ddbh;update dd_zhxm set sfdj=1 where ddbh=@ddbh"; conn.Execute(sql, new { djtime = djtime, ddbh = ddbh }); } }
/// <summary> /// 更新联系人 /// </summary> /// <param name="lxr"></param> /// <param name="lxdh"></param> /// <param name="id"></param> /// <returns></returns> public int UpdateYyQudao(string lxr, string lxdh, int id) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sqlcz = "update qy_jbxx set lxdh=@lxdh,dwfzr=@lxr where id=@id"; return(conn.Execute(sqlcz, new { lxdh = lxdh, lxr = lxr, id = id })); } }
/// <summary> /// 更新结算价 /// </summary> /// <param name="id"></param> /// <param name="jsj"></param> /// <returns></returns> public int UpdateTcJgJsj(int id, decimal jsj, decimal jg, int sfxsjg) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update xt_tcb set jsj=@jsj,jg=@jg,sfxsjg=@sfxsjg where id=@id"; return(conn.Execute(sql, new { jsj = jsj, id = id, jg = jg, sfxsjg = sfxsjg })); } }
public void ConfirmOrder(DdjbxxModel ddModel, List <DdZhxmModel> zhxmList, QyygxxModel ygModel) { StringBuilder strSql = new StringBuilder(); using (IDbConnection conn = new DapperConnection().DbConnection) { IDbTransaction transaction = conn.BeginTransaction(); try { if (ddModel.jsbz == 0)//自已才更新 { strSql.AppendFormat("UPDATE dbo.qy_ygxx SET sfyy=@sfyy WHERE id=@id"); conn.Execute(strSql.ToString(), new { sfyy = ygModel.sfyy, id = ygModel.id }, transaction); } strSql.Clear(); if (string.IsNullOrEmpty(ddModel.csrq)) { ddModel.csrq = DateTime.Now.ToString("yyyy-MM-dd"); } strSql.Append("insert into dd_jbxx_new("); strSql.Append("trade_no,zffs,ddbh,dsfdd,dsfbzid,ddzt,tcid,tcmc,dwbh,tcjg,jxbjg,ddze,intime,sfout,outtime,dh,xm,xb,hz,zjlx,zjhm,yykssj,yyjssj,sfdj,djtime,sfbg,bgtime,djlsh,sfjx,jxlist,sfjs,csrq,nl,remark,yybh,ddly,dwmc,jsbz,ygzh)"); strSql.Append(" values ("); strSql.Append("'',@zffs,@ddbh,@dsfdd,@dsfbzid,@ddzt,@tcid,@tcmc,@dwbh,@tcjg,@jxbjg,@ddze,@intime,@sfout,@outtime,@dh,@xm,@xb,@hz,@zjlx,@zjhm,@yykssj,@yyjssj,@sfdj,@djtime,@sfbg,@bgtime,@djlsh,@sfjx,@jxlist,@sfjs,@csrq,@nl,@remark,@yybh,@ddly,@dwmc,@jsbz,@ygzh)"); conn.Execute(strSql.ToString(), ddModel, transaction); strSql.Clear(); strSql.Append("insert into dd_zhxm("); strSql.Append("ddbh,zhxmbh,zhxmmc,jg,sfjx,sfdj)"); strSql.Append(" values ("); strSql.Append("@ddbh,@zhxmbh,@zhxmmc,@jg,@sfjx,@sfdj)"); conn.Execute(strSql.ToString(), zhxmList, transaction); transaction.Commit(); } catch (Exception ex) { LogApiHelper.AddLog(ex.Message); transaction.Rollback(); throw; } } }
/// <summary> /// 渠道开关 /// </summary> /// <param name="yybh"></param> /// <param name="bh"></param> /// <param name="sfqy"></param> /// <returns></returns> public int UpdateSfqd(string yybh, string bh, int sfqd) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sqlcz = "update qy_jbxx set sfqd=@sfqd,updatetime=getdate() where yybh=@yybh and bh=@bh"; return(conn.Execute(sqlcz, new { yybh = yybh, bh = bh, sfqd = sfqd })); } }
/// <summary> /// 企业开关 /// </summary> /// <param name="yybh"></param> /// <param name="bh"></param> /// <param name="sfqy"></param> /// <returns></returns> public int UpdateSfqy(int id, int sfqy) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sqlcz = "update qy_jbxx set sfqy=@sfqy,updatetime=getdate() where id=@id"; return(conn.Execute(sqlcz, new { id = id, sfqy = sfqy })); } }
public int UpdateQy(string lxr, string lxdh, int id, int sfxstcje, string zh, string mm) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sqlcz = "update qy_jbxx set lxdh=@lxdh,dwfzr=@lxr,sfxstcje=@sfxstcje,zh=@zh,mm=@mm where id=@id"; return(conn.Execute(sqlcz, new { lxdh = lxdh, lxr = lxr, id = id, sfxstcje = sfxstcje, zh = zh, mm = mm })); } }
/// <summary> /// 密码修改 /// </summary> /// <param name="id"></param> /// <param name="pwd"></param> /// <returns></returns> public int UpdatePassword(int id, string pwd) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update xt_zhb set Mm=@mm where id=@id"; return(conn.Execute(sql, new { id = id, mm = pwd })); } }
/// <summary> /// 修改单据到达医院状态 /// </summary> /// <param name="id"></param> /// <param name="djlsh"></param> public void UpdatOrderdjlsh(string ddbh, string djlsh) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update dd_jbxx_new set ddzt=3,sfout=1,outtime=getdate(),djlsh=@djlsh where ddbh=@ddbh"; conn.Execute(sql, new { djlsh = djlsh, ddbh = ddbh }); } }
/// <summary> /// 更新机构 /// </summary> /// <param name="model"></param> public int UpdateJg(XtJgbModel model) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sql = "update xt_jgb set jgmc=@jgmc,jgdz=@jgdz,csbh=@csbh,dj=@dj,bw=@bw,lxr=@lxr,lxdh=@lxdh,zyfs=@zyfs,jgxz=@jgxz,yydj=@yydj,sfqy=@sfqy,yyimage=@yyimage,yylogoimage=@yylogoimage,yyjs=@yyjs where id=@id"; return(conn.Execute(sql, model)); } }
/// <summary> /// 更新状态 /// </summary> /// <param name="sfqy"></param> /// <param name="id"></param> /// <returns></returns> public int UpdateYyQudaoStatus(int sfqy, int id) { using (IDbConnection conn = new DapperConnection().DbConnection) { string sqlcz = "update qy_jbxx set sfqy=@sfqy where id=@id"; return(conn.Execute(sqlcz, new { sfqy = sfqy, id = id })); } }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> public ReturnModel Delete(int id) { StringBuilder sbSql = new StringBuilder(); using (IDbConnection conn = new DapperConnection().DbConnection) { var transaction = conn.BeginTransaction(); try { sbSql.Append($"SELECT * FROM WJ_JG WHERE ID={id}"); Wjjg model = conn.QueryFirstOrDefault <Wjjg>(sbSql.ToString(), null, transaction); if (model == null) { return new ReturnModel { Code = 201, Msg = "医院不存在" } } ; sbSql.Clear(); sbSql.Append($"DELETE FROM WJ_TCBQ WHERE GLID IN (SELECT id FROM WJ_TC WHERE TCID IN (SELECT TCID FROM TC_TJ WHERE YYBH='{model.YYBH}'))"); conn.Execute(sbSql.ToString(), null, transaction); sbSql.Clear(); sbSql.Append($"DELETE FROM WJ_TC WHERE TCID IN (SELECT tcid FROM TC_TJ WHERE yybh='{model.YYBH}')"); conn.Execute(sbSql.ToString(), null, transaction); sbSql.Append($"DELETE FROM WJ_JG WHERE ID={id}"); conn.Execute(sbSql.ToString(), null, transaction); transaction.Commit(); return(new ReturnModel { Code = 200, Msg = "删除成功" }); } catch (Exception e) { transaction.Rollback(); Log.WriteLog(e.Message); return(new ReturnModel { Code = 201, Msg = "删除失败" }); } } }
/// <summary> /// 团检取消预约 /// </summary> /// <param name="yybh"></param> /// <param name="ydjh"></param> /// <returns></returns> public int DeleteTjOrder(string yybh, string ydjh) { string sql = "update qy_ygxx set sfyy=0 where yybh=@yybh and ydjh=@ydjh; delete from dd_zhxm where ddbh in (select ddbh from dd_jbxx_new where yybh =@yybh and dsfdd=@ydjh and ddly=1); delete from dd_jbxx_new where yybh =@yybh and dsfdd=@ydjh and ddly=1;"; using (IDbConnection conn = new DapperConnection().DbConnection) { return(conn.Execute(sql, new { yybh = yybh, ydjh = ydjh })); } }
public void Del(int id) { string sql = "DELETE FROM dbo.tj_fzry WHERE id=@id"; using (IDbConnection conn = new DapperConnection().DbConnection) { conn.Execute(sql, new { id = id }); } }
/// <summary> /// 更新上限人数 /// </summary> /// <param name="zhxmbh"></param> /// <param name="sxrs"></param> public void UpdateSxrs(string zhxmbh, int sxrs) { string sql = "UPDATE dbo.xt_zhxmb SET sxrs=@sxrs WHERE zhxmbh=@zhxmbh"; using (IDbConnection conn = new DapperConnection().DbConnection) { conn.Execute(sql, new { zhxmbh = zhxmbh, sxrs = sxrs }); } }