public int Inslog(B2b_invitecodesendlog log) { using (var helper = new SqlHelper()) { int result = new InternalB2b_invitecodesendlog(helper).Inslog(log); return(result); } }
internal B2b_invitecodesendlog GetNoteRecord(string invitecode, int comid) { string sql = @"SELECT [id] ,[phone] ,[smscontent] ,[invitecode] ,[senduserid] ,[sendtime] ,[issendsuc] ,[isqunfa] ,[remark] ,[comid] FROM [EtownDB].[dbo].[b2b_invitecodesendlog] where invitecode=@invitecode and comid=@comid"; try { var cmd = this.sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@invitecode", invitecode); cmd.AddParam("@comid", comid); B2b_invitecodesendlog u = null; using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { u = new B2b_invitecodesendlog() { Id = reader.GetValue <int>("id"), Phone = reader.GetValue <string>("Phone"), Smscontent = reader.GetValue <string>("Smscontent"), Invitecode = reader.GetValue <string>("Invitecode"), Senduserid = reader.GetValue <int>("Senduserid"), Sendtime = reader.GetValue <DateTime>("Sendtime"), Issendsuc = reader.GetValue <int>("Issendsuc"), Isqunfa = reader.GetValue <int>("Isqunfa"), Remark = reader.GetValue <string>("Remark"), Comid = reader.GetValue <int>("comid") }; } } return(u); } catch { return(null); } }
internal int Inslog(B2b_invitecodesendlog log) { string sql = @"INSERT INTO [EtownDB].[dbo].[b2b_invitecodesendlog] ([phone] ,[smscontent] ,[invitecode] ,[senduserid] ,[sendtime] ,[issendsuc] ,[isqunfa] ,[remark] ,[comid]) VALUES (@phone ,@smscontent ,@invitecode ,@senduserid ,@sendtime ,@issendsuc ,@isqunfa ,@remark ,@comid)"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@phone", log.Phone); cmd.AddParam("@smscontent", log.Smscontent); cmd.AddParam("@invitecode", log.Invitecode); cmd.AddParam("@senduserid", log.Senduserid); cmd.AddParam("@sendtime", log.Sendtime); cmd.AddParam("@issendsuc", log.Issendsuc); cmd.AddParam("@isqunfa", log.Isqunfa); cmd.AddParam("@remark", log.Remark); cmd.AddParam("@comid", log.Comid); return(cmd.ExecuteNonQuery()); }
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); }