Beispiel #1
0
        private MemberCard getCard(String no)
        {
            MemberCard card = new MemberCard();

            String sql = String.Format("SELECT id FROM members_cards WHERE card_no = '{0}'", no);

            using (SQLiteDataReader rdr = SQLiteHelper.ExecuteReader(ds + this.txtTarget.Text.Trim(), CommandType.Text, sql))
            {
                if (rdr.Read())
                {
                    card.Id = rdr["id"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["id"].ToString());
                }

                /*while (rdr.Read())
                 * {
                 *  member.Id = rdr["id"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["id"].ToString());
                 *  member.Balance = rdr["no"] == DBNull.Value ? "" : rdr["no"].ToString();
                 *  member.CreatedAt = Tools.TimeStamp.GetNowTimeStamp();
                 *  member.BeginAt = rdr["created_at"] == DBNull.Value ? "" : rdr["created_at"].ToString();
                 *  member.ExpiredAt = rdr["expire_at"] == DBNull.Value ? 0 : rdr["expire_at"].ToString();
                 *  member.Status = "Enabled";
                 *  members.Add(member);
                 * }*/
            }
            return(card);
        }
Beispiel #2
0
        private void btnMemberValue_Click(object sender, EventArgs e)
        {
            String sql = "INSERT INTO members_cards_records(member_card_id, balance, begin_at, expired_at, status, created_at) VALUES";

            int row = 0;
            int i   = 0;

            foreach (Member member in members)
            {
                if (Convert.ToInt32(member.Money) < 1 || member.CreatedAt == "0001/1/1 0:00:00" || member.CreatedAt == "0001-1-1 0:00:00" || member.EndAt == "")
                {
                    continue;
                }

                MemberCard card = this.getCard(member.No);
                sql += String.Format("({0}, {1}, {2}, {3}, 'Enabled', {4}),", card.Id, member.Money, Tools.TimeStamp.ConvertDateTimeInt(Convert.ToDateTime(member.BeginAt)), TimeStamp.ConvertDateTimeInt(Convert.ToDateTime(member.EndAt)), Tools.TimeStamp.GetNowTimeStamp());
                i++;

                if (i > 5000)
                {
                    sql = sql.Substring(0, sql.Length - 1);
                    row = SQLiteHelper.ExecuteNonQuery(ds + this.txtTarget.Text.Trim(), CommandType.Text, sql);
                    Console.WriteLine("本次处理:" + row);
                    row               = Tools.MySqlHelper.ExecuteNonQuery(this.txtServer.Text.Trim(), CommandType.Text, sql);
                    this.labOk.Text   = i.ToString();
                    this.labNone.Text = (Convert.ToInt32(this.labTotal.Text) - Convert.ToInt32(this.labOk.Text)).ToString();

                    sql = "INSERT INTO members_cards_records(member_card_id, balance, begin_at, expired_at, status, created_at) VALUES";
                }
            }

            sql = sql.Substring(0, sql.Length - 1);
            row = SQLiteHelper.ExecuteNonQuery(ds + this.txtTarget.Text.Trim(), CommandType.Text, sql);
            if (row < 1)
            {
                Console.WriteLine("最后一次处理失败:" + sql);
                return;
            }
            row = Tools.MySqlHelper.ExecuteNonQuery(this.txtServer.Text.Trim(), CommandType.Text, sql);
            Console.WriteLine("最后一次处理:" + row);
            this.labOk.Text   = i.ToString();
            this.labNone.Text = (Convert.ToInt32(this.labTotal.Text) - Convert.ToInt32(this.labOk.Text)).ToString();

            MessageBox.Show("会员卡迁移完成");
        }