public bool CreateReplay(Revert replay) { string sqlStr = "insert into tbRevert(revertTitle,revertContent,revertDate,postID,userID) values(@RevertTitle,@RevertContent,@RevertDate,@postId,@userId)"; SqlParameter[] param = { new SqlParameter("@RevertTitle", replay.RevertTitle), new SqlParameter("@RevertContent", replay.RevertContent), new SqlParameter("@RevertDate", replay.RevertDate), new SqlParameter("@postId", replay.PostID), new SqlParameter("@userId", replay.UserID) }; try { SQLHelper help = new SQLHelper(); if (help.ExecuteCommand(sqlStr, param)) { return(true); } else { return(false); } } catch { return(false); } }
protected override void OnDraw() { GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)); if (!GraphHelper.IsGraphLoaded) { GUILayout.Label("No graph selected.", EditorStyles.miniLabel); } if (GraphHelper.IsGraphDirty) { if (DrawButton("Save")) { Save.InvokeSafe(); } if (DrawButton("Revert")) { Revert.InvokeSafe(); } } if (GraphHelper.IsGraphLoaded) { if (DrawButton("Run")) { Run.InvokeSafe(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
public bool UpdateReplay(Revert replay) { string sqlStr = "Update tbRevert set RevertTitle=@RevetTitle, RevertContent=@RevertContent where RervertId=@RevertId"; SqlParameter[] param = { new SqlParameter("@RevertTitle", replay.RevertTitle), new SqlParameter("@RevertContent", replay.RevertContent), new SqlParameter("@RevertId", replay.RevertID) }; try { SQLHelper help = new SQLHelper(); if (help.ExecuteCommand(sqlStr, param)) { return(true); } else { return(false); } } catch { return(false); } }
private void Button3_Click(object sender, EventArgs e) { //if(Reverts[0] != null) //Array.Clear(Reverts,0,Reverts.Length); var amount = 0; foreach (string s in SafeFileNames) { amount++; } Reverts = new string[amount]; var i = 0; foreach (string FileName in FileNames) { var content = File.ReadAllText(FileName); Revert revert = new Revert(); revert.fileName = FileName; revert.content = content; string jsonified = JsonConvert.SerializeObject(revert); var fileText = content.Replace(replace_text.Text, replace_with.Text); File.WriteAllText(FileName, fileText); Reverts[i] = jsonified; i++; Console.WriteLine("Replaced a string in " + FileName + ", Changed to \"" + fileText + "\""); Console.WriteLine("Old value: " + replace_text.Text + " New Value: " + replace_with.Text); } }
public static int DeleteRevertRevertID(Revert revert) { SqlParameter[] sp = { new SqlParameter("@revertid", revert.RevertID), }; string sql = "delete from tb_Revert where 回帖编号=@revertid"; return(sqlHelp.ExecuteNonQuery(sql, sp)); }
public void copy(Revert revert) { dependentId = revert.dependentId; uid = revert.uid; userName = revert.userName; icon = revert.icon; time = revert.time; context = revert.context; tar = revert.tar; }
private void button1_Click_2(object sender, EventArgs e) { label3.Text = "???"; label3.ForeColor = Color.White; ConvertB.Enabled = true; RevertB.Enabled = true; MessageBox.Show("Config Reset! (Now you can either convert or revert for this item)"); Swap.CancelAsync(); Revert.CancelAsync(); title.Text = "[+] Convert/Revert Cancelled"; }
public static List <Revert> FindRevertByCardID(Revert revert) { SqlParameter[] sp = { new SqlParameter("@cardid", revert.CardID), }; string sql = "select * from tb_Revert where 帖子编号 like @cardid"; SqlDataReader dr = sqlHelp.ExecuteReader(sql, sp); return(getListOfRevertbyDataReader(dr)); }
public static Revert FindRevertByRevertID(Revert revert) { SqlParameter[] sp = { new SqlParameter("@revertid", revert.RevertID), }; string sql = "select * from tb_Revert where 回帖编号 like @revertid"; SqlDataReader dr = sqlHelp.ExecuteReader(sql, sp); return(getOfRevertbyDataReader(dr)); }
public static void OnRevert(TLUIElement controller, object _revert, Func <TLUIElement, int, int> Func) { _revert = _revert.GetMember("onrevert", new Revert(), false); if (_revert == null) { return; } Revert revert = _revert as Revert; revert.Calls[revert.Length] = (int count) => { return(Func(controller, count)); }; revert.Length++; }
/// <summary> /// 取得数据 /// </summary> /// <param name="id"></param> /// <returns></returns> private Revert GetData(int id) { Revert model = new Revert(); if (id > 0) { model = bll.GetModel(id); } model.Subject = Request.Form["ipt_Subject"] != "" ? Request.Form["ipt_Subject"] : ""; model.Content = Request.Form["ipt_Content"] != "" ? Request.Form["ipt_Content"] : ""; return(model); }
public static Revert read(ByteBuffer data) { Revert revert = new Revert(); revert.id = data.ReadLong(); revert.dependentId = data.ReadLong(); revert.uid = data.ReadLong(); revert.userName = data.ReadString(); revert.icon = data.ReadString(); revert.time = data.ReadString(); revert.context = data.ReadString(); revert.tar = data.ReadString(); return(revert); }
public List <Revert> GetHeros([FromBody] string name) { Revert r = new Revert(); var i = 0; r.name = name; r.phone = i; var hero = new List <Revert>(); hero.Add(r); i++; return(hero); }
public static int addRevert(Revert revert) { SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@revertid", revert.RevertID), new SqlParameter("@revertname", revert.RevertName), new SqlParameter("@cardid", revert.CardID), new SqlParameter("@revertcontent", revert.RevertContent), new SqlParameter("@reverttime", revert.RevertTime), new SqlParameter("@revertpeople", revert.RevertPeople), new SqlParameter("@pop", revert.Pop), }; string sql = "insert into tb_card values( @revertid,@revertname,@cardid,@revertcontent,@reverttime,@revertpeople,@pop)"; return(sqlHelp.ExecuteNonQuery(sql, sp)); }
static List <Revert> getListOfRevertbyDataReader(SqlDataReader dr) { List <Revert> listOfStudentInfo = new List <Revert>(); while (dr.Read()) { Revert revert = new Revert(); int revertID = dr.GetOrdinal("回帖编号"); if (!dr.IsDBNull(revertID)) { revert.RevertID = dr.GetString(revertID); } int revertName = dr.GetOrdinal("回帖主题"); if (!dr.IsDBNull(revertName)) { revert.RevertName = dr.GetString(revertName); } int cardID = dr.GetOrdinal("帖子编号"); if (!dr.IsDBNull(cardID)) { revert.CardID = dr.GetString(cardID); } int revertContent = dr.GetOrdinal("回帖内容"); if (dr.IsDBNull(revertContent)) { revert.RevertContent = dr.GetString(revertContent); } int revertTime = dr.GetOrdinal("回帖时间"); if (!dr.IsDBNull(revertTime)) { revert.RevertTime = dr.GetDateTime(revertTime); } int revertPeople = dr.GetOrdinal("回帖人"); if (!dr.IsDBNull(revertPeople)) { revert.RevertPeople = dr.GetString(revertPeople); } int pop = dr.GetOrdinal("角色"); if (!dr.IsDBNull(pop)) { revert.Pop = dr.GetString(pop); } listOfStudentInfo.Add(revert); } return(listOfStudentInfo); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Revert model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Revert set "); strSql.Append("Subject=@Subject,"); strSql.Append("Content=@Content,"); strSql.Append("ArticleID=@ArticleID,"); strSql.Append("BlogID=@BlogID,"); strSql.Append("Time=@Time,"); strSql.Append("IP=@IP,"); strSql.Append("VisitorID=@VisitorID,"); strSql.Append("VisitorName=@VisitorName"); strSql.Append(" where RevertID=@RevertID"); SqlParameter[] parameters = { new SqlParameter("@Subject", SqlDbType.NVarChar, 50), new SqlParameter("@Content", SqlDbType.NText), new SqlParameter("@ArticleID", SqlDbType.Int, 4), new SqlParameter("@BlogID", SqlDbType.Int, 4), new SqlParameter("@Time", SqlDbType.DateTime), new SqlParameter("@IP", SqlDbType.NVarChar, 20), new SqlParameter("@VisitorID", SqlDbType.Int, 4), new SqlParameter("@VisitorName", SqlDbType.NVarChar, 50), new SqlParameter("@RevertID", SqlDbType.Int, 4) }; parameters[0].Value = model.Subject; parameters[1].Value = model.Content; parameters[2].Value = model.ArticleID; parameters[3].Value = model.BlogID; parameters[4].Value = model.Time; parameters[5].Value = model.IP; parameters[6].Value = model.VisitorID; parameters[7].Value = model.VisitorName; parameters[8].Value = model.RevertID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Revert DataRowToModel(DataRow row) { Revert model = new Revert(); if (row != null) { if (row["RevertID"] != null && row["RevertID"].ToString() != "") { model.RevertID = int.Parse(row["RevertID"].ToString()); } if (row["Subject"] != null) { model.Subject = row["Subject"].ToString(); } if (row["Content"] != null) { model.Content = row["Content"].ToString(); } if (row["ArticleID"] != null && row["ArticleID"].ToString() != "") { model.ArticleID = int.Parse(row["ArticleID"].ToString()); } if (row["BlogID"] != null && row["BlogID"].ToString() != "") { model.BlogID = int.Parse(row["BlogID"].ToString()); } if (row["Time"] != null && row["Time"].ToString() != "") { model.Time = DateTime.Parse(row["Time"].ToString()); } if (row["IP"] != null) { model.IP = row["IP"].ToString(); } if (row["VisitorID"] != null && row["VisitorID"].ToString() != "") { model.VisitorID = int.Parse(row["VisitorID"].ToString()); } if (row["VisitorName"] != null) { model.VisitorName = row["VisitorName"].ToString(); } } return(model); }
static Revert getOfRevertbyDataReader(SqlDataReader dr) { Revert revert = new Revert(); while (dr.Read()) { int revertID = dr.GetOrdinal("回帖编号"); if (!dr.IsDBNull(revertID)) { revert.RevertID = dr.GetString(revertID); } int revertName = dr.GetOrdinal("回帖主题"); if (!dr.IsDBNull(revertName)) { revert.RevertName = dr.GetString(revertName); } int cardID = dr.GetOrdinal("帖子编号"); if (!dr.IsDBNull(cardID)) { revert.CardID = dr.GetString(cardID); } int revertContent = dr.GetOrdinal("回帖内容"); if (dr.IsDBNull(revertContent)) { revert.RevertContent = dr.GetString(revertContent); } int revertTime = dr.GetOrdinal("回帖时间"); if (!dr.IsDBNull(revertTime)) { revert.RevertTime = dr.GetDateTime(revertTime); } int revertPeople = dr.GetOrdinal("回帖人"); if (!dr.IsDBNull(revertPeople)) { revert.RevertPeople = dr.GetString(revertPeople); } int pop = dr.GetOrdinal("角色"); if (!dr.IsDBNull(pop)) { revert.Pop = dr.GetString(pop); } } return(revert); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Revert model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Revert("); strSql.Append("Subject,Content,ArticleID,BlogID,Time,IP,VisitorID,VisitorName)"); strSql.Append(" values ("); strSql.Append("@Subject,@Content,@ArticleID,@BlogID,@Time,@IP,@VisitorID,@VisitorName)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Subject", SqlDbType.NVarChar, 50), new SqlParameter("@Content", SqlDbType.NText), new SqlParameter("@ArticleID", SqlDbType.Int, 4), new SqlParameter("@BlogID", SqlDbType.Int, 4), new SqlParameter("@Time", SqlDbType.DateTime), new SqlParameter("@IP", SqlDbType.NVarChar, 20), new SqlParameter("@VisitorID", SqlDbType.Int, 4), new SqlParameter("@VisitorName", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Subject; parameters[1].Value = model.Content; parameters[2].Value = model.ArticleID; parameters[3].Value = model.BlogID; parameters[4].Value = model.Time; parameters[5].Value = model.IP; parameters[6].Value = model.VisitorID; parameters[7].Value = model.VisitorName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(false); } else { return(true); } }
static void Main(string[] args) { //Receiver //Example of Liskov Substitution Principle: //If S (CheckingAccount, SavingsAccount) is a subtype of T (IBankAccount), //then objects of type T (IBankAccount) may be replaced with object of type S (CheckingAccount, SavingsAccount). IBankAccount checkingAccount = new CheckingAccount(); IBankAccount savingsAccount = new SavingsAccount(); //Concrete commands ICommand addToChecking = new Add(checkingAccount); ICommand subtractFromChecking = new Subtract(checkingAccount); ICommand getBalanceOfChecking = new Get(checkingAccount); ICommand revertChecking = new Revert(checkingAccount); ICommand addToSavings = new Add(savingsAccount); ICommand subtractFromSavings = new Subtract(savingsAccount); ICommand getBalanceOfSavings = new Get(savingsAccount); ICommand revertSavings = new Revert(savingsAccount); //Invoker BankAccountInvoker checkingInvoker = new BankAccountInvoker(addToChecking, subtractFromChecking, getBalanceOfChecking, revertChecking); BankAccountInvoker savingsInvoker = new BankAccountInvoker(addToSavings, subtractFromSavings, getBalanceOfSavings, revertSavings); checkingInvoker.Add(10); checkingInvoker.Subtract(5); checkingInvoker.Revert(1); var checkingBalance = checkingInvoker.Get(); Console.WriteLine(checkingBalance); savingsInvoker.Add(8); savingsInvoker.Subtract(5); savingsInvoker.Revert(1); var savingsBalance = savingsInvoker.Get(); Console.WriteLine(savingsBalance); Console.ReadLine(); }
/// <summary> /// 添加或修改数据 /// </summary> private void UpdateData() { bool blResult = false; int id = Request.Form["id"] != "" ? Convert.ToInt32(Request.Form["id"]) : 0; Revert model = GetData(id); string writeMsg = "操作失败!"; if (model != null) { if (id < 1) { blResult = bll.Add(model); if (blResult) { writeMsg = "增加成功!"; } else { writeMsg = "增加失败!"; } } else { blResult = bll.Update(model); if (blResult) { writeMsg = "更新成功!"; } else { writeMsg = "更新失败!"; } } } Response.Clear(); Response.Write(writeMsg); Response.End(); }
public static DealBody read(ByteBuffer data) { DealBody item = new DealBody(); item.id = data.ReadLong(); item.seller = data.ReadByte() == 1; item.uid = data.ReadLong(); item.userName = data.ReadString(); item.icon = data.ReadString(); item.time = data.ReadString(); item.validTime = data.ReadString(); item.typeStr = data.ReadByte() == 0 ? "入库" : "现货"; item.bourse = data.ReadString(); item.stampName = data.ReadString(); item.monad = data.ReadString(); item.curNum = data.ReadInt(); item.price = float.Parse(data.ReadString()); item.context = data.ReadString(); item.helpFlag = data.ReadByte() == 1; item.revoke = data.ReadByte() == 1; item.isLock = data.ReadByte() == 1; int revertLen = data.ReadInt(); for (int j = 0; j < revertLen; j++) { Revert revert = Revert.read(data); item.reverts.Add(revert); } int orderLen = data.ReadInt(); for (int j = 0; j < orderLen; j++) { Order order = Order.read(data); order.item = item; item.orders.Add(order); } return(item); }
/// <summary> /// 得到一个对象实体 /// </summary> public Revert GetModel(int RevertID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 RevertID,Subject,Content,ArticleID,BlogID,Time,IP,VisitorID,VisitorName from Revert "); strSql.Append(" where RevertID=@RevertID"); SqlParameter[] parameters = { new SqlParameter("@RevertID", SqlDbType.Int, 4) }; parameters[0].Value = RevertID; Revert model = new Revert(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public static List <Revert> FindRevertByCardID(Revert revert) { return(RevertSer.FindRevertByCardID(revert)); }
public bool UpdateReplay(Revert replay) { return(replayDal.UpdateReplay(replay)); }
public bool CreateReplay(Revert replay) { return(replayDal.CreateReplay(replay)); }
public static int DeleteRevertByRevertID(Revert revert) { return(RevertSer.DeleteRevertRevertID(revert)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Revert model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Revert model) { return(dal.Add(model)); }
public void copy(DealBody item) { id = item.id; uid = item.uid; icon = item.icon; userName = item.userName; time = item.time; validTime = item.validTime; typeStr = item.typeStr; bourse = item.bourse; stampName = item.stampName; monad = item.monad; curNum = item.curNum; price = item.price; context = item.context; seller = item.seller; refresh = item.refresh; for (int i = 0; i < reverts.Count;) { Revert dr = reverts[i]; bool delFlag = true; foreach (Revert revert in item.reverts) { if (dr.id == revert.id) { dr.copy(revert); item.reverts.Remove(revert); delFlag = false; break; } } if (delFlag) { reverts.RemoveAt(i); } else { i++; } } foreach (Revert revert in item.reverts) { reverts.Add(revert); } for (int i = 0; i < orders.Count;) { Order dor = orders[i]; bool delFlag = true; foreach (Order order in item.orders) { if (dor.id == order.id) { dor.copy(order); item.orders.Remove(order); delFlag = false; break; } } if (delFlag) { orders.RemoveAt(i); } else { i++; } } foreach (Order order in item.orders) { orders.Add(order); } }