Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("7-2-3-8"))
                {
                    storesID = HTTPRequest.GetInt("sid", 0);
                    selectID = HTTPRequest.GetInt("aid", 0);
                    bDate    = Convert.ToDateTime(HTTPRequest.GetString("bDate"));
                    eDate    = Convert.ToDateTime(HTTPRequest.GetString("eDate"));
                    sName    = HTTPRequest.GetString("sName");
                    sType    = HTTPRequest.GetString("sType");

                    kList = HTTPRequest.GetString("kID");
                    string[] kList_Arrary = kList.Split(',');
                    for (int i = 0; i < kList_Arrary.Length - 1; i++)
                    {
                        //判断是否有子节点
                        bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(kList_Arrary[i]));
                        if (tl)
                        {
                            dataclass = CostDetails.getTreeChildrenCount(kList_Arrary[i]);
                            string[] dclass = dataclass.Split(',');
                            for (int j = 0; j < dclass.Length - 1; j++)
                            {
                                sList = CostDetails.getCostOfStorehouseDetails(selectID, storesID, dclass[j].ToString(), bDate, eDate);
                                DataTable dt = sList.Copy();
                                dt.TableName = "p" + j + c_count;
                                sDateSet.Tables.Add(dt);
                                c_count++;
                            }
                        }
                        else
                        {
                            sList = CostDetails.getCostOfStorehouseDetails(selectID, storesID, kList_Arrary[i], bDate, eDate);
                            DataTable dt = sList.Copy();
                            dt.TableName = "f" + i + c_count;
                            sDateSet.Tables.Add(dt);
                            c_count++;
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Exemplo n.º 2
0
        //明细账
        public DataTable getMonthCostDetails(string subjects, DateTime bDate, DateTime eDate, string oMonth, int sType, int status)
        {
            DataTable cdt    = new DataTable();      //明细
            DataSet   cds    = new DataSet();        //明细
            DataTable csCost = new DataTable();      //明细合成表
            DataTable dtCost = new DataTable();

            result = subjects.Split(',');
            for (int i = 0; i < result.Length - 1; i++)
            {
                bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                if (tl)
                {
                    dataclass = CostDetails.getTreeChildrenCount(result[i]);    //找到子节点
                    string[] dclass = dataclass.Split(',');
                    for (int j = 0; j < dclass.Length - 1; j++)
                    {
                        dtCost        = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(oMonth), sType, status);
                        cdt           = dtCost.Copy();
                        cdt.TableName = "c_" + j + tCount;
                        cds.Tables.Add(cdt);
                        tCount++;
                    }
                    csCost = cds.Tables[0].Clone();                       //创建新表 克隆以有表的架构
                    object[] objArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < cds.Tables.Count; m++)
                    {
                        if (cds.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < cds.Tables[m].Rows.Count; n++)
                            {
                                cds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                csCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                            }
                        }
                    }
                }
                else
                {
                    csCost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(oMonth), sType, status);
                }
            }

            if (csCost.Rows.Count > 0)
            {
                DataView dv = new DataView(csCost);
                dv.Sort = "Cmonth";
                csCost  = dv.ToTable(true, "Cmonth", "Cday", "CertificateID", "pzCode", "cdName", "cdMoney", "cdMoneyA", "cdMoneyB", "cdMoneyBB", "cDirection", "FeesSubjectID", "cClassName", "cCode", "unit");
            }
            return(csCost);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("7-2-3-8"))
                {
                    selectID  = HTTPRequest.GetInt("aid", 0);
                    bDate     = Convert.ToDateTime(HTTPRequest.GetString("bDate"));
                    eDate     = Convert.ToDateTime(HTTPRequest.GetString("eDate"));
                    className = HTTPRequest.GetString("className");
                    kID       = HTTPRequest.GetInt("kID", 0);
                    //判断是否有子节点
                    bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(kID));
                    if (tl)
                    {
                        dataclass = CostDetails.getTreeChildrenCount(kID.ToString());
                        string[] dclass = dataclass.Split(',');
                        for (int j = 0; j < dclass.Length - 1; j++)
                        {
                            cList = CostDetails.getCostOfClassDetails(selectID, bDate, eDate, Convert.ToInt32(dclass[j].ToString()));

                            DataTable rt = cList.Copy();
                            rt.TableName = "o_" + j + c_count;
                            rDateSet.Tables.Add(rt);
                            c_count = c_count + 1;
                        }
                    }
                    else
                    {
                        cList = CostDetails.getCostOfClassDetails(selectID, bDate, eDate, kID);

                        DataTable rt = cList.Copy();
                        rt.TableName = "o_" + c_count;
                        rDateSet.Tables.Add(rt);
                        c_count = c_count + 1;
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
        //总账
        public object getMonthCostTotalDetails(string subjects, DateTime bDate, DateTime eDate, string oMonth, int sType, int status)
        {
            DataTable cdt    = new DataTable();     //明细
            DataSet   cds    = new DataSet();       //明细
            DataTable sCost  = new DataTable();     //明细合成表
            DataTable dtCost = new DataTable();

            result = subjects.Split(',');
            for (int i = 0; i < result.Length - 1; i++)
            {
                bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                if (tl)
                {
                    dataclass = CostDetails.getTreeChildrenCount(result[i]);//找到子节点
                    string[] dclass = dataclass.Split(',');
                    for (int j = 0; j < dclass.Length - 1; j++)
                    {
                        dtCost        = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(oMonth), sType, status);
                        cdt           = dtCost.Copy();
                        cdt.TableName = "c_" + j + tCount;
                        cds.Tables.Add(cdt);
                        tCount++;
                    }
                    sCost = cds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
                    object[] objArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < cds.Tables.Count; m++)
                    {
                        if (cds.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < cds.Tables[m].Rows.Count; n++)
                            {
                                cds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                sCost.Rows.Add(objArray);                            //将数组的值添加到新表中
                            }
                        }
                    }
                }
                else
                {
                    sCost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(oMonth), sType, status);
                }
            }

            if (sCost.Rows.Count > 0)
            {
                cdMoney   = 0;
                cdMoneyA  = 0;
                cdMoneyB  = 0;
                cdMoneyBB = 0;

                cdMoney   = Convert.ToDecimal(sCost.Compute("sum(cdMoney)", "").ToString());
                cdMoneyA  = Convert.ToDecimal(sCost.Compute("sum(cdMoneyA)", "").ToString());
                cdMoneyB  = Convert.ToDecimal(sCost.Compute("sum(cdMoneyB)", "").ToString());
                cdMoneyBB = Convert.ToDecimal(sCost.Compute("sum(cdMoneyBB)", "").ToString());
            }
            else
            {
                cdMoney   = 0;
                cdMoneyA  = 0;
                cdMoneyB  = 0;
                cdMoneyBB = 0;
            }
            return(obj);
        }
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-9"))
                {
                    subjectID = HTTPRequest.GetString("subjectID");

                    sType = HTTPRequest.GetInt("tid", 0);
                    string dd = HTTPRequest.GetString("bDate");
                    string td = HTTPRequest.GetString("eDate");
                    bDate    = (HTTPRequest.GetString("bDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("bDate").Trim()) : DateTime.Now; //获得日期
                    eDate    = (HTTPRequest.GetString("eDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("eDate").Trim()) : DateTime.Now; //获得日期
                    getYear  = bDate.ToString("yyyy");
                    bTime    = bDate.ToString("yyyy.MM");
                    eTime    = eDate.ToString("yyyy.MM");
                    uiName   = tbUserInfo.GetUserInfoModel(this.userid);
                    oneMonth = Convert.ToInt32(bDate.ToString("MM"));
                    status   = HTTPRequest.GetInt("status", 0);


                    result = subjectID.Split(',');

                    for (int i = 0; i < result.Length - 1; i++)
                    {
                        //获得科目所选节点科目名称
                        fsubjectName = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));
                        //找到节点的所有父节点
                        fatherNode = DataClass.GetFeesSubjectClassParentStr(Convert.ToInt32(result[i]), "/");
                        //截取第一个节点
                        string[] getFirstNode = fatherNode.Split('/');
                        for (int pp = 0; pp < getFirstNode.Length; pp++)
                        {
                            className = getFirstNode[0].ToString();
                        }

                        if (fsubjectName != null)
                        {
                            for (int p = 0; p < fsubjectName.Rows.Count; p++)
                            {
                                zNode          = fsubjectName.Rows[p]["cClassName"].ToString();
                                classCode      = fsubjectName.Rows[p]["cCode"].ToString();
                                classDirection = Convert.ToInt32(fsubjectName.Rows[p]["cDirection"].ToString());
                            }
                        }

                        //判断是否有子节点
                        tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                        if (tl)
                        {
                            dataclass = CostDetails.getTreeChildrenCount(result[i]);//找到子节点
                            string[] dclass = dataclass.Split(',');
                            for (int j = 0; j < dclass.Length - 1; j++)
                            {
                                //获得月份
                                mList         = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(dclass[j]), bDate, eDate);
                                mdt           = mList.Copy();
                                mdt.TableName = "m_" + j + c_count;
                                mds.Tables.Add(mdt);


                                //获得最大月
                                maxList += CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(dclass[j]), bDate, eDate) + ",";
                                //获得科目名称及编码
                                objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(dclass[j]));

                                //上年结转余额
                                dList         = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(dclass[j]), status);
                                ydt           = dList.Copy();
                                ydt.TableName = "y_" + j + c_count;
                                yds.Tables.Add(ydt);

                                c_count++;
                            }
                            //--====================================月份合成表=============================================
                            msCost = mds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
                            object[] objmArray = new object[msCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < mds.Tables.Count; m++)
                            {
                                if (mds.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < mds.Tables[m].Rows.Count; n++)
                                    {
                                        mds.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中
                                        msCost.Rows.Add(objmArray);                           //将数组的值添加到新表中
                                    }
                                }
                            }
                            DataView dv = new DataView(msCost);
                            dv.Sort = "oMonth";
                            nTable  = dv.ToTable(true, "oMonth");
                            //==============上年结存余额合成一张表==============================
                            ysCost = yds.Tables[0].Clone();                       //创建新表 克隆以有表的架构
                            object[] objArray = new object[ysCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < yds.Tables.Count; m++)
                            {
                                if (yds.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < yds.Tables[m].Rows.Count; n++)
                                    {
                                        yds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                        ysCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                                    }
                                }
                            }
                            if (ysCost.Rows.Count > 0)
                            {
                                ycAccountMoney = Convert.ToDecimal(ysCost.Compute("sum(cAccountMoney)", "").ToString());
                            }
                            //找到科目中最大月
                            string[] maxListArrary = maxList.Split(',');

                            for (int q = 0; q < maxListArrary.Length - 1; q++)
                            {
                                if (maxListArrary[q].ToString() != "")
                                {
                                    int mValue = Convert.ToInt32(maxListArrary[q].ToString());
                                    if (mValue > maxValue)
                                    {
                                        maxValue = mValue;
                                    }
                                }
                            }
                            maxList = maxValue.ToString();



                            //明细账分页统计打印
                            for (int j = 0; j < dclass.Length - 1; j++)
                            {
                                //获得明细账打印明细
                                for (int mm = 0; mm < nTable.Rows.Count; mm++)
                                {
                                    if (nTable.Rows.Count == 1)
                                    {
                                        dtCost = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status);
                                    }
                                    else
                                    {
                                        DataTable Cost = CostDetails.getMonthCost(Convert.ToInt32(dclass[j]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status);

                                        DataTable dtm = Cost.Copy();
                                        dtm.TableName = "rmdn_" + mm + j;
                                        dtms.Tables.Add(dtm);
                                    }
                                }
                                if (dtms.Tables.Count > 1)
                                {
                                    qList = dtms.Tables[0].Clone();                    //创建新表 克隆以有表的架构
                                    object[] mArray = new object[qList.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                    for (int m = 0; m < dtms.Tables.Count; m++)
                                    {
                                        if (dtms.Tables[m].Rows.Count > 0)
                                        {
                                            for (int n = 0; n < dtms.Tables[m].Rows.Count; n++)
                                            {
                                                dtms.Tables[m].Rows[n].ItemArray.CopyTo(mArray, 0); //将表的一行的值存放数组中
                                                qList.Rows.Add(mArray);                             //将数组的值添加到新表中
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    qList = dtCost.Copy();
                                }

                                cdt           = qList.Copy();
                                cdt.TableName = "cttr_" + j + tCount;
                                cds.Tables.Add(cdt);
                                tCount++;
                            }
                            csCost = cds.Tables[0].Clone();                     //创建新表 克隆以有表的架构
                            object[] oArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < cds.Tables.Count; m++)
                            {
                                if (cds.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < cds.Tables[m].Rows.Count; n++)
                                    {
                                        cds.Tables[m].Rows[n].ItemArray.CopyTo(oArray, 0); //将表的一行的值存放数组中
                                        csCost.Rows.Add(oArray);                           //将数组的值添加到新表中
                                    }
                                }
                            }
                            if (csCost.Rows.Count > 0 && sType == 0)
                            {
                                DataView dvw = new DataView(csCost);
                                dvw.Sort = "Cmonth";
                                csCost   = dvw.ToTable(true, "Cmonth", "Cday", "CertificateID", "pzCode", "cdName", "cdMoney", "cdMoneyA", "cdMoneyB", "cdMoneyBB", "cDirection", "FeesSubjectID", "cClassName", "cCode");
                            }
                            if (csCost != null)
                            {
                                detailsCount = csCost.Rows.Count;
                                int p = 0;
                                dt = csCost.Clone();
                                foreach (DataRow dr in csCost.Rows)
                                {
                                    dt.ImportRow(dr);
                                    p++;
                                    if (p % MaxDetailsCount == 0)
                                    {
                                        dsDetails.Tables.Add(dt);
                                        dt           = csCost.Clone();
                                        dt.TableName = "q_" + p;
                                    }
                                }
                                if (dt.Rows.Count > 0)
                                {
                                    //剩下的行数
                                    dsDetails.Tables.Add(dt);
                                    dt           = csCost.Clone();
                                    dt.TableName = "t_" + (p + 1);
                                }
                            }
                            dTable = dsDetails.Tables.Count;
                        }
                        else
                        {
                            //上年结转余额
                            ysCost = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(result[i]), status);
                            //获得月份
                            nTable = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(result[i]), bDate, eDate);
                            //获得最大月
                            maxList = CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(result[i]), bDate, eDate);
                            //获得科目名称及编码
                            objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(result[i]));


                            //获得明细账打印明细

                            for (int mm = 0; mm < nTable.Rows.Count; mm++)
                            {
                                if (nTable.Rows.Count == 1)
                                {
                                    csCost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status);
                                }
                                else
                                {
                                    DataTable Cost = CostDetails.getMonthCost(Convert.ToInt32(result[i]), bDate, eDate, Convert.ToInt32(nTable.Rows[mm][0].ToString()), sType, status);
                                    DataTable dtm  = Cost.Copy();
                                    dtm.TableName = "rmd_" + mm;
                                    dtms.Tables.Add(dtm);
                                }
                            }
                            if (dtms.Tables.Count > 1)
                            {
                                csCost = dtms.Tables[0].Clone();                       //创建新表 克隆以有表的架构
                                object[] objmArray = new object[csCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                for (int m = 0; m < dtms.Tables.Count; m++)
                                {
                                    if (dtms.Tables[m].Rows.Count > 0)
                                    {
                                        for (int n = 0; n < dtms.Tables[m].Rows.Count; n++)
                                        {
                                            dtms.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中
                                            csCost.Rows.Add(objmArray);                            //将数组的值添加到新表中
                                        }
                                    }
                                }
                            }

                            if (csCost != null)
                            {
                                detailsCount = csCost.Rows.Count;
                                int p = 0;
                                dt = csCost.Clone();
                                foreach (DataRow dr in csCost.Rows)
                                {
                                    dt.ImportRow(dr);
                                    p++;
                                    if (p % MaxDetailsCount == 0)
                                    {
                                        dsDetails.Tables.Add(dt);
                                        dt.TableName = "t_" + p;
                                        dt           = csCost.Clone();
                                    }
                                }
                                if (dt.Rows.Count > 0)
                                {
                                    //剩下的行数
                                    dsDetails.Tables.Add(dt);
                                    dt           = csCost.Clone();
                                    dt.TableName = "t_" + (p + 1);
                                }
                            }

                            dTable = dsDetails.Tables.Count;
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Exemplo n.º 6
0
        public object getClassDetails(string feeID)
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();


            //判断是否有子节点
            bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(feeID));

            if (tl)
            {
                string dataclass = CostDetails.getTreeChildrenCount(feeID);

                string[] dclass = dataclass.Split(',');
                for (int j = 0; j < dclass.Length - 1; j++)
                {
                    dt              = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(dclass[j]), status);
                    dList           = dt.Copy();
                    dList.TableName = "t_" + j + c_count;
                    ds.Tables.Add(dList);
                    c_count++;
                }
            }
            else
            {
                dt              = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(feeID), status);
                dList           = dt.Copy();
                dList.TableName = "d_" + c_count;
                ds.Tables.Add(dList);
                c_count++;
            }

            //合成一张表
            sCost = ds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
            object[] objArray = new object[sCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
            for (int m = 0; m < ds.Tables.Count; m++)
            {
                if (ds.Tables[m].Rows.Count > 0)
                {
                    for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                    {
                        ds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                        sCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                    }
                }
            }
            if (sCost.Rows.Count > 0)
            {
                cAccountMoney = Convert.ToDecimal(sCost.Compute("sum(cAccountMoney)", "").ToString());
                JcdMoney      = Convert.ToDecimal(sCost.Compute("sum(JcdMoney)", "").ToString());
                DcdMoney      = Convert.ToDecimal(sCost.Compute("sum(DcdMoney)", "").ToString());
                OMoney        = Convert.ToDecimal(sCost.Compute("sum(oMoney)", "").ToString());
                iMoney        = Convert.ToDecimal(sCost.Compute("sum(iMoney)", "").ToString());
                uiName        = tbUserInfo.GetUserInfoModel(this.userid);
            }
            else
            {
                cAccountMoney = 0;
                JcdMoney      = 0;
                DcdMoney      = 0;
                OMoney        = 0;
                iMoney        = 0;
            }

            return(obj);
        }
Exemplo n.º 7
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-9"))
                {
                    //科目树
                    FeesSubjectJson = Caches.GetFeesSubjectClassInfoToJson(-1, false, true);

                    bDate    = (HTTPRequest.GetString("bDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("bDate").Trim()) : DateTime.Now.AddDays(-(DateTime.Now.Day) + 1); //获得日期
                    eDate    = (HTTPRequest.GetString("eDate").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("eDate").Trim()) : DateTime.Now;                                  //获得日期
                    sType    = HTTPRequest.GetInt("seType", -1);                                                                                                                          //统计类型:0=明细统计,1=总账统计
                    getYear  = bDate.ToString("yyyy");
                    oneMonth = Convert.ToInt32(bDate.ToString("MM"));
                    status   = HTTPRequest.GetInt("get_status", 0);


                    //获得科目选择,遍历科目
                    fsubject = HTTPRequest.GetString("subject_hd");
                    result   = fsubject.Split(',');



                    if (ispost)
                    {
                        for (int i = 0; i < result.Length - 1; i++)
                        {
                            //获得科目所选节点科目名称
                            fsubjectName = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));

                            //判断是否有子节点
                            tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                            if (tl)
                            {
                                dataclass = CostDetails.getTreeChildrenCount(result[i]); //找到子节点
                                string[] dclass = dataclass.Split(',');
                                for (int j = 0; j < dclass.Length - 1; j++)
                                {
                                    //获得月份
                                    mList         = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(dclass[j]), bDate, eDate);
                                    mdt           = mList.Copy();
                                    mdt.TableName = "m_" + j + c_count;
                                    mds.Tables.Add(mdt);


                                    //获得最大月
                                    maxList += CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(dclass[j]), bDate, eDate) + ",";
                                    //获得科目名称及编码
                                    objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(dclass[j]));

                                    //上年结转余额
                                    dList         = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(dclass[j]), status);
                                    ydt           = dList.Copy();
                                    ydt.TableName = "y_" + j + c_count;
                                    yds.Tables.Add(ydt);

                                    c_count++;
                                }
                                //--====================================月份合成表=============================================
                                msCost = mds.Tables[0].Clone();                        //创建新表 克隆以有表的架构
                                object[] objmArray = new object[msCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                for (int m = 0; m < mds.Tables.Count; m++)
                                {
                                    if (mds.Tables[m].Rows.Count > 0)
                                    {
                                        for (int n = 0; n < mds.Tables[m].Rows.Count; n++)
                                        {
                                            mds.Tables[m].Rows[n].ItemArray.CopyTo(objmArray, 0); //将表的一行的值存放数组中
                                            msCost.Rows.Add(objmArray);                           //将数组的值添加到新表中
                                        }
                                    }
                                }
                                DataView dv = new DataView(msCost);
                                dv.Sort = "oMonth";
                                nTable  = dv.ToTable(true, "oMonth");
                                //=====================上年结存余额合成一张表==============================
                                ysCost = yds.Tables[0].Clone();                       //创建新表 克隆以有表的架构
                                object[] objArray = new object[ysCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                for (int m = 0; m < yds.Tables.Count; m++)
                                {
                                    if (yds.Tables[m].Rows.Count > 0)
                                    {
                                        for (int n = 0; n < yds.Tables[m].Rows.Count; n++)
                                        {
                                            yds.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                            ysCost.Rows.Add(objArray);                           //将数组的值添加到新表中
                                        }
                                    }
                                }
                                if (ysCost.Rows.Count > 0)
                                {
                                    ycAccountMoney = Convert.ToDecimal(ysCost.Compute("sum(cAccountMoney)", "").ToString());
                                }

                                //====================找到科目中最大月========================================
                                string[] maxListArrary = maxList.Split(',');

                                for (int q = 0; q < maxListArrary.Length - 1; q++)
                                {
                                    if (maxListArrary[q].ToString() != "")
                                    {
                                        int mValue = Convert.ToInt32(maxListArrary[q].ToString());
                                        if (mValue > maxValue)
                                        {
                                            maxValue = mValue;
                                        }
                                    }
                                }
                                maxList = maxValue.ToString();
                            }
                            else
                            {
                                //上年结转余额
                                ysCost = CostDetails.getOccurrenceAndBalanceDetails(bDate, eDate, Convert.ToInt32(result[i]), status);
                                //获得月份
                                nTable = CostDetails.getMonthBySubjectAndDateTime(Convert.ToInt32(result[i]), bDate, eDate);
                                //获得最大月
                                maxList = CostDetails.getMonthBySubjectAndDateTime_Max(Convert.ToInt32(result[i]), bDate, eDate);
                                //获得科目名称及编码
                                objectName = CostDetails.getSubjectNameAndID(Convert.ToInt32(result[i]));
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-7-8"))
                {
                    Act           = HTTPRequest.GetString("Act").Trim();
                    tType         = HTTPRequest.GetInt("tType", 0);
                    feeType       = HTTPRequest.GetInt("feeType", 0);
                    get_direction = HTTPRequest.GetInt("get_direction", 0);//借贷方向
                    //获得科目节点选择
                    getTreeNode = HTTPRequest.GetString("get_treeNode").Trim();
                    string[] result = getTreeNode.Split(',');
                    if (ispost)
                    {
                        maori_ID = HTTPRequest.GetInt("maori_ID", 0);  //销售类型:0=购销;1=联营:2=直销
                        moriType = HTTPRequest.GetInt("moriType", 0);  //毛利统计类别
                        sDate    = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) : DateTime.Now;
                        stDate   = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) : DateTime.Now;



                        //1.费用统计_门店
                        if (tType == 1 && feeType == 0)
                        {
                            //获得科目名称
                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                DataTable dttp = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));

                                if (dttp != null)
                                {
                                    for (int pp = 0; pp < dttp.Rows.Count; pp++)
                                    {
                                        TreeName += dttp.Rows[0][0] + ",";
                                    }
                                }
                                else
                                {
                                    TreeName = "";
                                }
                            }
                            if (TreeName.Length > 2)
                            {
                                TreeName = TreeName.Substring(0, TreeName.Length - 1);
                            }
                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                //判断是否有子节点
                                bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                                if (tl)
                                {
                                    dataclass = CostDetails.getTreeChildrenCount(result[i]);

                                    string[] dclass = dataclass.Split(',');
                                    for (int j = 0; j < dclass.Length - 1; j++)
                                    {
                                        //获得科目信息
                                        kList = CostDetails.getTreeName(dclass[j].ToString());
                                        DataTable dt = kList.Copy();
                                        dt.TableName = "p_" + j + c_count;
                                        kDateSetName.Tables.Add(dt);

                                        //获得区域信息
                                        rList = CostDetails.getRegionList(get_direction, dclass[j].ToString(), sDate, stDate);

                                        DataTable rt = rList.Copy();
                                        rt.TableName = "o_" + j + c_count;
                                        rDateSet.Tables.Add(rt);
                                        c_count = c_count + 1;
                                    }

                                    DataTable newDataTable = rDateSet.Tables[0].Clone();             //创建新表 克隆以有表的架构
                                    object[]  objArray     = new object[newDataTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                    for (int m = 0; m < rDateSet.Tables.Count; m++)
                                    {
                                        if (rDateSet.Tables[m].Rows.Count > 0)
                                        {
                                            for (int n = 0; n < rDateSet.Tables[m].Rows.Count; n++)
                                            {
                                                rDateSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                                newDataTable.Rows.Add(objArray);                          //将数组的值添加到新表中
                                            }
                                        }
                                    }
                                    DataView dv = new DataView(newDataTable);
                                    dv.Sort = "RegionID";
                                    nTable  = dv.ToTable(true, "RegionID", "rName");
                                }
                                else
                                {
                                    //获得科目信息
                                    kList = CostDetails.getTreeName(result[i]);
                                    DataTable dt = kList.Copy();
                                    dt.TableName = "m_" + i;
                                    kDateSetName.Tables.Add(dt);

                                    //获得区域信息
                                    rList = CostDetails.getRegionList(get_direction, result[i], sDate, stDate);

                                    DataTable rt = rList.Copy();
                                    rt.TableName = "f_" + i;
                                    rDateSet.Tables.Add(rt);

                                    DataTable newDataTable = rDateSet.Tables[0].Clone();             //创建新表 克隆以有表的架构
                                    object[]  objArray     = new object[newDataTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                    for (int m = 0; m < rDateSet.Tables.Count; m++)
                                    {
                                        if (rDateSet.Tables[m].Rows.Count > 0)
                                        {
                                            for (int n = 0; n < rDateSet.Tables[m].Rows.Count; n++)
                                            {
                                                rDateSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                                newDataTable.Rows.Add(objArray);                          //将数组的值添加到新表中
                                            }
                                        }
                                    }
                                    DataView dv = new DataView(newDataTable);
                                    dv.Sort = "RegionID";
                                    nTable  = dv.ToTable(true, "RegionID", "rName");
                                }
                            }
                        }
                        //2.费用统计_科目
                        if (tType == 1 && feeType == 1)
                        {
                            //获得科目名称
                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                DataTable dttp = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));

                                if (dttp != null)
                                {
                                    for (int pp = 0; pp < dttp.Rows.Count; pp++)
                                    {
                                        TreeName += dttp.Rows[0][0] + ",";
                                    }
                                }
                                else
                                {
                                    TreeName = "";
                                }
                            }
                            if (TreeName.Length > 2)
                            {
                                TreeName = TreeName.Substring(0, TreeName.Length - 1);
                            }

                            //把选择的科目整理到dataset中
                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                className = CostDetails.getClassName(result[i]);

                                DataTable ddt = className.Copy();
                                ddt.TableName = "k" + i + c_count;
                                classDataSet.Tables.Add(ddt);
                                c_count++;
                            }
                            //把dataset中的datatable合并到一张表中
                            newTable = classDataSet.Tables[0].Clone();              //创建新表 克隆以有表的架构
                            object[] objArray = new object[newTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < classDataSet.Tables.Count; m++)
                            {
                                if (classDataSet.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < classDataSet.Tables[m].Rows.Count; n++)
                                    {
                                        classDataSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                        newTable.Rows.Add(objArray);                                  //将数组的值添加到新表中
                                    }
                                }
                            }
                        }
                        //3.费用统计_业务员
                        if (tType == 1 && feeType == 2)
                        {
                            //获得科目名称
                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                DataTable dttp = CostDetails.getObjectsListName(Convert.ToInt32(result[i]));

                                if (dttp != null)
                                {
                                    for (int pp = 0; pp < dttp.Rows.Count; pp++)
                                    {
                                        TreeName += dttp.Rows[0][0] + ",";
                                    }
                                }
                                else
                                {
                                    TreeName = "";
                                }
                            }
                            if (TreeName.Length > 2)
                            {
                                TreeName = TreeName.Substring(0, TreeName.Length - 1);
                            }

                            for (int i = 0; i < result.Length - 1; i++)
                            {
                                //判断是否有子节点
                                bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                                if (tl)
                                {
                                    dataclass = CostDetails.getTreeChildrenCount(result[i]);

                                    string[] dclass = dataclass.Split(',');
                                    for (int j = 0; j < dclass.Length - 1; j++)
                                    {
                                        //获得科目信息
                                        kList = CostDetails.getTreeName(dclass[j].ToString());
                                        DataTable dt = kList.Copy();
                                        dt.TableName = "p_" + j + c_count;
                                        kDateSetName.Tables.Add(dt);

                                        staffList = CostDetails.getStaffName(get_direction, sDate, stDate, Convert.ToInt32(dclass[j]));
                                        DataTable stl = staffList.Copy();
                                        stl.TableName = "qp_" + j + c_count;
                                        sDataSet.Tables.Add(stl);
                                        c_count++;
                                    }
                                }
                                else
                                {
                                    //获得科目信息
                                    kList = CostDetails.getTreeName(result[i]);
                                    DataTable dt = kList.Copy();
                                    dt.TableName = "m_" + i;
                                    kDateSetName.Tables.Add(dt);
                                    //获取业务员名称
                                    staffList = CostDetails.getStaffName(get_direction, sDate, stDate, Convert.ToInt32(result[i]));
                                    DataTable stl = staffList.Copy();
                                    stl.TableName = "we_" + i + c_count;
                                    sDataSet.Tables.Add(stl);
                                }
                            }
                            sCostTable = sDataSet.Tables[0].Clone();                  //创建新表 克隆以有表的架构
                            object[] objArray = new object[sCostTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                            for (int m = 0; m < sDataSet.Tables.Count; m++)
                            {
                                if (sDataSet.Tables[m].Rows.Count > 0)
                                {
                                    for (int n = 0; n < sDataSet.Tables[m].Rows.Count; n++)
                                    {
                                        sDataSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                        sCostTable.Rows.Add(objArray);                            //将数组的值添加到新表中
                                    }
                                }
                            }
                            DataView dv = new DataView(sCostTable);
                            dv.Sort = "StaffID";
                            tnTable = dv.ToTable(true, "StaffID", "sName");
                        }
                        //4.费用统计_赠品
                        if (tType == 1 && feeType == 3)
                        {
                            DataTable dt = CostDetails.getGiftCost(0, sDate, stDate);
                            if (dt.Rows.Count > 0)
                            {
                                gList_stor = dt.Copy();
                            }

                            gList = CostDetails.getGiftCost(0, sDate, stDate);
                        }

                        //1.毛利统计
                        if (tType == 0)
                        {
                            mList = CostDetails.getMoriOfRegion(moriType, 0, sDate, stDate);
                        }
                    }
                    else
                    {
                        if (Act.IndexOf("act") > -1)
                        {
                            sDate  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("bDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("bDate"))) : DateTime.Now;
                            stDate = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("eDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("eDate"))) : DateTime.Now;
                            DataTable dt = new DataTable();
                            DataSet   ds = new DataSet();
                            if (tType == 0)
                            {
                                moriType = HTTPRequest.GetInt("mType", 0);
                                mList    = CostDetails.getMoriOfRegion(moriType, 0, sDate, stDate);

                                dt = mList.Copy();
                                ds.Tables.Add(dt);
                                if (moriType == 0)
                                {
                                    ds.Tables[0].Columns[0].ColumnName = "区域名称";
                                }
                                if (moriType == 1)
                                {
                                    ds.Tables[0].Columns[0].ColumnName = "客户名称";
                                }
                                if (moriType == 2)
                                {
                                    ds.Tables[0].Columns[0].ColumnName = "业务员名称";
                                }
                                if (moriType == 3)
                                {
                                    ds.Tables[0].Columns[0].ColumnName = "品牌名称";
                                }
                                if (moriType == 4)
                                {
                                    ds.Tables[0].Columns[0].ColumnName = "单品名称";
                                }
                                ds.Tables[0].Columns[1].ColumnName = "销售金额";
                                ds.Tables[0].Columns[2].ColumnName = "成本金额";
                                ds.Tables[0].Columns[3].ColumnName = "利润金额";

                                CreateExcel(ds.Tables[0], "毛利统计_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
                            }
                            if (tType == 1)
                            {
                                DataSet dss = new DataSet();
                                if (feeType == 3)
                                {
                                    gList = CostDetails.getGiftCost(0, sDate, stDate);
                                    dt    = gList.Copy();
                                    dt.Columns.RemoveAt(0);
                                    dt.Columns.RemoveAt(0);
                                    dt.Columns.RemoveAt(1);
                                    ds.Tables.Add(dt);
                                    ds.Tables[0].Columns[0].ColumnName = "门店名称";
                                    ds.Tables[0].Columns[1].ColumnName = "商品名称";
                                    ds.Tables[0].Columns[2].ColumnName = "商品条码";
                                    ds.Tables[0].Columns[3].ColumnName = "赠品单数量";
                                    ds.Tables[0].Columns[4].ColumnName = "销售单数量";
                                    ds.Tables[0].Columns[5].ColumnName = "赠品金额";

                                    CreateExcel(ds.Tables[0], "赠品数据_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
                                }
                                else
                                {
                                    for (int i = 0; i < result.Length - 1; i++)
                                    {
                                        //判断是否有子节点
                                        bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                                        if (tl)
                                        {
                                            dataclass = CostDetails.getTreeChildrenCount(result[i]);

                                            string[] dclass = dataclass.Split(',');
                                            for (int j = 0; j < dclass.Length - 1; j++)
                                            {
                                                //客户
                                                if (feeType == 0)
                                                {
                                                    rList        = CostDetails.getCostOfStorehouse(-1, dclass[j].ToString(), get_direction, sDate, stDate);
                                                    dt           = rList.Copy();
                                                    dt.TableName = "k_" + j;
                                                    ds.Tables.Add(dt);

                                                    newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                    object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                    for (int m = 0; m < ds.Tables.Count; m++)
                                                    {
                                                        if (ds.Tables[m].Rows.Count > 0)
                                                        {
                                                            for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                            {
                                                                ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                                newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                            }
                                                        }
                                                    }
                                                }
                                                //科目
                                                if (feeType == 1)
                                                {
                                                    rList        = CostDetails.getClassCost(get_direction, dclass[j].ToString(), sDate, stDate);
                                                    dt           = rList.Copy();
                                                    dt.TableName = "c_" + j;
                                                    ds.Tables.Add(dt);

                                                    newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                    object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                    for (int m = 0; m < ds.Tables.Count; m++)
                                                    {
                                                        if (ds.Tables[m].Rows.Count > 0)
                                                        {
                                                            for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                            {
                                                                ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                                newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                            }
                                                        }
                                                    }
                                                }
                                                //业务员
                                                if (feeType == 2)
                                                {
                                                    rList        = CostDetails.getCostOfStaffID(get_direction, sDate, stDate, Convert.ToInt32(dclass[j].ToString()), -1);
                                                    dt           = rList.Copy();
                                                    dt.TableName = "y_" + j;
                                                    ds.Tables.Add(dt);

                                                    newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                    object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                    for (int m = 0; m < ds.Tables.Count; m++)
                                                    {
                                                        if (ds.Tables[m].Rows.Count > 0)
                                                        {
                                                            for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                            {
                                                                ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                                newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //客户
                                            if (feeType == 0)
                                            {
                                                rList        = CostDetails.getCostOfStorehouse(-1, result[i], get_direction, sDate, stDate);
                                                dt           = rList.Copy();
                                                dt.TableName = "k_" + i;
                                                ds.Tables.Add(dt);

                                                newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                for (int m = 0; m < ds.Tables.Count; m++)
                                                {
                                                    if (ds.Tables[m].Rows.Count > 0)
                                                    {
                                                        for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                        {
                                                            ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                            newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                        }
                                                    }
                                                }
                                            }
                                            //科目
                                            if (feeType == 1)
                                            {
                                                rList        = CostDetails.getClassCost(get_direction, result[i], sDate, stDate);
                                                dt           = rList.Copy();
                                                dt.TableName = "c_" + i;
                                                ds.Tables.Add(dt);

                                                newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                for (int m = 0; m < ds.Tables.Count; m++)
                                                {
                                                    if (ds.Tables[m].Rows.Count > 0)
                                                    {
                                                        for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                        {
                                                            ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                            newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                        }
                                                    }
                                                }
                                            }
                                            //业务员
                                            if (feeType == 2)
                                            {
                                                rList        = CostDetails.getCostOfStaffID(get_direction, sDate, stDate, Convert.ToInt32(result[i]), -1);
                                                dt           = rList.Copy();
                                                dt.TableName = "y_" + i;
                                                ds.Tables.Add(dt);

                                                newData = ds.Tables[0].Clone();                   //创建新表 克隆以有表的架构
                                                object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                                                for (int m = 0; m < ds.Tables.Count; m++)
                                                {
                                                    if (ds.Tables[m].Rows.Count > 0)
                                                    {
                                                        for (int n = 0; n < ds.Tables[m].Rows.Count; n++)
                                                        {
                                                            ds.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                                            newData.Rows.Add(obj);                         //将数组的值添加到新表中
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        dt = newData.Copy();
                                        //客户
                                        if (feeType == 0)
                                        {
                                            dt.Columns.RemoveAt(0);
                                            dss.Tables.Add(dt);
                                            dss.Tables[0].Columns[0].ColumnName = "客户名称";
                                            dss.Tables[0].Columns[1].ColumnName = "发生金额";
                                        }
                                        //科目
                                        if (feeType == 1)
                                        {
                                            dt.Columns.RemoveAt(0);
                                            dss.Tables.Add(dt);
                                            dss.Tables[0].Columns[0].ColumnName = "科目名称";
                                            dss.Tables[0].Columns[1].ColumnName = "发生金额";
                                        }
                                        //业务员
                                        if (feeType == 2)
                                        {
                                            dss.Tables.Add(dt);
                                            dss.Tables[0].Columns[0].ColumnName = "业务名称";
                                            dss.Tables[0].Columns[1].ColumnName = "发生金额";
                                        }
                                        CreateExcel(dss.Tables[0], "费用统计_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Exemplo n.º 9
0
        //费用统计——业务员
        public Decimal getCostOFStaff(string staffID)
        {
            get_direction = HTTPRequest.GetInt("get_direction", 0);//借贷方向
            sDate         = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) : DateTime.Now;
            stDate        = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) : DateTime.Now;
            getTreeNode   = HTTPRequest.GetString("get_treeNode");
            string[] result = getTreeNode.Split(',');
            sTest = 0;
            for (int i = 0; i < result.Length - 1; i++)
            {
                //判断是否有子节点
                bool    tl           = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                DataSet sCostDataSet = new DataSet();
                if (tl)
                {
                    dataclass = CostDetails.getTreeChildrenCount(result[i]);

                    string[] dclass = dataclass.Split(',');
                    for (int j = 0; j < dclass.Length - 1; j++)
                    {
                        sCostList = CostDetails.getCostOfStaffID(get_direction, sDate, stDate, Convert.ToInt32(dclass[j].ToString()), Convert.ToInt32(staffID));

                        DataTable ct = sCostList.Copy();

                        ct.TableName = "s_" + j + c_count;
                        sCostDataSet.Tables.Add(ct);
                        c_count = c_count + 1;
                    }
                    DataTable sCost = new DataTable();
                    sCost = sCostDataSet.Tables[0].Clone();              //创建新表 克隆以有表的架构
                    object[] objArray = new object[sCost.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < sCostDataSet.Tables.Count; m++)
                    {
                        if (sCostDataSet.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < sCostDataSet.Tables[m].Rows.Count; n++)
                            {
                                sCostDataSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                sCost.Rows.Add(objArray);                                     //将数组的值添加到新表中
                            }
                        }
                    }
                    try
                    {
                        if (get_direction == 0)
                        {
                            sTest += Convert.ToDecimal(sCost.Compute("sum(cdMoney)", "").ToString());
                        }
                        if (get_direction == 1)
                        {
                            sTest += Convert.ToDecimal(sCost.Compute("sum(cdMoneyB)", "").ToString());
                        }
                    }
                    catch (Exception e)
                    {
                        e.Message.ToString();
                    }
                }
                else
                {
                    sCostList = CostDetails.getCostOfStaffID(get_direction, sDate, stDate, Convert.ToInt32(result[i].ToString()), Convert.ToInt32(staffID));

                    if (sCostList.Rows.Count > 0)
                    {
                        if (get_direction == 0)
                        {
                            sTest += Convert.ToDecimal(sCostList.Compute("sum(cdMoney)", "").ToString());
                        }
                        if (get_direction == 1)
                        {
                            sTest += Convert.ToDecimal(sCostList.Compute("sum(cdMoneyB)", "").ToString());
                        }
                    }
                }
            }
            return(sTest);
        }
Exemplo n.º 10
0
        //2.费用统计——科目

        //获得科目费用统计
        public Decimal getCostOfClass(string kid)
        {
            get_direction = HTTPRequest.GetInt("get_direction", 0);//借贷方向

            sDate  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) : DateTime.Now;
            stDate = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) : DateTime.Now;

            //判断是否有子节点
            bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(kid));

            if (tl)
            {
                dataclass = CostDetails.getTreeChildrenCount(kid);
                string[] dclass = dataclass.Split(',');
                for (int j = 0; j < dclass.Length - 1; j++)
                {
                    classList = CostDetails.getClassCost(get_direction, dclass[j].ToString(), sDate, stDate);

                    DataTable ct = classList.Copy();
                    ct.TableName = "c_" + j + c_count;
                    rDateSet.Tables.Add(ct);
                    c_count = c_count + 1;
                }

                clist = rDateSet.Tables[0].Clone();                  //创建新表 克隆以有表的架构
                object[] objArray = new object[clist.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                for (int m = 0; m < rDateSet.Tables.Count; m++)
                {
                    if (rDateSet.Tables[m].Rows.Count > 0)
                    {
                        for (int n = 0; n < rDateSet.Tables[m].Rows.Count; n++)
                        {
                            rDateSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                            clist.Rows.Add(objArray);                                 //将数组的值添加到新表中
                        }
                    }
                    else
                    {
                        test = 0;
                    }
                }
                try
                {
                    if (get_direction == 0)
                    {
                        test = Convert.ToDecimal(clist.Compute("sum(cdMoney)", "").ToString());
                    }
                    if (get_direction == 1)
                    {
                        test = Convert.ToDecimal(clist.Compute("sum(cdMoneyB)", "").ToString());
                    }
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                }
            }
            else
            {
                classList = CostDetails.getClassCost(get_direction, kid, sDate, stDate);
                if (classList.Rows.Count > 0)
                {
                    if (get_direction == 0)
                    {
                        test = Convert.ToDecimal(classList.Compute("sum(cdMoney)", "").ToString());
                    }
                    if (get_direction == 1)
                    {
                        test = Convert.ToDecimal(classList.Compute("sum(cdMoneyB)", "").ToString());
                    }
                }
                else
                {
                    test = 0;
                }
            }
            return(test);
        }
Exemplo n.º 11
0
        //获得门店的费用
        public DataSet getCostOfStorehouse(string sid)
        {
            get_direction = HTTPRequest.GetInt("get_direction", 0);//借贷方向

            sDate  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("sDate"))) : DateTime.Now;
            stDate = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("stDate"))) : DateTime.Now;


            getTreeNode = HTTPRequest.GetString("get_treeNode");
            string[] result = getTreeNode.Split(',');
            for (int i = 0; i < result.Length - 1; i++)
            {
                //判断是否有子节点
                bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(result[i]));
                if (tl)
                {
                    dataclass = CostDetails.getTreeChildrenCount(result[i]);

                    string[] dclass = dataclass.Split(',');
                    for (int j = 0; j < dclass.Length - 1; j++)
                    {
                        cost_storehouse_list = CostDetails.getCostOfStorehouse(Convert.ToInt32(sid), dclass[j].ToString(), get_direction, sDate, stDate);
                        DataTable ct = cost_storehouse_list.Copy();

                        ct.TableName = "p_" + j + "_" + c_count + count;
                        SdateSetCost.Tables.Add(ct);
                        c_count = c_count + 1;
                        count   = count + 1;
                    }
                    newData = SdateSetCost.Tables[0].Clone();         //创建新表 克隆以有表的架构
                    object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < SdateSetCost.Tables.Count; m++)
                    {
                        if (SdateSetCost.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < SdateSetCost.Tables[m].Rows.Count; n++)
                            {
                                SdateSetCost.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                newData.Rows.Add(obj);                                   //将数组的值添加到新表中
                            }
                        }
                    }

                    try
                    {
                        test = Convert.ToDecimal(newData.Compute("sum(appendCost)", "").ToString());
                    }
                    catch (Exception e)
                    {
                        e.Message.ToString();
                    }
                }
                else
                {
                    cost_storehouse_list = CostDetails.getCostOfStorehouse(Convert.ToInt32(sid), result[i], get_direction, sDate, stDate);
                    DataTable ct = cost_storehouse_list.Copy();

                    ct.TableName = "j_" + i + c_count;
                    SdateSetCost.Tables.Add(ct);
                    c_count = c_count + 1;

                    newData = SdateSetCost.Tables[0].Clone();         //创建新表 克隆以有表的架构
                    object[] obj = new object[newData.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < SdateSetCost.Tables.Count; m++)
                    {
                        if (SdateSetCost.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < SdateSetCost.Tables[m].Rows.Count; n++)
                            {
                                SdateSetCost.Tables[m].Rows[n].ItemArray.CopyTo(obj, 0); //将表的一行的值存放数组中
                                newData.Rows.Add(obj);                                   //将数组的值添加到新表中
                            }
                        }
                    }

                    try
                    {
                        test = Convert.ToDecimal(newData.Compute("sum(appendCost)", "").ToString());
                    }
                    catch (Exception e)
                    {
                        e.Message.ToString();
                    }
                }
            }
            return(SdateSetCost);
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("7-2-3-8"))
                {
                    selectID  = HTTPRequest.GetInt("aid", 0);
                    bDate     = Convert.ToDateTime(HTTPRequest.GetString("bDate"));
                    eDate     = Convert.ToDateTime(HTTPRequest.GetString("eDate"));
                    staffName = HTTPRequest.GetString("staffName");
                    staffID   = HTTPRequest.GetInt("staffID", 0);
                    treeNode  = HTTPRequest.GetString("kID");

                    string[] kList_Arrary = treeNode.Split(',');
                    for (int i = 0; i < kList_Arrary.Length - 1; i++)
                    {
                        //判断是否有子节点
                        bool tl = DataClass.ExistsFeesSubjectClassChild(Convert.ToInt32(kList_Arrary[i]));
                        if (tl)
                        {
                            dataclass = CostDetails.getTreeChildrenCount(kList_Arrary[i]);
                            string[] dclass = dataclass.Split(',');
                            for (int j = 0; j < dclass.Length - 1; j++)
                            {
                                sList = CostDetails.getCostOfStaffDetails(selectID, bDate, eDate, staffID, dclass[j].ToString());

                                DataTable dt = sList.Copy();
                                dt.TableName = "p" + j + c_count;
                                sDateSet.Tables.Add(dt);
                                c_count++;
                            }
                        }
                        else
                        {
                            sList = CostDetails.getCostOfStaffDetails(selectID, bDate, eDate, staffID, kList_Arrary[i].ToString());
                            DataTable dt = sList.Copy();
                            dt.TableName = "f" + i + c_count;
                            sDateSet.Tables.Add(dt);
                            c_count++;
                        }
                    }
                    //把dataset中的datatable合并到一张表中
                    newTable = sDateSet.Tables[0].Clone();                  //创建新表 克隆以有表的架构
                    object[] objArray = new object[newTable.Columns.Count]; //定义与表列数相同的对象数组 存放表的一行的值
                    for (int m = 0; m < sDateSet.Tables.Count; m++)
                    {
                        if (sDateSet.Tables[m].Rows.Count > 0)
                        {
                            for (int n = 0; n < sDateSet.Tables[m].Rows.Count; n++)
                            {
                                sDateSet.Tables[m].Rows[n].ItemArray.CopyTo(objArray, 0); //将表的一行的值存放数组中
                                newTable.Rows.Add(objArray);                              //将数组的值添加到新表中
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }