Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gcbh"></param>
        /// <param name="deptCode"></param>
        /// <param name="kmCode"></param>
        /// <param name="billdate"></param>
        /// <returns></returns>
        public decimal GetYueHf(string gcbh, string deptCode, string kmCode, string strdydj)
        {
            string   strflowid = "";
            DateTime begDate   = new DateTime();
            DateTime endDate   = new DateTime();
            string   strcn     = new ConfigBLL().GetValueByKey("CYLX");//是否是财年

            if (!string.IsNullOrEmpty(strcn) && strcn == "Y" && (!string.IsNullOrEmpty(strdydj)))
            {
                string strsql = " select * from bill_ysgc where gcbh='" + gcbh + "'";

                DataTable dttime = new sqlHelper.sqlHelper().GetDataTable(strsql, null);//根据计划过程获取开始结束时间
                if (dttime != null && dttime.Rows.Count > 0)
                {
                    begDate = Convert.ToDateTime(dttime.Rows[0]["kssj"].ToString());
                    endDate = Convert.ToDateTime(dttime.Rows[0]["jzsj"].ToString());
                }
            }
            else
            {
                string[] temp = GetYsYearMonth(gcbh);
                string[] yf   = temp[2].Split('|');
                begDate = new DateTime(Int32.Parse(temp[0]), Int32.Parse(yf[0]), 1);
                endDate = new DateTime(Int32.Parse(temp[0]), Int32.Parse(yf[yf.Length - 1]), 1).AddMonths(1);
            }
            //返回花费金额

            //hfje=new sqlHelper.sqlHelper().GetCellValue("exec dz_hfje '"++"','','',''")
            bool dz_syys_flg = new ConfigBLL().GetValueByKey("dz_syys_flg").Equals("1");//大智剩余预算取值方式flg 大智的取值通过存储过程 dz_hfje

            if (!dz_syys_flg)
            {
                //根据对应单据找出对应决算flowid
                if (!string.IsNullOrEmpty(strdydj))
                {
                    MainDal maindal = new MainDal();
                    strflowid = maindal.getJSFlowId(strdydj);
                    return(ysDal.GetYueHfje(begDate, endDate, deptCode, kmCode, strflowid));
                }
                else
                {
                    return(ysDal.GetYueHfje(begDate, endDate, deptCode, kmCode));
                }
            }
            else
            {
                decimal deje = 0;
                ////string nd = "";
                ////string strcnyf = "";
                ////根据过程编号获取年月



                //                // exec [dz_hfje_bxd] '0119','2017','020107','2017-02'


                //                //string strsql_new = @"exec dz_hfje_bxd '" + begDate + "','" + endDate + "','" + deptCode + "','" + kmCode + "'";

                //                try
                //                {
                //                    string strcnyfsql = @"select nian + '-' +right('0'+ yue,2) as cnyf ,*
                //                                        from bill_ysgc  where gcbh='" + gcbh + "' and ysType = 2 ";
                //                    DataTable dtysgc = new sqlHelper.sqlHelper().GetDataTable(strcnyfsql, null);
                //                    if (dtysgc!=null&&dtysgc.Rows.Count>0)
                //                    {
                //                        nd = dtysgc.Rows[0]["nian"].ToString();
                //                        strcnyf = dtysgc.Rows[0]["cnyf"].ToString();
                //                    }

                //                    IList<yskmhf> ysmxb_hf = new Bll.newysgl.bill_ysmxbBll().getkmje(deptCode, nd);
                //                    string strje = ysmxb_hf.Where(p => p.fykm == kmCode && p.cnyf == strcnyf).Sum(p => p.je).ToString();
                //                    if (decimal.TryParse(strje, out deje))
                //                    {
                //                        return deje;
                //                    }
                //                    else
                //                    {
                //                        return 0;
                //                    }

                //                }
                //                catch (Exception)
                //                {

                //                    return 0;
                //                }



                string strsql = @"exec dz_hfje '" + begDate + "','" + endDate + "','" + deptCode + "','" + kmCode + "'";

                try
                {
                    string je = new sqlHelper.sqlHelper().GetCellValue(strsql);
                    if (!string.IsNullOrEmpty(je))
                    {
                        decimal.TryParse(je, out deje);
                    }
                    return(deje);
                }
                catch (Exception)
                {
                    return(0);
                }
            }
        }