public string newcode(string sphone) { string code = ""; Random newRandom = new Random(); for (int i = 0; i < 4; i++) { code = code + newRandom.Next(1, 9).ToString(); } Cms.Model.C_code cm = new Model.C_code(); cm.vphone = sphone; cm.vcode = code; cm.isare = 1; cm.updatetime = DateTime.Now; Add(cm); return(code); }
public bool setcode(string sphone) { bool bl = false; string strSql = "select top 1 * from C_code where DateDiff(dd,updatetime,getdate())=0 and vphone='" + sphone + "' and isare=1 order by id desc"; DataTable dt = DbHelperSQL.Query(strSql).Tables[0]; if (dt.Rows.Count > 0) { Cms.Model.C_code cm = new Model.C_code(); cm = GetModel(int.Parse(dt.Rows[0]["id"].ToString())); cm.isare = 0; Update(cm); bl = true; } return(bl); }