Ejemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Parse("2012-2-21");
            int zd = 3;//麻柳沱
            int n = 12;//枪数目
            List<ZDGAS.gunSum> gunS = new List<ZDGAS.gunSum>();
            List<ZDGAS.gunGas> gunG = new List<ZDGAS.gunGas>();
            DAL dal = new DAL();
            for (int i = 0; i < n; i++)
            {
                ZDGAS.gunSum gs = new ZDGAS.gunSum();
                ZDGAS.gunGas gg = new ZDGAS.gunGas();
                string SQL1 = ZDGAS.getBZstarttime(dt, i + 1, zd, false, true);
                string SQL2 = ZDGAS.getBZendtime(dt, i + 1, zd, false, true);
                DataTable dt1 = dal.RunSqlDataTable(SQL1);
                DataTable dt2 = dal.RunSqlDataTable(SQL2);

                gs.枪号 = i + 1; gg.枪号 = i + 1;
                gg.站点 = zd;

                if (dt1.Rows.Count <= 0)
                {
                    gs.错误信息 = "未接班";
                    gg.接班时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    gg.接班时间 = dt1.Rows[0]["time"].ToString();
                    gs.停止起 = Convert.ToDouble(dt1.Rows[0]["stopsumgas"].ToString());
                    gs.接班总气量 = Convert.ToDouble(dt1.Rows[0]["SuMGas"].ToString());
                    gs.接班总金额 = Convert.ToDouble(dt1.Rows[0]["SuMMOney"].ToString());
                }

                if (dt2.Rows.Count <= 0)
                {
                    gs.错误信息 = "未交班";
                    gg.交班时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    gg.交班时间 = dt2.Rows[0]["time"].ToString();
                    gs.停止止 = Convert.ToDouble(dt1.Rows[0]["stopsumgas"].ToString());
                    gs.交班总气量 = Convert.ToDouble(dt2.Rows[0]["SuMGas"].ToString());
                    gs.交班总金额 = Convert.ToDouble(dt2.Rows[0]["SuMMOney"].ToString());
                }

                gg.FF_计算数据();
                gs.系统班累气量 = Math.Round(gg.记帐刷卡气量 + gg.现金消费气量 + gg.预购刷卡气量, 2);
                gs.系统班累金额 = Math.Round(gg.记帐刷卡金额 + gg.现金消费金额 + gg.预购刷卡金额, 2);

                gs.FF_计算数值();

                if (gs.错误信息 != "")
                {
                    switch (gs.错误信息)
                    {
                        case "未交班": gg.交班时间 = "未交班"; break;
                        case "未接班": gg.接班时间 = "未接班"; break;
                        default:
                            break;
                    }
                }

                gunG.Add(gg);
                gunS.Add(gs);

            }
            //string dataFh = "{\"top\":头对象,\"sum\":累计对象,\"gas\":销售对象,\"gasjz\":记帐对象}";

            string fotS1 = "[{\"交班时间\":\"合计:\",\"现金消费气量\":{0},\"现金消费金额\":{1},\"记帐刷卡气量\":{2},\"记帐刷卡金额\":{3},\"预购刷卡气量\":{4},\"预购刷卡金额\":{5}}]";
            //string  fotS1 = "{{0}-{1}-{2}-{3}-{4}-{5}}";
            fotS1 = fotS1.Replace("{0}", "11111");
            fotS1 = fotS1.Replace("{1}", "22222");
            fotS1 = fotS1.Replace("{2}", "3333");
            fotS1 = fotS1.Replace("{3}", "4444");
            fotS1 = fotS1.Replace("{4}", "5555");
            fotS1 = fotS1.Replace("{5}", "6666");

            string text = "{\"total\":12,\"rows\":行数据对象,\"footer\":合计对象}";
            text = text.Replace("行数据对象", Json.Json_转换到json(gunG));
            text = text.Replace("合计对象", fotS1);

            string Txt = text + "\r\n\r\n";
            Txt += "{\"total\":12,\"rows\":" + Json.Json_转换到json(gunS) + "}";
            textBox1.Text = Txt;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取的每班气量
        /// </summary>
        /// <param name="context"></param>
        public void getBZgas(HttpContext context)
        {
            gastop top = new gastop();
            bool ISyeban = Convert.ToBoolean(context.Request["bbyb"]);

            DateTime dt = DateTime.Parse(context.Request["date"]); //日期
            int zd = Convert.ToInt32(context.Request["zd"].ToString());//站点
            int n = 0;
            int bz = 0;

            string topbz = ISyeban ? "夜班" : "白班";
            string topbt = "";

            switch (zd)
            {//初始化 枪数目
                case 2: n = 6; bz = ZDGAS.getBZno(dt, zd, ISyeban); topbt = "南高CNG站"; break;
                case 3: n = 12; bz = ZDGAS.getBZno(dt, zd, ISyeban); topbt = "江阳西路CNG站"; break;
                case 4: n = 4; bz = ZDGAS.getBZno(dt); topbt = "麻柳沱CNG站"; break;
                default:
                    break;
            }
            top.班组 = bz.ToString() + "班" + topbz;
            top.日期 = dt.ToString("yyyy年MM月dd日");
            topbt += ":  " + dt.ToString("yyyy年MM月dd日 dddd") + "  " + top.班组;

            List<ZDGAS.gunSum> gunS = new List<ZDGAS.gunSum>();
            List<ZDGAS.gunGas> gunG = new List<ZDGAS.gunGas>();
            DAL dal = new DAL();
            for (int i = 0; i < n; i++) //计算每枪数据
            {
                ZDGAS.gunSum gs = new ZDGAS.gunSum();
                ZDGAS.gunGas gg = new ZDGAS.gunGas();
                string SQL1 = "", SQL2 = "";
                if (zd == 4)
                {
                    SQL1 = ZDGAS.getBZstarttime(dt, i + 1, true);
                    SQL2 = ZDGAS.getBZendtime(dt, i + 1, true);
                }
                else
                {
                    SQL1 = ZDGAS.getBZstarttime(dt, i + 1, zd, ISyeban, true);
                    SQL2 = ZDGAS.getBZendtime(dt, i + 1, zd, ISyeban, true);
                }

                DataTable dt1 = dal.RunSqlDataTable(SQL1);//接班数据
                DataTable dt2 = dal.RunSqlDataTable(SQL2);//交班数据

                gs.枪号 = i + 1; gg.枪号 = i + 1;
                gg.站点 = zd;

                if (dt1.Rows.Count <= 0)
                {
                    gs.错误信息 = "未接班";
                    gg.接班时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    gg.接班时间 = dt1.Rows[0]["time"].ToString();
                    gs.停止起 = Convert.ToDouble(dt1.Rows[0]["stopsumgas"].ToString());
                    gs.接班总气量 = Convert.ToDouble(dt1.Rows[0]["SuMGas"].ToString());
                    gs.接班总金额 = Convert.ToDouble(dt1.Rows[0]["SuMMOney"].ToString());
                }

                if (dt2.Rows.Count <= 0)
                {
                    gs.错误信息 += "未交班";
                    gg.交班时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    gg.交班时间 = dt2.Rows[0]["time"].ToString();
                    gs.停止止 = Convert.ToDouble(dt2.Rows[0]["stopsumgas"].ToString());
                    gs.交班总气量 = Convert.ToDouble(dt2.Rows[0]["SuMGas"].ToString());
                    gs.交班总金额 = Convert.ToDouble(dt2.Rows[0]["SuMMOney"].ToString());
                }

                gg.FF_计算数据();
                gs.系统班累气量 = Math.Round(gg.记帐刷卡气量 + gg.现金消费气量 + gg.预购刷卡气量, 2);
                gs.系统班累金额 = Math.Round(gg.记帐刷卡金额 + gg.现金消费金额 + gg.预购刷卡金额, 2);

                gs.FF_计算数值();

                if (gs.错误信息 != "")
                {
                    switch (gs.错误信息)
                    {
                        case "未交班": gg.交班时间 = "未交班"; break;
                        case "未接班": gg.接班时间 = "未接班"; break;
                        case "未接班未交班": gg.接班时间 = "未接班"; gg.交班时间 = "未交班"; break;
                        default:
                            break;
                    }
                }
                gunG.Add(gg);
                gunS.Add(gs);
            }
            string dataFh = "{\"yxdx\":\"影响对象\",\"dbsj\":当班数据,\"top\":头对象,\"sum\":累计对象,\"gas\":销售对象,\"gasjz\":记帐对象,\"btdx\":\"标题对象\",\"char1\":图表对象1,\"char2\":图表对象2,\"dqBZ\":\"【当前班组】\"} ";// 最后返回的 json对象
            string rowtext = "{\"total\":12,\"rows\":行数据对象,\"footer\":脚对象}";
            string temp = "";

            // 统计记帐单位数据
            string SQL = "SELECT [记账单位名称] as 记帐单位,[刷卡记账气量] as 刷卡,[手工记账气量] as 手工 FROM [CNGQT].[dbo].[SC_记账明细] where 站点=" + zd.ToString() + " AND 班组=" + bz.ToString() + " AND 日期='" + dt.ToShortDateString() + "'";
            DataTable jzdw = dal.RunSqlDataTable(SQL);
            double[] jz = new double[3];
            foreach (DataRow i in jzdw.Rows) //统计合计数
            {
                jz[0] += Convert.ToDouble(i["刷卡"].ToString());
                jz[1] += Convert.ToDouble(i["手工"].ToString());
            }
            string jdx = Json.TableToJson(jzdw);
            if (jdx == "") { jdx = "[]"; }

            temp = rowtext.Replace("行数据对象", jdx);
            temp = temp.Replace("脚对象", string.Format("[{{\"记帐单位\":\"合计:\",\"刷卡\":{0:f},\"手工\":{1:f} }}]", jz[0], jz[1]));
            dataFh = dataFh.Replace("记帐对象", temp);//生成 记帐对象json

            double[] z1 = new double[6];
            foreach (ZDGAS.gunGas i in gunG)//计算销售合计值
            {
                z1[0] += i.现金消费气量;
                z1[1] += i.现金消费金额;
                z1[2] += i.记帐刷卡气量;
                z1[3] += i.记帐刷卡金额;
                z1[4] += i.预购刷卡气量;
                z1[5] += i.预购刷卡金额;
            }
            double[] z2 = new double[12];
            foreach (ZDGAS.gunSum i in gunS)//计算累计合计值
            {
                z2[0] += i.接班总气量;
                z2[1] += i.接班总金额;
                z2[2] += i.交班总气量;
                z2[3] += i.交班总金额;
                z2[4] += i.机器班累气量;
                z2[5] += i.机器班累金额;
                z2[6] += i.系统班累气量;
                z2[7] += i.系统班累金额;
                z2[8] += i.误差;
                z2[9] += i.停止起;
                z2[10] += i.停止止;
                z2[11] += i.停止总累;
            }
            string foot2 = string.Format("[{{\"枪号\":\"合计:\",\"接班总气量\":{0:f},\"接班总金额\":{1:f},\"交班总气量\":{2:f},\"交班总金额\":{3:f},\"机器班累气量\":{4:f},\"机器班累金额\":{5:f},\"系统班累气量\":{6:f},\"系统班累金额\":{7:f},\"误差\":{8:f},\"停止起\":{9:f},\"停止止\":{10:f},\"停止总累\":{11:f} }}]", z2[0], z2[1], z2[2], z2[3], z2[4], z2[5], z2[6], z2[7], z2[8], z2[9], z2[10], z2[11]);
            string foot1 = string.Format("[{{\"交班时间\":\"合计:\",\"现金消费气量\":{0:f},\"现金消费金额\":{1:f},\"记帐刷卡气量\":{2:f},\"记帐刷卡金额\":{3:f},\"预购刷卡气量\":{4:f},\"预购刷卡金额\":{5:f} }}]", z1[0], z1[1], z1[2], z1[3], z1[4], z1[5]);
            //行数据

            temp = rowtext.Replace("行数据对象", Json.Json_转换到json(gunG));
            temp = temp.Replace("脚对象", foot1);
            dataFh = dataFh.Replace("销售对象", temp);//生成销售对象json

            temp = rowtext.Replace("行数据对象", Json.Json_转换到json(gunS));
            temp = temp.Replace("脚对象", foot2);
            dataFh = dataFh.Replace("累计对象", temp);

            //头对象
            top.交班底数 = z2[2];
            top.接班底数 = z2[0];
            top.生产气量 = z2[2] - z2[0];
            top.预购刷卡气量 = z1[4];
            top.刷卡记帐气量 = jz[0];
            top.手工记帐气量 = jz[1];
            SQL = "SELECT [报损气量],[现金消费金额]  FROM [CNGQT].[dbo].[SC_班销售统计] where 站点=" + zd.ToString() + " AND 班组=" + bz.ToString() + " AND 日期='" + dt.ToShortDateString() + "'";
            string[] xfsz = dal.RunSqlStrings(SQL);
            if (xfsz == null)
            {
                top.报损气量 = 0;
                top.交款金额 = 0;
            }
            else
            {
                top.报损气量 = Convert.ToDouble(xfsz[0]);
                top.交款金额 = Convert.ToDouble(xfsz[1]);
            }

            top.交款气量 = top.生产气量 - top.预购刷卡气量 - top.刷卡记帐气量 - top.手工记帐气量 - top.报损气量;

            temp = "{{ \"total\": 1, \"rows\": [{{ \"班组\": \"{0}\",\"日期\":\"{1}\",\"交班底数\":{2:f},\"接班底数\":{3:f},\"生产气量\":{4:f},\"预购刷卡气量\":{5:f},\"刷卡记帐气量\":{6:f},\"手工记帐气量\":{7:f},\"报损气量\":{8:f},\"交款气量\":{9:f},\"交款金额\":\"{10:C2}\" }}]}}";
            temp = string.Format(temp, top.班组, top.日期, top.交班底数, top.接班底数, top.生产气量, top.预购刷卡气量, top.刷卡记帐气量, top.手工记帐气量, top.报损气量, top.交款气量, top.交款金额);
            dataFh = dataFh.Replace("头对象", temp);
            dataFh = dataFh.Replace("标题对象", topbt);

            temp = getGasSc(dt, zd, bz, ISyeban, top.生产气量);
            dataFh = dataFh.Replace("当班数据", temp);

            temp = getGastubiao(dt, zd, bz, ISyeban);
            dataFh = dataFh.Replace("图表对象1", temp);

            temp = string.Format("{{ \"val\":[ {0:f},{1:f},{2:f},{3:f} ],\"sum\":{4:f} }}", top.交款气量, top.预购刷卡气量, top.刷卡记帐气量 + top.手工记帐气量, top.报损气量, top.生产气量);
            dataFh = dataFh.Replace("图表对象2", temp);

            temp = getGasStop(dt, zd, bz, ISyeban);
            dataFh = dataFh.Replace("影响对象", temp);
            dataFh = dataFh.Replace("【当前班组】", bz.ToString());

            Sys.DebugMes(dataFh);
            context.Response.Write(dataFh);
        }