예제 #1
0
        //这个函数执行的结果是,当最后一个jzbh中对应的消费条目按je_chaer的数量列入到Szw_temp中(最后一个lsbh中的i条记录插入到lsbh中)
        public void Fun_fj_chaizhang(decimal je_chaer, string jzbh, string jzzt)
        {
            BLL.Szwmx     B_Szwmx  = new Hotel_app.BLL.Szwmx();
            BLL.Common    B_common = new Hotel_app.BLL.Common();
            StringBuilder strsql;
            decimal       ljje = 0;
            string        id_app;      //当前要拆分的Id_app
            decimal       je_temp = 0; //记录当前累加值
            int           j       = 0;
            DataSet       ds      = B_Szwmx.GetList(" id>=0  and yydh='" + common_file.common_app.yydh + "'  and jzbh='" + jzbh + "'    and xfdr!='" + common_file.common_app.fkdr + "'  order by xfsj  asc");

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ljje += decimal.Parse(ds.Tables[0].Rows[i]["sjxfje"].ToString());
                    j     = i;//记录当前累加的记录
                    if (ljje < je_chaer)
                    {
                        je_temp = ljje; continue;
                    }
                    if (ljje >= je_chaer)
                    {
                        if (ljje > je_chaer)
                        {
                            string Union_bh_new = common_file.common_ddbh.ddbh("lzbh", "szdate", "szcounter", 6); //算帐操作
                            string id_app_old   = ds.Tables[0].Rows[i]["id_app"].ToString();
                            string id_app_new   = common_file.common_ddbh.ddbh("gzpj", "jzdate", "jzcounter", 6); //前缀保留成挂帐分结

                            decimal je_need = je_chaer - je_temp;
                            decimal je_last = decimal.Parse(ds.Tables[0].Rows[i]["sjxfje"].ToString()) - je_need;
                            Fun_gzpj_chaizhang(id_app_old, id_app_new, Union_bh_new, je_need, je_last, DateTime.Now.ToString());
                        }
                        break;
                    }
                }
                //将0-第i条记录添加到Szw_temp中
                for (int i_0 = 0; i_0 <= j; i_0++)
                {
                    strsql = new StringBuilder();
                    strsql.Append("insert into Szw_temp(yydh,qymc,lsbh,is_top,is_select,id_app,jzbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,fkfs,xfje,yh,sjxfje,xfsl,shsc,jjje,mxbh,czsj,czy_temp)");
                    strsql.Append(" select  yydh,qymc,lsbh,is_top,is_select,id_app,jzbh,jzzt,fjrb,fjbh,sktt,xfrq,xfsj,'" + common_file.common_app.czy + "',xfdr,xfrb,xfxm,xfbz,xfzy,fkfs,xfje,'',sjxfje,xfsl,shsc,'0',mxbh,czsj,'" + common_file.common_app.czy_GUID + "'   from Sjzmx");
                    strsql.Append("  where     jzbh='" + jzbh + "'  and  id_app='" + ds.Tables[0].Rows[i_0]["id_app"].ToString() + "'");
                    B_common.ExecuteSql(strsql.ToString());
                }
            }
        }
예제 #2
0
        //id_app_old  要拆帐的那条,id_app_new  要拆出的那条  union_lzbh 两条生成的lzbh
        //fj_type  是算帐分结,记帐分结,挂帐分结(common_file.common_jzzt.xxxxx)
        //je_need要拆出来的金额,je_last余下的金额
        //

        //userType  1为正常的拆账,2为单拆
        public static void  Fun_fj_chaizhang(string id_app_old, string id_app_new, string union_lzbh, decimal je_need, decimal je_last, string fj_type, string czsj, string userType)
        {
            BLL.Szwmx     B_Szwmx  = new Hotel_app.BLL.Szwmx();
            BLL.Common    B_common = new Hotel_app.BLL.Common();
            StringBuilder strsql;

            Model.Szwmx M_Szwmx;

            M_Szwmx = B_Szwmx.GetModelList("id_app='" + id_app_old + "'  and id>=0  and  yydh='" + common_file.common_app.yydh + "'")[0];
            double xfsl_need = common_file.common_sswl.Round_sswl(double.Parse((je_need / (je_need + je_last) * M_Szwmx.xfsl).ToString()), common_file.common_sswl.sswl_ws, common_file.common_sswl.selectMode_sel); //拆出消费数量
            double xfsl_last = double.Parse((M_Szwmx.xfsl).ToString()) - xfsl_need;

            //向Szw_union里面加入拆出来的两条记录(1表示是第一条记录,原来被拆的那条,0表示新加的那条)
            string temp_czsj = DateTime.Now.ToString();//保持两条的时间一致

            strsql = new StringBuilder();
            strsql.Append("insert into  Szw_union(yydh,qymc,union_bh,jzbh,id_app,czsj,is_first)");
            strsql.Append("  select yydh,qymc,'" + union_lzbh + "',jzbh,'" + id_app_old + "','" + temp_czsj + "',1   from Szwmx ");
            strsql.Append("  where  id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());//第一条(旧的记录)
            strsql = new StringBuilder();
            strsql.Append("insert into  Szw_union(yydh,qymc,union_bh,jzbh,id_app,czsj,is_first)");
            strsql.Append("  select yydh,qymc,'" + union_lzbh + "',jzbh,'" + id_app_new + "','" + temp_czsj + "',0   from Szwmx ");
            strsql.Append("  where id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());//第二条(新生成的一条记录)

            //第一步,拆分帐务明细表的记录
            strsql = new StringBuilder();
            strsql.Append("update  Szwmx  set  xfje=" + je_last + ", sjxfje=" + je_last + ", xfsl=" + xfsl_last + "  where id>=0  and yydh='" + common_file.common_app.yydh + "'  and id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());
            //注意这里的xfzy  以分结类型用"拆帐"来显示
            strsql = new StringBuilder();
            strsql.Append("insert into  Szwmx(yydh,qymc,is_top,is_select,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,is_visible,mxbh)");
            strsql.Append("  select  yydh,qymc,is_top,is_select,'" + id_app_new + "',jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,'" + common_zw.zwcl_caiz + "',jjje," + je_need + ",yh," + je_need + "," + xfsl_need + ",shsc,czy_bc,czzt,czsj,syzd,is_visible,mxbh  from  Szwmx");
            strsql.Append("  where  id>=0 and id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());

            ////结帐明细要一起分拆--针对记。挂
            //if (fj_type == common_file.common_jzzt.czzt_gzfj || fj_type == common_file.common_jzzt.czzt_jzfj)
            //{
            //    strsql = new StringBuilder();
            //    strsql.Append("update  Sjzmx  set  xfje=" + je_last + ", sjxfje=" + je_last + ", xfsl=" + xfsl_last + "  where id>=0  and yydh='" + common_file.common_app.yydh + "'  and id_app='" + id_app_old + "'");
            //    B_common.ExecuteSql(strsql.ToString());

            //    strsql = new StringBuilder();
            //    strsql.Append("insert into  Sjzmx(yydh,qymc,is_top,is_select,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,is_visible,xyh,jzzt,fkfs,mxbh,tfsj)");
            //    strsql.Append("  select  yydh,qymc,is_top,is_select,'" + id_app_new + "',jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,'" + common_zw.zwcl_caiz + "',jjje," + je_need + ",yh," + je_need + "," + xfsl_need + ",shsc,czy_bc,czzt,czsj,syzd,is_visible,xyh,jzzt,fkfs,mxbh,tfsj  from  Sjzmx");
            //    strsql.Append("  where  id>=0 and id_app='" + id_app_old + "'");
            //    B_common.ExecuteSql(strsql.ToString());
            //}
            //看当前的id_app_old是否存在于Sjzmx中,存在也要拆分
            DataSet ds_temp_0 = B_common.GetList(" select * from Sjzmx  ", " id>=0  and  id_app='" + id_app_old + "'  and  yydh='" + common_file.common_app.yydh + "' ");

            if (ds_temp_0 != null && ds_temp_0.Tables[0].Rows.Count > 0)
            {
                strsql = new StringBuilder();
                strsql.Append("update  Sjzmx  set  xfje=" + je_last + ", sjxfje=" + je_last + ", xfsl=" + xfsl_last + "  where id>=0  and yydh='" + common_file.common_app.yydh + "'  and id_app='" + id_app_old + "'");
                B_common.ExecuteSql(strsql.ToString());

                strsql = new StringBuilder();
                strsql.Append("insert into  Sjzmx(yydh,qymc,is_top,is_select,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,is_visible,xyh,jzzt,fkfs,mxbh,tfsj)");
                strsql.Append("  select  yydh,qymc,is_top,is_select,'" + id_app_new + "',jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,'" + common_zw.zwcl_caiz + "',jjje," + je_need + ",yh," + je_need + "," + xfsl_need + ",shsc,czy_bc,czzt,czsj,syzd,is_visible,xyh,jzzt,fkfs,mxbh,tfsj  from  Sjzmx");
                strsql.Append("  where  id>=0 and id_app='" + id_app_old + "'");
                B_common.ExecuteSql(strsql.ToString());
            }

            //第二步,拆分ssyxfmx里面的记录
            strsql = new StringBuilder();
            strsql.Append(" update   Ssyxfmx  Set xfje=" + je_last + ",  sjxfje=" + je_last + ",xfsl=" + xfsl_last + "   where id>=0  and yydh='" + common_file.common_app.yydh + "' and id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());
            //

            strsql = new StringBuilder();
            strsql.Append("insert into Ssyxfmx(yydh,qymc,id_app,jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,xfzy,jjje,xfje,yh,sjxfje,xfsl,czy_bc,mxbh,ddsj,lksj,czsj )");
            strsql.Append(" select yydh,qymc,'" + id_app_new + "',jzbh,lsbh,krxm,fjrb,fjbh,sktt,xfrq,xfsj,czy,xfdr,xfrb,xfxm,xfbz,'" + common_zw.zwcl_caiz + "',jjje," + je_need + ",yh," + je_need + "," + xfsl_need + ",czy_bc,mxbh,ddsj,lksj,'" + czsj + "'   from Ssyxfmx");
            strsql.Append(" where id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());

            //增加完成后直接向Ssyxfmx_cz里面加一条记录
            strsql = new StringBuilder();
            strsql.Append("insert into  Ssyxfmx_cz(yydh,qymc,id_app,krly,yxzj,zjhm,krsj,xyh,xydw,xsy,hykh,krgj,pq,gj_sf,gj_cs,gj_dq)");
            strsql.Append("  select  yydh,qymc,'" + id_app_new + "',krly,yxzj,zjhm,krsj,xyh,xydw,xsy,hykh,krgj,pq,gj_sf,gj_cs,gj_dq from Ssyxfmx_cz ");
            strsql.Append("  where id>=0  and id_app='" + id_app_old + "'");
            B_common.ExecuteSql(strsql.ToString());



            //把新拆出来的一条记录加入到Szw_zz_fj_temp里面
            if (userType == "1")
            {
                strsql = new StringBuilder();
                strsql.Append("insert into  Szw_zz_fj_temp(yydh,qymc,jzbh,id_app,lsbh,czy,czsj)");
                //strsql.Append("   select  yydh,qymc,jzbh,'" + id_app_new + "',lsbh,czy,'" + czsj + "'  from  Szwmx ");
                strsql.Append("   select  yydh,qymc,jzbh,'" + id_app_new + "',lsbh,'" + common_file.common_app.czy_GUID + "','" + czsj + "'  from  Szwmx ");
                //strsql.Append("  where  id_app='" + id_app_old + "'");
                strsql.Append("   where  id_app='" + id_app_new + "'");
                B_common.ExecuteSql(strsql.ToString());
            }
        }