Exemple #1
0
        private DeviceHeadEntity getDeviceHeadEntity()
        {
            DeviceHeadEntity deviceHeadEntity = new DeviceHeadEntity();

            deviceHeadEntity.DeviceIdFlag         = 1U;
            deviceHeadEntity.BatteryStatus        = 0U;
            deviceHeadEntity.ConsumeFlag          = 0U;
            deviceHeadEntity.ReplaceCardFlag      = 0U;
            deviceHeadEntity.ValveStatus          = 0U;
            deviceHeadEntity.ValveCloseStatusFlag = 0U;
            deviceHeadEntity.RefundFlag           = 0U;
            deviceHeadEntity.ChangeMeterFlag      = 0U;
            deviceHeadEntity.OverZeroFlag         = 0U;
            deviceHeadEntity.ForceStatus          = 0U;

            return(deviceHeadEntity);
        }
        // Token: 0x060003EC RID: 1004 RVA: 0x00035448 File Offset: 0x00033648
        private void writeCard()
        {
            ConsumeCardEntity consumeCardEntity = new ConsumeCardEntity();
            CardHeadEntity    cardHeadEntity    = new CardHeadEntity();

            cardHeadEntity.parseEntity(ConvertUtils.ToUInt32(this.lastPursuitInfo["userHead"].ToString()));
            consumeCardEntity.CardHead = cardHeadEntity;
            DeviceHeadEntity deviceHeadEntity = new DeviceHeadEntity();

            deviceHeadEntity.parseEntity(ConvertUtils.ToUInt32(this.lastPursuitInfo["deviceHead"].ToString()));
            deviceHeadEntity.ReplaceCardFlag = 1U;
            if (this.forceStatus_CB.SelectedIndex <= 0)
            {
                deviceHeadEntity.ForceStatus = 0U;
            }
            else
            {
                deviceHeadEntity.ForceStatus = (uint)this.forceStatus_CB.SelectedIndex;
            }
            consumeCardEntity.DeviceHead          = deviceHeadEntity;
            consumeCardEntity.UserId              = ConvertUtils.ToUInt32(this.lastPursuitInfo["userId"].ToString());
            consumeCardEntity.TotalRechargeNumber = ConvertUtils.ToUInt32(this.lastPursuitInfo["pursuitNum"].ToString());
            uint num = ConvertUtils.ToUInt32(this.lastPursuitInfo["operateType"].ToString());

            if (num == 3U)
            {
                uint num2 = ConvertUtils.ToUInt32(this.lastPursuitInfo["consumeTimes"].ToString());
                consumeCardEntity.ConsumeTimes = num2 - 1U;
            }
            else
            {
                consumeCardEntity.ConsumeTimes = ConvertUtils.ToUInt32(this.lastPursuitInfo["consumeTimes"].ToString());
            }
            if (num == 4U)
            {
                consumeCardEntity.DeviceHead.RefundFlag   = 1U;
                consumeCardEntity.DeviceHead.ConsumeFlag  = 1U;
                consumeCardEntity.DeviceHead.DeviceIdFlag = 1U;
            }
            long num3;

            if (!MainForm.DEBUG)
            {
                num3 = (long)this.parentForm.writeCard(consumeCardEntity.getEntity());
                if (num3 != 0L)
                {
                    WMMessageBox.Show(this, "写卡失败!");
                    return;
                }
            }
            DateTime now      = DateTime.Now;
            TimeSpan timeSpan = now - WMConstant.DT1970;
            long     num4     = (long)timeSpan.TotalSeconds;

            this.db.AddParameter("time", ConvertUtils.ToInt64(timeSpan.TotalSeconds).ToString());
            this.db.AddParameter("userHead", ConvertUtils.ToInt64(consumeCardEntity.CardHead.getEntity()).ToString());
            this.db.AddParameter("deviceHead", ConvertUtils.ToInt64(consumeCardEntity.DeviceHead.getEntity()).ToString());
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.AddParameter("pursuitNum", ConvertUtils.ToInt64(consumeCardEntity.TotalRechargeNumber).ToString());
            this.db.AddParameter("unitPrice", "0");
            this.db.AddParameter("totalNum", ConvertUtils.ToInt64(consumeCardEntity.TotalReadNum).ToString());
            this.db.AddParameter("consumeTimes", ConvertUtils.ToInt64(consumeCardEntity.ConsumeTimes).ToString());
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("operateType", "2");
            this.db.AddParameter("totalPayNum", "0");
            this.db.AddParameter("permanentUserId", this.lastPursuitInfo["permanentUserId"].ToString());
            num3 = this.db.ExecuteNonQueryAndReturnLastInsertRowId("INSERT INTO userCardLog(time, userHead, deviceHead, userId, pursuitNum, unitPrice, totalNum, consumeTImes, operator, operateType, totalPayNum, permanentUserId) VALUES (@time, @userHead, @deviceHead, @userId, @pursuitNum, @unitPrice, @totalNum, @consumeTImes, @operator, @operateType, @totalPayNum, @permanentUserId)");
            uint num5 = MainForm.DEBUG ? 123U : this.parentForm.getCardID();

            this.db.AddParameter("cardId", string.Concat(num5));
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.ExecuteNonQuery("UPDATE cardData SET cardId=@cardId WHERE userId=@userId");
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.AddParameter("userName", this.nameTB.Text);
            this.db.AddParameter("pursuitNum", "0");
            this.db.AddParameter("unitPrice", "0");
            this.db.AddParameter("totalPrice", this.replaceCardFeeTB.Text.Trim());
            this.db.AddParameter("payType", "2");
            this.db.AddParameter("dealType", "0");
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("operateTime", string.Concat(num4));
            this.db.AddParameter("userCardLogId", string.Concat(num3));
            this.db.AddParameter("permanentUserId", this.lastPursuitInfo["permanentUserId"].ToString());
            this.db.AddParameter("realPayNum", ConvertUtils.ToDouble(this.realPayNumTB.Text.Trim()).ToString("0.00") ?? "");
            this.db.ExecuteNonQuery("INSERT INTO payLogTable(userId,userName,pursuitNum,unitPrice,totalPrice,payType,dealType,operator,operateTime,userCardLogId, permanentUserId, realPayNum) VALUES (@userId,@userName,@pursuitNum,@unitPrice,@totalPrice,@payType,@dealType,@operator,@operateTime,@userCardLogId, @permanentUserId, @realPayNum)");
            this.clearAllBtn_Click(new object(), new EventArgs());
            WMMessageBox.Show(this, "补卡完成!");
        }
        // Token: 0x060003DE RID: 990 RVA: 0x00033378 File Offset: 0x00031578
        private void readCardBtn_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (parentForm == null)
            {
                return;
            }
            ConsumeCardEntity consumeCardEntity = parseCard(true);

            if (consumeCardEntity == null)
            {
                return;
            }
            if (consumeCardEntity.DeviceHead.ConsumeFlag == 0)
            {
                flag = false;
            }
            string   text = string.Concat(consumeCardEntity.UserId);
            DateTime now  = DateTime.Now;

            db.AddParameter("userId", text);
            DataRow dataRow = db.ExecuteRow("SELECT * FROM metersTable WHERE meterId=@userId");

            if (dataRow == null)
            {
                WMMessageBox.Show(this, "没有找到相应的表信息!");
                return;
            }
            db.AddParameter("permanentUserId", dataRow["permanentUserId"].ToString());
            DataRow dataRow2 = db.ExecuteRow("SELECT * FROM usersTable WHERE permanentUserId=@permanentUserId");

            if (dataRow2 == null)
            {
                WMMessageBox.Show(this, "没有找到该用户!");
                return;
            }
            double num = ConvertUtils.ToUInt32(dataRow2["totalPursuitNum"].ToString());

            fillBaseInfoWidget(dataRow2);
            if (flag)
            {
                db.AddParameter("permanentUserId", dataRow["permanentUserId"].ToString());
                db.AddParameter("lastReadInfo", "1");
                db.AddParameter("totalNum", string.Concat(consumeCardEntity.TotalReadNum));
                DataRow dataRow3 = db.ExecuteRow("SELECT * FROM userCardLog WHERE permanentUserId=@permanentUserId AND totalNum=@totalNum AND lastReadInfo=@lastReadInfo ORDER BY operationId DESC");
                if (dataRow3 == null)
                {
                    db.AddParameter("time", string.Concat((now - WMConstant.DT1970).TotalSeconds));
                    db.AddParameter("userHead", string.Concat(consumeCardEntity.CardHead.getEntity()));
                    db.AddParameter("deviceHead", string.Concat(consumeCardEntity.DeviceHead.getEntity()));
                    db.AddParameter("userId", text ?? "");
                    db.AddParameter("pursuitNum", "0");
                    db.AddParameter("totalNum", string.Concat(consumeCardEntity.TotalReadNum));
                    db.AddParameter("consumeTimes", string.Concat(consumeCardEntity.ConsumeTimes));
                    db.AddParameter("operator", MainForm.getStaffId());
                    db.AddParameter("operateType", "2");
                    db.AddParameter("totalPayNum", "0");
                    db.AddParameter("unitPrice", "0");
                    db.AddParameter("lastReadInfo", "1");
                    db.AddParameter("permanentUserId", dataRow["permanentUserId"].ToString());
                    db.ExecuteNonQuery("INSERT INTO userCardLog(time, userHead, deviceHead, userId, pursuitNum, totalNum, consumeTImes, operator, operateType, totalPayNum, unitPrice, lastReadInfo, permanentUserId) VALUES (@time, @userHead, @deviceHead, @userId, @pursuitNum, @totalNum, @consumeTImes, @operator, @operateType,@totalPayNum, @unitPrice, @lastReadInfo, @permanentUserId)");
                }
            }
            db.AddParameter("permanentUserId", dataRow["permanentUserId"].ToString());
            db.AddParameter("operateType", "2");
            db.AddParameter("lastReadInfo", "0");
            DataTable dataTable = db.ExecuteQuery("SELECT * FROM userCardLog WHERE permanentUserId=@permanentUserId AND operateType!=@operateType AND lastReadInfo=@lastReadInfo ORDER BY operationId DESC");

            if (dataTable != null && dataTable.Rows != null && dataTable.Rows.Count > 0)
            {
                fillPursuitInfoWidget(dataTable.Rows[0]);
                lastPursuitInfo = dataTable.Rows[0];
                if (num > 0.0 && num < ConvertUtils.ToDouble(lastPursuitInfo["pursuitNum"].ToString()) / 10.0)
                {
                    WMMessageBox.Show(this, "用户已经退购!");
                    return;
                }
                DateTime d        = WMConstant.DT1970.AddSeconds(ConvertUtils.ToDouble(lastPursuitInfo["time"].ToString()));
                TimeSpan timeSpan = now - d;
                db.AddParameter("typeId", dataRow2["userTypeId"].ToString());
                dataRow2 = db.ExecuteRow("SELECT * FROM userTypeTable WHERE typeId=@typeId");
                if (dataRow2 == null)
                {
                    WMMessageBox.Show(this, "没有找到对应用户类型!");
                    return;
                }
                overZeroValue = ConvertUtils.ToDouble(dataRow2["overZeroValue"].ToString());
                uint totalReadNum = consumeCardEntity.TotalReadNum;
                overZeroFlag = consumeCardEntity.DeviceHead.OverZeroFlag;
                consumeTimes = ConvertUtils.ToUInt32(lastPursuitInfo["consumeTimes"].ToString());
                if (!flag)
                {
                    num -= ConvertUtils.ToDouble(lastPursuitInfo["pursuitNum"].ToString()) / 10.0;
                    consumeTimes--;
                    double           num2             = ConvertUtils.ToDouble(lastPursuitInfo["totalNum"].ToString()) / 10.0;
                    DeviceHeadEntity deviceHeadEntity = new DeviceHeadEntity();
                    deviceHeadEntity.parseEntity(ConvertUtils.ToUInt32(lastPursuitInfo["deviceHead"].ToString()));
                    overZeroFlag = deviceHeadEntity.OverZeroFlag;
                }
                int surplusNum = consumeCardEntity.DeviceHead.getSurplusNum();
                lastSurplusNumTB.Text  = surplusNum.ToString();
                totalReadNumTB.Text    = consumeCardEntity.TotalReadNum.ToString();
                totalPursuitNumTB.Text = num.ToString();
                db.AddParameter("userId", text);
                dataRow2 = db.ExecuteRow("SELECT * FROM cardData WHERE userId=@userId");
                if (dataRow2 == null)
                {
                    WMMessageBox.Show(this, "没有找到用户卡片信息!");
                    return;
                }
                ic_id = ConvertUtils.ToUInt32(dataRow2["cardId"].ToString());
                enterByManualBtn.Enabled = true;
                enterByAutoBtn.Enabled   = true;
            }
            else
            {
                WMMessageBox.Show(this, "没有找到消费记录!");
            }
        }