private void BtnAdd_Click(object sender, EventArgs e) { try { if (!CheckInputNotEmpty()) { return; } uType uType = new uType(); uType.UserType = this.tbUserTypeAdd.Text.Trim(); int ret = new uTypeManager().AddUserType(uType); if (ret > 0) { MessageBox.Show(INSERTSUCCEED, OPERATIONWARN, MessageBoxButtons.OK, MessageBoxIcon.Information); UserTypeDataBind(); } else { MessageBox.Show(INSERTFAILED, OPERATIONWARN, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, OPERATIONFAILSED, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private Udstyr ReadUdstyr(SqlDataReader reader) //denne metode skal justeres så den tager fat de rigtige steder i DB { int udstyrId = reader.GetInt32(0); int stationId = reader.GetInt32(1); Station station = HentStationFraId(stationId); uType type = uType.Filter; try { string typeStr = reader.GetString(2); type = (uType)Enum.Parse(typeof(uType), typeStr); CheckEnumParseU(type, udstyrId); } catch (ParseToEnumException) { ParseToEnumException parseFailEx = new ParseToEnumException(udstyrId); string log = parseFailEx.ToString(); } DateTime instDato = reader.GetDateTime(3); string beskrivelse = reader.GetString(4); return(new Udstyr(udstyrId, instDato, beskrivelse, type, station)); }
/// <summary> /// Constructor to use to create manually an chat message. /// </summary> /// <param name="author">Author of the message.</param> /// <param name="message">Message content.</param> public IrcMessage(string author, string message) { this.timestamp = DateTime.Now; this.message = message; this.author = author; this.userType = uType.BOT; }
private void BtnUpdate_Click(object sender, EventArgs e) { try { if (!CheckUpdate()) { return; } uType uType = new uType(); uType.UTypeId = Convert.ToInt32(this.tbUserTypeId.Text.Trim()); uType.UserType = this.tbUserTypeUpdate.Text.Trim(); int ret = new uTypeManager().UpdateUserType(uType); if (ret > 0) { MessageBox.Show(UPDATESUCCEED, OPERATIONWARN, MessageBoxButtons.OK, MessageBoxIcon.Information); UserTypeDataBind(); } else { MessageBox.Show(UPDATEFAILED, OPERATIONWARN, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, OPERATIONFAILSED, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//指定位置に指定タイプのオブジェクトが通れるかチェック public bool chkMoveObj(Vector2Int pos, uType type) { switch (type) { case uType.Warship: /* 船 */ case uType.Submarine: /* 潜水艦 */ if (tileMap[pos.x, pos.y].getGroup() != TileGroup.Sea) { return(false); } break; case uType.Vehicle: /* 車両 */ if (tileMap[pos.x, pos.y].getGroup() != TileGroup.Ground) { return(false); } break; case uType.Infantry: /* 人 */ if (tileMap[pos.x, pos.y].getGroup() == TileGroup.Sea) { return(false); } break; } return(true); }
public List <uType> GetUserData() { List <uType> u = new List <uType>(); //sql语句 StringBuilder sb = new StringBuilder(); sb.AppendLine("select userType from UserType"); //创建连接对象 SqlConnection conn = new SqlConnection(connString); try { //创建执行工具 SqlCommand cmd = new SqlCommand(sb.ToString(), conn); //执行 conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); //判断 while (reader.Read()) { uType ut = new uType(); ut.UserType = Convert.ToString(reader["UserType"]); u.Add(ut); } } catch (Exception ex) { throw ex; } return(u); }
public Udstyr(int udstyrId, DateTime installationsdato, string beskrivelse, uType type, Station station) { UdstyrId = udstyrId; Installationsdato = installationsdato; Beskrivelse = beskrivelse; Type = type; Station = station; OpgaveListe = null; }
private void CheckEnumParseU(uType checkType, int checkId) { if (!(checkType == uType.Filter || checkType == uType.Termometer || checkType == uType.Lufttrykmåler)) { int exId = checkId; throw new ParseToEnumException(exId); } }
public int UpdateUserType(uType utype) { try { return(us.UpdateUserType(utype)); } catch (Exception ex) { throw ex; } }
//ユニットオブジェクトのテンプレート作成 static UnitObj addObjTlt(String _image, uType _type, Unit _units, int _cost, int _hpMax, int _fuelMax, int _fuelEfc, float _speedMax, float _yawMax) { UnitObj newObj = Instantiate(instance); newObj.unitImage = newObj.transform.GetComponent <SpriteRenderer>(); //newObj.transform.Find("Texture").GetComponent<SpriteRenderer>() newObj.unitImage.sprite = Resources.Load <Sprite>("UnitImg/" + _image); newObj.units = _units; newObj.type = _type; newObj.hpMax = _hpMax; newObj.fuelMax = _fuelMax; newObj.fuelEfc = _fuelEfc; newObj.speedMax = _speedMax; newObj.yawMax = _yawMax; newObj.yawrate = _yawMax; newObj.gameObject.SetActive(false); //非表示 newObj.gameObject.name = "Tlt_" + _units.ToString(); //switch (newObj.type){ // case uType.Infantry: /* 歩兵 */ // newObj.gameObject.layer = LayerMask.NameToLayer("Infantry"); // break; // case uType.Vehicle: /* 車両 */ // newObj.gameObject.layer = LayerMask.NameToLayer("Vehicle"); // break; // case uType.Aircraft: /* 航空機 */ // newObj.gameObject.layer = LayerMask.NameToLayer("Aircraft"); // break; // case uType.Warship: /* 戦艦 */ // newObj.gameObject.layer = LayerMask.NameToLayer("Warship"); // break; // case uType.Submarine: /* 潜水艦 */ // newObj.gameObject.layer = LayerMask.NameToLayer("Submarine"); // break; // case uType.Building: // newObj.gameObject.layer = LayerMask.NameToLayer("Building"); // break; // default: /* その他 */ // break; // //} newObj.gameObject.layer = LayerMask.NameToLayer(newObj.type.ToString()); //建物の場合は、位置と向きを固定 if (_type == uType.Building) { var rb = newObj.GetComponent <Rigidbody2D>(); rb.constraints = RigidbodyConstraints2D.FreezeAll; newObj.GetComponent <CircleCollider2D>().isTrigger = true; //コライダーを無効化 } return(newObj); }
//根据用户类别获取读者类别 public List <uType> GetuType(string userType) { List <uType> utype = new List <uType>(); //sql语句 StringBuilder sb = new StringBuilder(); sb.AppendLine("select *"); sb.AppendLine("from UserType"); sb.AppendLine("where userType like @userType"); sb.AppendLine("order by uTypeId desc"); //变量赋值,设置参数 SqlParameter[] paras = { new SqlParameter("@userType", "%" + userType + "%") }; //创建连接对象 SqlConnection conn = new SqlConnection(connString); try { //创建执行工具 SqlCommand cmd = new SqlCommand(sb.ToString(), conn); //设置执行工具的参数 cmd.Parameters.AddRange(paras); conn.Open(); //执行 SqlDataReader reader = cmd.ExecuteReader(); //判断 while (reader.Read()) { uType ut = new uType(); ut.UTypeId = Convert.ToInt32(reader["UTypeId"]); ut.UserType = Convert.ToString(reader["UserType"]); utype.Add(ut); } reader.Close(); } catch (Exception ex) { throw ex; } //关闭数据库 finally { conn.Close(); } return(utype); }
//更改读者类别 public int UpdateUserType(uType utype) { //sql语句 StringBuilder sb = new StringBuilder(); sb.AppendLine("update UserType"); sb.AppendLine("set userType=@userType"); sb.AppendLine("where uTypeId=@uTypeId"); //变量赋值,设置参数 SqlParameter[] paras = { new SqlParameter("@userType", utype.UserType), new SqlParameter("@uTypeId", utype.UTypeId) }; //创建连接对象 SqlConnection conn = new SqlConnection(connString); try { //创建执行工具 SqlCommand cmd = new SqlCommand(sb.ToString(), conn); //设置执行工具的参数 cmd.Parameters.AddRange(paras); conn.Open(); //执行 int result = cmd.ExecuteNonQuery(); return(result); } catch (Exception ex) { throw ex; } //关闭数据库 finally { conn.Close(); } }
/// <summary> /// Constructor to be used to parse receoved IRC message. /// </summary> /// <param name="receivedLine">Received IRC message.</param> /// <param name="loggedinAccount">Account that is logged in to the IRC.</param> public IrcMessage(string receivedLine, TwitchCredentials loggedinAccount) { this.timestamp = DateTime.Now; this.messageSource = loggedinAccount; // First get all arguments if starts with @ if (receivedLine.StartsWith("@")) { MatchCollection ircTags = Regex.Matches(receivedLine, @"(?<arg>[\w-]+)=(?<value>[\w:#,-\/]*);?"); foreach (Match m in ircTags) { switch (m.Groups["arg"].Value) { case "color": nameColor = m.Groups["value"].Value; break; case "display-name": displayName = m.Groups["value"].Value; break; case "emotes": emotes = m.Groups["value"].Value; break; case "mod": moderator = (!string.IsNullOrEmpty(m.Groups["value"].Value) && m.Groups["value"].Value == "1"); break; case "subscriber": subscriber = (!string.IsNullOrEmpty(m.Groups["value"].Value) && m.Groups["value"].Value == "1"); break; case "turbo": turbo = (!string.IsNullOrEmpty(m.Groups["value"].Value) && m.Groups["value"].Value == "1"); break; case "user-id": userId = int.Parse(m.Groups["value"].Value); break; case "user-type": switch (m.Groups["value"].Value) { case "mod": userType = uType.MODERATOR; break; case "global_mod": userType = uType.GLOBALMODERATOR; break; case "admin": userType = uType.ADMIN; break; case "staff": userType = uType.STAFF; break; default: userType = uType.VIEWER; break; } break; } } } // Get the base IRC message //Match ircMessage = Regex.Match(receivedLine, @"(?<!\S)(?::(?:(?<author>\w+)!)?(?<host>\S+) )?(?<command>\w+)(?: (?!:)(?<args>.+?))?(?: :(?<message>.+))?$"); Match ircMessage = Regex.Match(receivedLine, @"(?<!\S)(?::(?:(?<author>\w+)!)?(?<host>\S+) )?(?<command>\w+)(?: (?<args>.+?))?(?: :(?<message>.+))?$"); author = ircMessage.Groups["author"].Value; host = ircMessage.Groups["host"].Value; command = ircMessage.Groups["command"].Value; arguments = ircMessage.Groups["args"].Value.Split(' '); message = ircMessage.Groups["message"].Value; }