Esempio n. 1
0
        public int InsertOrUpdate(Member_Card model)
        {
            string insertsqltxt = ""; //卡号插入SQL
            int    cardid       = 0;  //卡管理ID
            string cardcode     = ""; //卡号
            int    RandomCode   = 0;


            var cmd = sqlHelper.PrepareStoredSqlCommand(SQLInsertOrUpdate);

            cmd.AddParam("@Id", model.Id);
            cmd.AddParam("@Com_id", model.Com_id);
            cmd.AddParam("@cname", model.Cname);
            cmd.AddParam("@ctype", model.Ctype);
            cmd.AddParam("@printnum", model.Printnum);
            cmd.AddParam("@zhuanzeng", model.Zhuanzeng);
            cmd.AddParam("@qrcode", model.Qrcode);
            cmd.AddParam("@Exchange", model.Exchange);
            cmd.AddParam("@remark", model.Remark);
            cmd.AddParam("@cardRule", model.CardRule);
            cmd.AddParam("@cardRule_starnum", model.CardRule_starnum);
            cmd.AddParam("@cardRule_First", model.CardRule_First);

            var parm = cmd.AddReturnValueParameter("ReturnValue");

            cmd.ExecuteNonQuery();

            cardid = (int)parm.Value;

            //是修改操作将不产生卡号
            if (model.Id == 0)
            {
                //后8位如果是顺序编码2 则执行
                if (model.CardRule == 2)
                {
                    for (int i = model.CardRule_starnum; i < model.CardRule_starnum + model.Printnum; i++)
                    {
                        cardcode     = model.CardRule_First + model.CardRule_Second.ToString() + i;
                        insertsqltxt = "insert Member_Card (com_id,crid,cardcode)values(" + model.Com_id + "," + cardid + "," + cardcode + ")";
                        cmd          = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
                        cmd.ExecuteNonQuery();
                    }
                }
                //后8位采用随机编码1
                else
                {
                    for (int i = 1; i < model.Printnum; i++)
                    {
                        //获得随机码
                        RandomCode = MemberCardData.GetRandomCode();
                        //使用随机码时,标记为已使用防止重复码
                        insertsqltxt = "update RandomCode set state = 1 where code = " + RandomCode;
                        cmd          = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
                        cmd.ExecuteNonQuery();

                        //插入卡库Member_Card
                        cardcode     = model.CardRule_First + model.CardRule_Second.ToString() + RandomCode;
                        insertsqltxt = "insert Member_Card (com_id,crid,cardcode)values(" + model.Com_id + "," + cardid + "," + cardcode + ")";
                        cmd          = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            return((int)parm.Value);
        }
Esempio n. 2
0
        public string CreateECard(int cardtype, int comid)
        {
            string insertsqltxt = ""; //卡号插入SQL
            string cardcode     = ""; //卡号
            int    Face         = 1;  //活动面向对象 Face=3网站 Face=4微信


            //从公司自己导入的卡号中获取卡号,如果没有的话则创建
            cardcode = new MemberCardData().GetUnusedOutCardcode(comid);
            if (cardcode == "")
            {
                int RandomCode = 0;
                int Firstcard  = 0;
                int Scountcard = Int16.Parse(DateTime.Now.ToString("yyMM"));

                if (cardtype == 1)
                {
                    Firstcard = 2002;
                    Face      = 3;
                }
                else
                {
                    Firstcard = 2001;
                    Face      = 4;
                }

                //获得随机码
                RandomCode = MemberCardData.GetRandomCode();
                //使用随机码时,标记为已使用防止重复码
                insertsqltxt = "update RandomCode set state = 1 where code = " + RandomCode;
                var cmda = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
                cmda.ExecuteNonQuery();


                //插入卡库Member_Card
                cardcode = Firstcard.ToString() + Scountcard.ToString() + RandomCode;
            }
            else
            {
                //把得到的外部导入会员卡号标注为已使用,防止重复
                insertsqltxt = "update Out_MemberCardCode set isused = 1 where outcardcode = '" + cardcode + "'";
                var cmda = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
                cmda.ExecuteNonQuery();
            }



            insertsqltxt = "insert Member_Card (com_id,crid,cardcode,openstate)values(" + comid + ",0," + cardcode + ",1);select @@identity;";
            var cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);

            cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
            string cardid = cmd.ExecuteScalar().ToString();


            //直接插入活动指定活动3=网站活动,4=微信活动
            insertsqltxt = "insert into Member_Card_Activity (CardID,ACTID ) select " + cardid + ",id from Member_Activity where  com_id=" + comid + " and FaceObjects=" + Face;
            cmd          = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt);
            cmd.ExecuteNonQuery();

            DateTime today = DateTime.Now;

            //当时微信注册或网站注册的 积分活动,自动已赠送,活动变成已使用
            string updatesqltxt = "update member_card_activity set actnum=0,usestate=2,usesubdate='" + today + "' where cardid=" + cardid + " and actid in (select id from Member_Activity where acttype=4 and faceobjects in (4,3))";

            cmd = this.sqlHelper.PrepareTextSqlCommand(updatesqltxt);
            cmd.ExecuteNonQuery();

            return(cardcode);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string phone = Request["etmobile"].ConvertTo <string>("");

            string duanxintext = Request["duanxintext1"].ConvertTo <string>("");



            int comid = Request["comid"].ConvertTo <int>(0);

            int    userid  = Request["userid"].ConvertTo <int>(0);
            string isqunfa = Request["isqunfa"].ConvertTo <string>("no");

            if (isqunfa == "yes")
            {
                isqunfa = "1";
            }
            else
            {
                isqunfa = "0";
            }
            string msg       = "";
            int    sendstate = 0;   //发送结果默认为0

            string Invitecode = ""; //验证码

            //获取公司微信号
            B2b_company com = B2bCompanyData.GetAllComMsg(comid);

            if (com.B2bcompanyinfo.Weixinname == "")
            {
                msg = phone + "公司微信号为空";
            }
            else
            {
                duanxintext = duanxintext.Replace("$comweixin$", com.B2bcompanyinfo.Weixinname);

                //判断手机格式是否正确
                bool isphone = Regex.IsMatch(phone, @"^1[358]\d{9}$", RegexOptions.IgnoreCase);
                if (isphone)
                {
                    //获得随机码
                    Invitecode = MemberCardData.GetRandomCode().ToString();
                    //使用随机码时,标记为已使用 防止重复码
                    ExcelSqlHelper.ExecuteNonQuery("update RandomCode set state = 1 where code = " + Invitecode);

                    duanxintext = duanxintext.Replace("$invitecode$", Invitecode);
                    sendstate   = SendSmsHelper.SendSms(phone, duanxintext, comid, out msg);
                }
                else
                {
                    msg = phone + "手机格式不正确";
                }
            }



            //录入发送邀请码日志
            B2b_invitecodesendlog log = new B2b_invitecodesendlog
            {
                Id         = 0,
                Phone      = phone,
                Smscontent = duanxintext,
                Invitecode = Invitecode,
                Senduserid = userid,
                Sendtime   = DateTime.Now,
                Issendsuc  = 0,
                Isqunfa    = int.Parse(isqunfa),
                Remark     = msg,
                Comid      = comid
            };

            if (sendstate > 0)
            {
                log.Issendsuc = 1;
            }
            else
            {
                log.Issendsuc = 0;
            }

            int result = new B2b_invitecodesendlogData().Inslog(log);
        }