//通过房间类型的ID获取主单ID public static int GetMainRecordIDByFjrbID(string id) { int result = 0; string lsbh = ""; BLL.Qskyd_fjrb B_Qskyd_fjrb = new Hotel_app.BLL.Qskyd_fjrb(); BLL.Qskyd_mainrecord B_Qskyd_mainrecord = new Hotel_app.BLL.Qskyd_mainrecord(); if (B_Qskyd_fjrb.GetModel(int.Parse(id)) != null) { lsbh = B_Qskyd_fjrb.GetModel(int.Parse(id)).lsbh; } if (B_Qskyd_mainrecord.GetModelList("lsbh='" + lsbh + "'").Count > 0) { result = B_Qskyd_mainrecord.GetModelList("lsbh='" + lsbh + "'")[0].id; } return(result); }
/// <summary> /// 结帐时的批量帐务处理 /// /// </summary> /// 先写入Sjzzd,同时写sjzmx,Ffkfssz /// 写入成功后,将zwmx里面的对应的记录写入到zwmx_bak,并删除当前lsbh对应下的zwmx记录 public static string Pladd(string lsbh, string jzbh, string xydw, string krly, string czsj, string syzd, string czy, string czy_bc, string jzzt, string cznr, string bz, string fkje, string xfje, string xxzs) { //修改房态时用到的变量 string id = "";//主单的ID // Ffjzt.Ffjzt_add_edit Ffjzt_add_edit_new = new Hotel_app.Ffjzt.Ffjzt_add_edit(); //用于修改房态 BLL.Ffjzt B_Ffjzt = new Hotel_app.BLL.Ffjzt(); //修改房态 Hotel_app.BLL.Qskyd_fjrb B_Qskyd_fjrb = new Hotel_app.BLL.Qskyd_fjrb(); Hotel_app.Model.Qskyd_mainrecord M_Qskyd_mainrecord; Hotel_app.BLL.Qskyd_mainrecord B_Qskyd_mainrecord = new Hotel_app.BLL.Qskyd_mainrecord(); Hotel_app.Server.Qyddj.Qyddj_add_edit_delete Qyddj_add_edit_delete_new = new Hotel_app.Server.Qyddj.Qyddj_add_edit_delete();//房态及删除主单操作 string s = common_app.get_failure; StringBuilder strSql = new StringBuilder();//注意jzzd只写入一次(公共信息查一次就好) strSql.Append("insert into Sjzzd(yydh,qymc,lsbh,jzbh,krxm,sktt,fjbh,xydw,krly,tfsj,czsj,czy,czzt,jzzt,syzd,bz,fkje,xfje)"); strSql.Append(" select top 1 yydh,qymc,'" + lsbh + "',jzbh,krxm,sktt,fjbh,'" + xydw + "','" + krly + "','" + DateTime.Now + "','" + czsj + "','" + czy + "','" + common_file.common_jzzt.czzt_sz + "','" + common_file.common_jzzt.czzt_sz + "','" + syzd + "','" + bz + "','" + fkje + "','" + xfje + "' from Szw_temp"); strSql.Append(" where lsbh='" + lsbh + "' and czy_temp='" + czy + "'"); BLL.Common B_common = new Hotel_app.BLL.Common(); if (B_common.ExecuteSql(strSql.ToString()) > 0)//写入主单成功后,写入jzmx { strSql = new StringBuilder(); strSql.Append("insert into Sjzmx(yydh,qymc,id_app,jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,jjje,xfje,yh,sjxfje,xfsl,shsc,czy_bc,czzt,czsj,syzd,jzzt,fkfs ) "); strSql.Append(" select yydh,qymc,id_app,jzbh,'" + lsbh + "',krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,jjje,xfje,yh,sjxfje,xfsl,shsc,'" + czy_bc + "','" + jzzt + "','" + czsj + "','" + syzd + "','" + jzzt + "',fkfs from Szw_temp"); strSql.Append(" where lsbh='" + lsbh + "' and czy_temp='" + czy + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0)//写入jzmx成功后, { //提取fkdr为付款的项目写入Ffkfssz strSql = new StringBuilder(); strSql.Append("insert into Sfkfssz(yydh,qymc,jzbh,jzzt,lsbh,fjbh,krxm,fkfs,xfdr,xfrb,xfxm,xfje,sjxfje,fkrq,fksj,xfrq,xfsj,czy,czy_bc,syzd)"); strSql.Append(" select yydh,qymc,jzhb,'" + jzzt + "',lsbh,fjbh,krxm,fkfs,xfdr,xfxm,xfje,sjxfje,fkrq,fksj,xfrq,xfsj,czy,czy_bc,syzd from Szw_temp"); strSql.Append(" where lsbh='" + lsbh + "' and czy_temp='" + czy + "' and xfdr='" + common_app.fkdr + "'"); //删除zwmx里面此lsbh对应的帐务(同时通过zwmx上面的触发器来写入到zwmx_bak里面) strSql = new StringBuilder(); strSql.Append("update Szwmx set jzbh='" + jzbh + "' where id>0 " + common_file.common_app.yydh_select + " and lsbh='" + lsbh + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0)//更新成功 { strSql = new StringBuilder(); strSql.Append("delete from Szwmx where id>0 " + common_file.common_app.yydh_select + " and lsbh='" + lsbh + "'"); //删除的时候根据删除的触发器写入到对应的bak表中 if (B_common.ExecuteSql(strSql.ToString()) > 0) { //先更新押金操作表里面的jzbh,再删除yjcz表里面对应的记录,并写入其bak,写入Ffkfssz strSql = new StringBuilder(); strSql.Append("update Syjcz set jzbh='" + jzbh + "' where id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0) //押金更新成功 { if (jzzt == common_file.common_jzzt.czzt_sz) //算帐 { strSql = new StringBuilder(); strSql.Append("delete from Syjcz where id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0) { //清除Szw_temp strSql = new StringBuilder(); strSql.Append("delete from Szw_temp where id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0) //清除Szw_temp里面的数据了 { //调用修改房态的方法(第五步) M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'")[0]; id = M_Qskyd_mainrecord.id.ToString(); //删除主单并记录(这里有包含主单记录删除时的备份) if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", common_file.common_jzzt.czzt_sz, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) { s = common_app.get_suc; } } } } else if (jzzt == common_file.common_jzzt.czzt_gz || jzzt == common_file.common_jzzt.czzt_jz)//挂帐或者记帐 { strSql = new StringBuilder(); strSql.Append("delete from Szw_temp where id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'"); if (B_common.ExecuteSql(strSql.ToString()) > 0) //清除Szw_temp里面的数据了 { //调用修改房态的方法(第五步) M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'")[0]; id = M_Qskyd_mainrecord.id.ToString(); //删除主单并记录(这里有包含主单记录删除时的备份) if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", jzzt, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) { s = common_app.get_suc; } } } } } } } } return(s); }
//平帐时用到的方法 public string Sjzmx_pz(string id, string yydh, string qymc, string id_app, string jzbh, string lsbh, string krxm, string fjrb, string fjbh, string sktt, string xfrq, string xfsj, string czy, string xfdr, string xfrb, string xfxm, string xfbz, string xfzy, string xfje, string yh, string sjxfje, string xfsl, string czy_bc, string czzt, string czsj, string syzd, string add_edit_delete, string xxzs, string fkfs) { string s = common_file.common_app.get_failure; string xyh_temp = ""; string jzzt = ""; BLL.Sjzmx B_Sjzmx = new Hotel_app.BLL.Sjzmx(); Model.Sjzmx M_Sjzmx = new Hotel_app.Model.Sjzmx(); if (xxzs == common_file.common_app.xxzs_xxvalue) { } if (xxzs == common_file.common_app.xxzs_zsvalue) { } if (add_edit_delete == common_file.common_app.get_add) { //id,yydh,qymc,id_app,jzbh,,lsbh,krxm,fjrb,fjbh,sktt, //xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy //xfje,yh,sjxfje,xfsl,czy_bc,czzt,czsj,syzd,fkfs,add,xxzs,fkfs M_Sjzmx.yydh = yydh; M_Sjzmx.qymc = qymc; M_Sjzmx.id_app = id_app; M_Sjzmx.jzbh = jzbh; M_Sjzmx.lsbh = lsbh; M_Sjzmx.krxm = krxm; M_Sjzmx.fjrb = fjrb; M_Sjzmx.fjbh = fjbh; M_Sjzmx.sktt = sktt; M_Sjzmx.xfrq = Convert.ToDateTime(xfrq); M_Sjzmx.xfsj = Convert.ToDateTime(xfsj); M_Sjzmx.czy = czy; M_Sjzmx.xfdr = xfdr; M_Sjzmx.xfrb = xfrb; M_Sjzmx.xfxm = xfxm; M_Sjzmx.xfbz = xfbz; M_Sjzmx.xfzy = xfzy; M_Sjzmx.xfje = Convert.ToDecimal(xfje); M_Sjzmx.yh = yh; M_Sjzmx.sjxfje = Convert.ToDecimal(sjxfje); M_Sjzmx.xfsl = Convert.ToDecimal(xfsl); M_Sjzmx.czy_bc = czy_bc; M_Sjzmx.czzt = czzt; M_Sjzmx.czsj = Convert.ToDateTime(czsj); M_Sjzmx.syzd = syzd; M_Sjzmx.fkfs = fkfs; if (czzt == common_jzzt.czzt_sz)//结帐(结帐是直接从主单里面读) { if (sktt == "sk") { M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 and yydh='" + yydh + "' and lsbh='" + lsbh + "'")[0]; xyh_temp = M_Qskyd_mainrecord.xyh;//直接读出协议号 jzzt = M_Qskyd_mainrecord.krxm; } if (sktt == "tt") { { M_Qttyd_mainrecord = B_Qttyd_mainrecord.GetModelList("id>0 and yydh='" + yydh + "' and lsbh='" + lsbh + "'")[0]; xyh_temp = M_Qttyd_mainrecord.xyh;//直接读出协议号 jzzt = M_Qttyd_mainrecord.krxm; } } } else if (czzt == common_jzzt.czzt_gz || czzt == common_jzzt.czzt_jz) { object obj = DbHelperSQL.GetSingle("SELECT xyh from Sjzzd where id>0 and yydh='" + yydh + "' and jzbh='" + jzbh + "'"); if (obj != null) { xyh_temp = obj.ToString(); } else { xyh_temp = ""; } obj = DbHelperSQL.GetSingle("SELECT jzzt from Sjzzd where id>0 and yydh='" + yydh + "' and jzbh='" + jzbh + "'"); if (obj != null) { jzzt = obj.ToString(); } else { jzzt = ""; } } M_Sjzmx.xyh = xyh_temp; M_Sjzmx.jzzt = jzzt; if (B_Sjzmx.Add(M_Sjzmx) > 0) { if (czzt == common_jzzt.czzt_gz || czzt == common_jzzt.czzt_jz)//写入付款方式设置 { strSql = new StringBuilder(); strSql.Append("insert into Sfkfssz(yydh,qymc,jzbh,jzzt,lsbh,fjbh,krxm,fkfs,xfdr,xfrb,xfxm,xfje,sjxfje,fkrq,fksj,xfrq,xfsj,czy,czy_bc,syzd,id_app)"); strSql.Append(" select yydh,qymc,jzbh,'" + jzzt + "',lsbh,fjbh,krxm,fkfs,xfdr,xfrb,xfxm,-xfje,-sjxfje,xfrq,xfsj,xfrq,xfsj,czy,'" + czy_bc + "','" + syzd + "',id_app from sjzmx"); strSql.Append(" where yydh='" + yydh + "' and id_app='" + id_app + "'"); B_common.ExecuteSql(strSql.ToString()); } s = common_file.common_app.get_suc; } } if (add_edit_delete == common_file.common_app.get_delete) { if (id != "") { B_Sjzmx.Delete(Convert.ToInt32(id)); s = common_file.common_app.get_suc; } } return(s); }
//结帐,记帐,挂帐处理过程 public string GetJzResult(string lsbh, string jzbh, string yydh, string jzzt, string syzd, string czy_bc, string czzt, string sk_tt, string czy, string czsj, string hhykh_bz, string phoneNo, string czy_GUID) { string s = common_app.get_failure; //记帐,挂帐,结帐的处理节 if (czzt == common_file.common_jzzt.czzt_sz)//算帐 { strSql = new StringBuilder(); strSql.Append(" insert into Sfkfssz(yydh,qymc,is_top,is_select,jzbh,jzzt,lsbh,fjbh,krxm,fkfs,xfdr,xfrb,xfxm,xfje,sjxfje,xfrq,xfsj,czrq,czsj,czy,czy_bc,syzd,id_app)"); strSql.Append(" select yydh,qymc,0,0,jzbh,'" + jzzt + "',lsbh,fjbh,krxm,fkfs,xfdr,xfrb,xfxm,-xfje,-sjxfje,xfrq,xfsj,'" + DateTime.Parse(czsj).ToShortDateString() + "','" + czsj + "','" + czy + "','" + czy_bc + "','" + syzd + "',id_app from Szw_temp where jzbh='" + jzbh + "' and xfdr='" + common_app.fkdr + "'"); B_common.ExecuteSql(strSql.ToString()); strSql = new StringBuilder(); strSql.Append("delete from Syjcz where id>0 " + common_app.yydh_select + " and id_app in (select id_app from Szw_temp where czy_temp='" + czy_GUID + "')"); B_common.ExecuteSql(strSql.ToString()); strSql = new StringBuilder(); strSql.Append("delete from Szwmx where id>=0 " + common_file.common_app.yydh_select + " and jzbh<>'' and jzbh='" + jzbh + "'"); B_common.ExecuteSql(strSql.ToString()); } if (czzt == common_jzzt.czzt_gz || czzt == common_jzzt.czzt_jz || czzt == common_file.common_jzzt.czzt_sz) { //调用修改房态的方法(第五步) if (sk_tt == "sk") { //DataSet ds_temp0 = B_common.GetList(" select distinct lsbh from Szw_temp", " czy='" + czy + "' and yydh='" + yydh + "'"); DataSet ds_temp0 = B_common.GetList(" select * from Flfsz ", " id>=0 and yydh='" + common_file.common_app.yydh + "' and lfbh in (select lfbh from Flfsz where lsbh='" + lsbh + "' and yydh='" + common_file.common_app.yydh + "' and shlz='1' ) and shlz=1 "); // B_common.GetList("select distinct lsbh from Flfsz", " lfbh in (select lfbh From Flfsz where lsbh='" + lsbh + "' ) and shlz=1 and yydh='" + yydh + "'"); if (ds_temp0 != null && ds_temp0.Tables[0].Rows.Count > 0) { } else { ds_temp0 = B_common.GetList("select distinct lsbh from Qskyd_mainrecord", " lsbh='" + lsbh + "' and yydh='" + yydh + "'"); } if (ds_temp0 != null && ds_temp0.Tables[0].Rows.Count > 0) { s = common_app.get_failure; for (int j = 0; j < ds_temp0.Tables[0].Rows.Count; j++) { string lsbh_0 = ds_temp0.Tables[0].Rows[j]["lsbh"].ToString(); M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 " + common_app.yydh_select + " and lsbh='" + lsbh_0 + "'")[0]; id = M_Qskyd_mainrecord.id.ToString(); //删除主单记录(这里有包含主单记录删除时的备份) // if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", common_file.common_jzzt.czzt_sz, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", czzt, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) { s = common_app.get_suc; } } } else { //M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'")[0]; DataSet ds_1 = B_common.GetList(" select * from Qskyd_mainrecord ", "id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "' and main_sec='" + common_file.common_app.main_sec_main + "'"); //M_Qskyd_mainrecord = B_Qskyd_mainrecord.GetModelList("id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "'")[0]; if (ds_1 != null && ds_1.Tables[0].Rows.Count > 0) {//M_Qskyd_mainrecord.id.ToString(); //删除主单记录(这里有包含主单记录删除时的备份 id = ds_1.Tables[0].Rows[0]["id"].ToString(); // if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", common_file.common_jzzt.czzt_sz, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) if (Qyddj_add_edit_delete_new.delete_sz_xgft(id, "jz", czzt, "", jzbh, czy, czsj, xxzs) == common_app.get_suc) { s = common_app.get_suc; } } } } else//是团体 { DataSet ds_1 = B_common.GetList(" select * from Qttyd_mainrecord ", "id>0 " + common_app.yydh_select + " and lsbh='" + lsbh + "' "); if (ds_1 != null && ds_1.Tables[0].Rows.Count > 0) { //M_Qttyd_mainrecord = B_Qttyd_mainrecord.GetModelList("ID>0 " + common_app.yydh_select + " AND LSBH='" + lsbh + "'")[0]; string tt_id = ds_1.Tables[0].Rows[0]["id"].ToString();// M_Qttyd_mainrecord.id.ToString(); //要成批更新团体所有成员的房态,并删除成员主单 //string ddbh_temp = M_Qttyd_mainrecord.ddbh; // if (Qttyd_add_edit_delete_new.delete_sz_ttyd(tt_id, "jz", common_file.common_jzzt.czzt_sz, "", jzbh, czy, czsj, xxzs) == common_file.common_app.get_suc) if (Qttyd_add_edit_delete_new.delete_sz_ttyd(tt_id, "jz", czzt, "", jzbh, czy, czsj, xxzs) == common_file.common_app.get_suc) { s = common_file.common_app.get_suc; } } } if (s == common_app.get_suc) { //备份到Szw_temp_bak,清除Szw_temp,并且更新bak表里面的tfsj为当前的操作时间 strSql = new StringBuilder(); strSql.Append(" insert into Szw_temp_bak(yydh,qymc,is_top,is_select,id_app,jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,fkfs,jjje,xfje,yh,sjxfje,xfsl,shsc,mxbh,czsj,czy_temp)"); strSql.Append(" select yydh,qymc,is_top,is_select,id_app,jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,fkfs,jjje,xfje,yh,sjxfje,xfsl,shsc,mxbh,czsj,czy_temp from Szw_temp"); strSql.Append(" where czy_temp='" + czy_GUID + "' and xfxm!='" + common_app.dj_pzsk + "'"); B_common.ExecuteSql(strSql.ToString()); strSql = new StringBuilder(); strSql.Append("delete from Szw_temp where id>0 and czy_temp='" + czy_GUID + "'"); if (B_common.ExecuteSql(strSql.ToString()) >= 0) //清除Szw_temp里面的数据了 //修改备份表的tfsj { if (sk_tt == "sk") { B_common.ExecuteSql(" update Qskyd_mainrecord_bak set czsj='" + czsj + "' where jzbh='" + jzbh + "'"); B_common.ExecuteSql(" update Qskyd_mainrecord_lskr set czsj='" + czsj + "' where jzbh='" + jzbh + "'"); //B_common.ExecuteSql(" update Qskyd_mainrecord_temp set lksj='" + czsj + "' where lsbh='" + lsbh + "'"); } } if (sk_tt == "tt") { string bak_ddbh_temp = DbHelperSQL.GetSingle(" Select ddbh from Qttyd_mainrecord_bak where lsbh='" + lsbh + "' and jzbh='" + jzbh + "'").ToString(); string bak_jzbh_temp = DbHelperSQL.GetSingle(" select jzbh from Qttyd_mainrecord_bak where lsbh='" + lsbh + "' and jzbh='" + jzbh + "'").ToString(); B_common.ExecuteSql(" update Qttyd_mainrecord_bak set czsj='" + czsj + "' where lsbh='" + lsbh + "' and jzbh='" + jzbh + "'"); B_common.ExecuteSql(" update Qskyd_mainrecord_bak set czsj='" + czsj + "' where ddbh='" + bak_ddbh_temp + "' and jzbh='" + bak_jzbh_temp + "'"); B_common.ExecuteSql(" update Qskyd_mainrecord_lskr set czsj='" + czsj + "' where ddbh='" + bak_ddbh_temp + "' and jzbh='" + bak_jzbh_temp + "'"); B_common.ExecuteSql(" update Qskyd_mainrecord_temp set czsj='" + czsj + "' where ddbh='" + bak_ddbh_temp + "'"); } } //结帐成功后,更新会员的积分(挂-结,记-结,部分结,结帐都要加积分 DataSet ds_temp_2; if (sk_tt == "sk") { ds_temp_2 = B_common.GetList("select jzbh,lsbh,hykh,hykh_bz,krsj,xyh,xydw from Qskyd_mainrecord_bak", " id>=0 and jzbh='" + jzbh + "'"); if (ds_temp_2 != null && ds_temp_2.Tables[0].Rows.Count > 0) { for (int i_0 = 0; i_0 < ds_temp_2.Tables[0].Rows.Count; i_0++) { //有用到的时候才启用 //IncHYScore(ds_temp_2.Tables[0].Rows[i_0]["jzbh"].ToString(), ds_temp_2.Tables[0].Rows[i_0]["lsbh"].ToString(), sk_tt, ds_temp_2.Tables[0].Rows[i_0]["hykh_bz"].ToString(), yydh, qymc,ds_temp_2.Tables[0].Rows[i_0]["krsj"].ToString() , czsj); } } } else if (sk_tt == "tt") { } } return(s); }