예제 #1
0
        /// <summary>
        /// 获取充值参数信息
        /// </summary>
        /// <returns></returns>
        public APIRst GetFrPay()
        {
            APIRst rst = new APIRst();

            try
            {
                var dt       = bll.GetFrPay();
                var dtsource = from s1 in dt.AsEnumerable()
                               select new
                {
                    frpay       = CommFunc.ConvertDBNullToFloat(s1["Price"]),
                    fCoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    vRdChrgType = CommFunc.ConvertDBNullToInt32(s1["ChrgType"])
                };
                rst.data = dtsource.ToList();
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取充值参数信息错误:" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
예제 #2
0
파일: RdcMethod.cs 프로젝트: ZQuanLi/Test
        public int WriteVar(string lpszDbVarName, string dataVal)
        {
            float dd = CommFunc.ConvertDBNullToFloat(dataVal);

            float[] arr       = new float[] { dd };
            IntPtr  structPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(4);

            System.Runtime.InteropServices.Marshal.Copy(arr, 0, structPtr, 1);
            int rst = RdcFunc.RDC_WriteVarByName(this.Handle.Value, lpszDbVarName, structPtr);

            System.Runtime.InteropServices.Marshal.FreeHGlobal(structPtr);
            return(rst);
        }
예제 #3
0
        /// <summary>
        /// 充值参数
        /// </summary>
        /// <param name="Price">电量单价</param>
        /// <param name="CoName">售电票据单位名称</param>
        /// <param name="ChrgType">付费类型</param>
        /// <returns></returns>
        public int FSetFrPay(float Price, string CoName, int ChrgType)
        {
            int           cc     = 0;
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("select Price from syscont where Ledger=@Ledger");
            object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger });
            float  pp  = CommFunc.ConvertDBNullToFloat(obj);

            if (Price != pp)
            {
                strSql.Clear();
                strSql.Append("START TRANSACTION;");
                strSql.Append("insert into v2_info(`Ledger`, `Co_id`, `Module_id`, `ModuleAddr`, `Fun_id`, `Hist_id`, `YT_id`,");
                strSql.Append("`BeginVal`, `FirstVal`, `LastVal`, `MinVal`, `MaxVal`, `FirstTime`, `LastTime`, `MinTime`, `MaxTime`, `DataCfg`,");
                strSql.Append("`FirstVal1st`,`FirstVal2nd`, `FirstVal3rd`, `FirstVal4th`, `Val1st`, `Val2nd`, `Val3rd`, `Val4th`, `ChargVal`, `RdVal`, `DebtTime`,");
                strSql.Append("`Create_by`, `Create_dt`, `Update_by`, `Update_dt`, `BaseVal`, `RaVal`, `InVal`, `Remark`)");
                strSql.Append(" select a.Ledger,a.Co_id,a.Module_id,a.ModuleAddr,a.Fun_id,ifnull(max.Hist_id,0)+1,a.YT_id,");
                strSql.Append(" a.BeginVal,a.FirstVal,a.LastVal,a.MinVal,a.MaxVal,a.FirstTime,a.LastTime,a.MinTime,a.MaxTime,a.DataCfg,");
                strSql.Append(" a.FirstVal1st,a.FirstVal2nd,a.FirstVal3rd,a.FirstVal4th,a.Val1st,a.Val2nd,a.Val3rd,a.Val4th,a.ChargVal,a.RdVal,DebtTime,");
                strSql.Append(" @SysUid, now(), @SysUid, now(), a.BaseVal,a.RaVal,a.InVal,CONCAT('改单价:',b.Price,'->',@Price)");
                strSql.Append(" from v2_info as a inner join syscont as b on a.Ledger=b.Ledger");
                strSql.Append(" inner join vp_funinfo as fun on a.Ledger=fun.Ledger and a.Co_id = fun.Co_id and a.Module_id = fun.Module_id and a.ModuleAddr = fun.ModuleAddr and a.Fun_id = fun.Fun_id");
                strSql.Append(" left join (select Ledger,Co_id,Module_id,ModuleAddr,Fun_id,max(Hist_id)as Hist_id from v2_info group by Ledger,Co_id,Module_id,ModuleAddr,Fun_id) as max");
                strSql.Append(" on a.Ledger=max.Ledger and a.Co_id = max.Co_id and a.Module_id = max.Module_id and a.ModuleAddr = max.ModuleAddr and a.Fun_id = max.Fun_id");
                strSql.Append(" where a.Ledger=@Ledger and a.Hist_id=0 and fun.FunType='E' and a.RdVal!=0;");
                /*补差额电度*/
                strSql.Append("update vp_v2info as a inner join syscont as b on a.Ledger=b.Ledger");
                strSql.Append(" inner join vp_funinfo as fun on a.Ledger=fun.Ledger and a.Co_id = fun.Co_id and a.Module_id = fun.Module_id and a.ModuleAddr = fun.ModuleAddr and a.Fun_id = fun.Fun_id");
                strSql.Append(" set a.ChargVal = (a.ChargVal - a.RdVal) + round(round(a.RdVal*b.Price,2)/@Price,2)");
                strSql.Append(" where a.Ledger=@Ledger and a.Hist_id=0 and fun.FunType='E' and a.RdVal!=0;");
                strSql.Append("update syscont set Price = @Price where Ledger=@Ledger;");
                //
                strSql.Append("COMMIT;");
                cc = cc + SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Price = Price, SysUid = this.SysUid });
            }
            //
            strSql.Clear();
            strSql.Append("update syscont set CoName = @CoName ,ChrgType=@ChrgType where Ledger=@Ledger");
            cc = cc + SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Price = Price, CoName = CoName, ChrgType = ChrgType });
            return(cc);
        }