コード例 #1
0
        //平帐时用到的方法
        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);
        }
コード例 #2
0
        //此函数是向Szw_temp中加载要批结的数据(分两个步骤完成的)
        public void GetPLJZData(DateTime _dt_start, DateTime _dt_end, string _pljz_type, decimal pjje, string jzzt, string jjType, out string jzbh_last_return)
        {
            //删除Szw_temp中当前czy_guid的所有记录,这一步非常关键
            jzbh_last_return = "";
            StringBuilder sb = new StringBuilder();

            sb.Append(" delete from  Szw_temp  where  id>=0  and yydh='" + common_file.common_app.yydh + "'  and  czy_temp='" + common_file.common_app.czy_GUID + "' ");
            B_common.ExecuteSql(sb.ToString());

            dt_start = _dt_start;
            dt_end   = _dt_end;
            decimal xfje    = 0;
            decimal fkje    = 0;
            decimal je_temp = 0;

            pljz_type = _pljz_type;
            if (pljz_type == "Time")//按时间批量结算(直接找到  结帐主单
            {
                jzbh_last_return = "";
                xfje             = 0; fkje = 0; ljje = 0;
                List <string> lsbh_jzbh = new List <string>();
                ds = B_sjzzd.GetList(" id>=0  and  yydh='" + common_file.common_app.yydh + "'  and   (czzt='" + common_file.common_jzzt.czzt_gz + "'  or  czzt='" + common_file.common_jzzt.czzt_jzzgz + "')   and  tfsj>='" + dt_start + "'  and  tfsj<='" + dt_end + "'  and  jzzt='" + jzzt + "'  order by  tfsj  asc");
                if (ds != null & ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        xfje = decimal.Parse(ds.Tables[0].Rows[i]["xfje"].ToString());
                        fkje = decimal.Parse(ds.Tables[0].Rows[i]["fkje"].ToString());
                        lsbh_jzbh.Add(ds.Tables[0].Rows[i]["lsbh"].ToString() + "|" + ds.Tables[0].Rows[i]["jzbh"].ToString());
                    }
                }
                //遍历所有出现的lsbh,向Szw_temp 中加入数据
                StringBuilder strsql_1;
                //
                for (int i = 0; i < lsbh_jzbh.Count; i++)
                {
                    //加载消费
                    string lsbh_temp_1 = lsbh_jzbh[i].Split('|')[0].ToString();
                    string jzbh_temp_1 = lsbh_jzbh[i].Split('|')[1].ToString();
                    strsql_1 = new StringBuilder();
                    strsql_1.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_1.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,'1',shsc,'0',mxbh,czsj,'" + common_file.common_app.czy_GUID + "' from Sjzmx");
                    strsql_1.Append("  where   jzbh='" + jzbh_temp_1 + "' and  xfdr!='" + common_file.common_app.fkdr + "'  and  jzzt='" + jzzt + "'");
                    B_common.ExecuteSql(strsql_1.ToString());

                    //加载付款
                    strsql_1 = new StringBuilder();
                    strsql_1.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_1.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,'1',shsc,'0',mxbh,czsj,'" + common_file.common_app.czy_GUID + "'  from Sjzmx");
                    strsql_1.Append("  where   jzbh='" + jzbh_temp_1 + "'  and  xfdr='" + common_file.common_app.fkdr + "'");
                    B_common.ExecuteSql(strsql_1.ToString());
                }
            }
            if (pljz_type == "Value")//按值计算
            {
                jzbh_last_return = "";
                decimal je_ljz = 0;//记录完成一次累加之后的累计值
                int     j_0 = 0; List <string> lsbh_jzbh = new List <string>();
                ds = B_sjzzd.GetList(" id>=0 and yydh='" + common_file.common_app.yydh + "'  and   (czzt='" + common_file.common_jzzt.czzt_gz + "'  or  czzt='" + common_file.common_jzzt.czzt_jzzgz + "')  and jzzt='" + jzzt + "'  order by  tfsj  asc");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        je_temp += (Math.Abs(decimal.Parse(ds.Tables[0].Rows[i]["xfje"].ToString())) - Math.Abs(decimal.Parse(ds.Tables[0].Rows[i]["fkje"].ToString())));
                        if (je_temp < pjje)
                        {
                            j_0 = i;//记录当前累加时记录到哪条sjzzd
                            lsbh_jzbh.Add(ds.Tables[0].Rows[i]["lsbh"].ToString() + "|" + ds.Tables[0].Rows[i]["jzbh"].ToString());
                            je_ljz = je_temp;
                            continue;
                        }

                        //这一部是将最后一个sjzzd中要累加的记录找出来添加到Szw_temp中;
                        if (je_temp >= pjje)//当累计金额达到要结账的金额时
                        {
                            if (i == 0)
                            {
                                j_0 = -1;
                            }
                            else
                            {
                                j_0 = i - 1;
                            }
                            decimal je_chaer  = pjje - je_ljz;//最后这条结账编号要拆出多少金额出来
                            string  jzbh_last = ds.Tables[0].Rows[i]["jzbh"].ToString();
                            jzbh_last_return = jzbh_last;
                            //string jzbh_last=ds.Tables[0].Rows[i]["jzbh"].ToString();
                            BLL.Sjzmx B_Sjzmx = new Hotel_app.BLL.Sjzmx();
                            DataSet   ds_temp = B_Sjzmx.GetList(" id>=0  and yydh='" + common_file.common_app.yydh + "'  and     jzbh='" + jzbh_last + "'");
                            //对最后一个lsbh执行类似拆账的操作
                            Fun_fj_chaizhang(je_chaer, jzbh_last, jzzt);
                            break;
                        }
                    }
                    //把第0-j_0条记录添加到Szw_temp中
                    System.Text.StringBuilder strsql_2 = new StringBuilder();
                    if (j_0 >= 0)
                    {
                        for (int i_0 = 0; i_0 <= j_0; i_0++)
                        {
                            string lsbh_temp_1 = lsbh_jzbh[i_0].Split('|')[0].ToString();
                            string jzbh_temp_1 = lsbh_jzbh[i_0].Split('|')[1].ToString();
                            strsql_2 = new StringBuilder();
                            strsql_2.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_2.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,'1',shsc,'0',mxbh,czsj,'" + common_file.common_app.czy_GUID + "' from Sjzmx");
                            strsql_2.Append("  where    jzbh='" + jzbh_temp_1 + "'  and  xfdr!='" + common_file.common_app.fkdr + "'  and  jzzt='" + jzzt + "'");
                            B_common.ExecuteSql(strsql_2.ToString());

                            strsql_2 = new StringBuilder();
                            strsql_2.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_2.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,'1',shsc,'0',mxbh,czsj,'" + common_file.common_app.czy_GUID + "'  from Sjzmx");
                            strsql_2.Append("  where   jzbh='" + jzbh_temp_1 + "'  and  xfdr='" + common_file.common_app.fkdr + "'");
                            B_common.ExecuteSql(strsql_2.ToString());
                        }
                    }
                }
            }
        }