Advertisement
csaki

SRO evatools banaccount source

Jul 24th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.79 KB | None | 0 0
  1. namespace EvaTools
  2. {
  3.     using EvaTools.Misc;
  4.     using EvaTools.SQL;
  5.     using System;
  6.     using System.ComponentModel;
  7.     using System.Drawing;
  8.     using System.Windows.Forms;
  9.  
  10.     public class BanAccount : Form
  11.     {
  12.         private Button button1;
  13.         private Button button2;
  14.         private IContainer components = null;
  15.         private DateTimePicker dateTimePicker1;
  16.         private DateTimePicker dateTimePicker2;
  17.         private Label label1;
  18.         private Label label2;
  19.         private Label label3;
  20.         private TextBox textBox1;
  21.         private TextBox textBox2;
  22.         private Label Username;
  23.  
  24.         public BanAccount()
  25.         {
  26.             this.InitializeComponent();
  27.         }
  28.  
  29.         private void BanAccount_Load(object sender, EventArgs e)
  30.         {
  31.             this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
  32.             this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
  33.             this.dateTimePicker1.CustomFormat = "yyyy-MM-dd 00:00:00.000";
  34.             this.dateTimePicker2.CustomFormat = "yyyy-MM-dd 00:00:00.000";
  35.         }
  36.  
  37.         private void button1_Click(object sender, EventArgs e)
  38.         {
  39.             if (QueryChecks.containsQuotes(this.textBox1.Text))
  40.             {
  41.                 MessageBox.Show("Username field contains ' or \" symbols. It isn't allowed.");
  42.             }
  43.             else if (QueryChecks.containsQuotes(this.textBox2.Text))
  44.             {
  45.                 MessageBox.Show("Reason field contains ' or \" symbols. It isn't allowed.");
  46.             }
  47.             else if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
  48.             {
  49.                 MessageBox.Show("Punishment begin time is bigger as punishment end time. This isn't possible.");
  50.             }
  51.             else if (this.textBox1.Text.Length < 1)
  52.             {
  53.                 MessageBox.Show("Username field is empty.");
  54.             }
  55.             else
  56.             {
  57.                 sqlMain main = new sqlMain(dataStore.sqlConnectionString);
  58.                 int num = 0;
  59.                 string[] strArray = InitializeArrays.InitStringArray(new string[1]);
  60.                 main.SelectDB("ACCOUNT");
  61.                 if (main.ReadInt("select count(*) from TB_User where StrUserID='" + this.textBox1.Text + "'") < 1)
  62.                 {
  63.                     MessageBox.Show("User with such username not found.");
  64.                 }
  65.                 else
  66.                 {
  67.                     strArray = main.getSingleArray("select JID,StrUserID from TB_User where StrUserID='" + this.textBox1.Text + "'");
  68.                     if (main.ReadInt("select count(*) from _Punishment where UserJID='" + strArray[0] + "' and Executor='AutomatedPunisher'") > 0)
  69.                     {
  70.                         int num2 = main.ReadInt("select SerialNo from _Punishment where UserJID='" + strArray[0] + "'");
  71.                         main.exec("delete from _BlockedUser where SerialNo='" + num2 + "'");
  72.                         main.exec("delete from _Punishment where SerialNo='" + num2 + "'");
  73.                         MessageBox.Show("User was banned by automated punisher, and that punishment was removed from database.");
  74.                     }
  75.                     if (main.ReadInt("select count(*) from _BlockedUser where UserJID='" + strArray[0] + "'") > 0)
  76.                     {
  77.                         MessageBox.Show("This user is already blocked.");
  78.                     }
  79.                     else
  80.                     {
  81.                         string query = "insert into _Punishment(UserJID,Type,Executor,Shard,CharName,CharInfo,PosInfo,Guide,Description,RaiseTime,BlockStartTime,BlockEndTime,PunishTime,Status) values('" + strArray[0] + "','1','EvaTools','0','','','','" + this.textBox2.Text + "','" + this.textBox2.Text + "','" + this.dateTimePicker1.Text + "','" + this.dateTimePicker1.Text + "','" + this.dateTimePicker1.Text + "','" + this.dateTimePicker2.Text + "','0')";
  82.                         main.exec(query);
  83.                         num = main.ReadInt("select top 1 SerialNo from _Punishment order by SerialNo desc");
  84.                         string str2 = string.Concat(new object[] { "insert into _BlockedUser(UserJID,UserID,Type,SerialNo,timeBegin,timeEnd) values('", strArray[0], "','", strArray[1], "','1','", num, "','", this.dateTimePicker1.Text, "','", this.dateTimePicker2.Text, "')" });
  85.                         main.exec(str2);
  86.                         MessageBox.Show("Account successfully banned.");
  87.                         base.Close();
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.  
  93.         private void button2_Click(object sender, EventArgs e)
  94.         {
  95.             base.Close();
  96.         }
  97.  
  98.         private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  99.         {
  100.         }
  101.  
  102.         protected override void Dispose(bool disposing)
  103.         {
  104.             if (disposing && (this.components != null))
  105.             {
  106.                 this.components.Dispose();
  107.             }
  108.             base.Dispose(disposing);
  109.         }
  110.  
  111.         private void InitializeComponent()
  112.         {
  113.             this.Username = new Label();
  114.             this.textBox1 = new TextBox();
  115.             this.dateTimePicker1 = new DateTimePicker();
  116.             this.label1 = new Label();
  117.             this.label2 = new Label();
  118.             this.dateTimePicker2 = new DateTimePicker();
  119.             this.label3 = new Label();
  120.             this.textBox2 = new TextBox();
  121.             this.button1 = new Button();
  122.             this.button2 = new Button();
  123.             base.SuspendLayout();
  124.             this.Username.AutoSize = true;
  125.             this.Username.Location = new Point(13, 13);
  126.             this.Username.Name = "Username";
  127.             this.Username.Size = new Size(0x37, 13);
  128.             this.Username.TabIndex = 0;
  129.             this.Username.Text = "Username";
  130.             this.textBox1.Location = new Point(0x54, 6);
  131.             this.textBox1.Name = "textBox1";
  132.             this.textBox1.Size = new Size(0xc6, 20);
  133.             this.textBox1.TabIndex = 1;
  134.             this.textBox1.TextChanged += new EventHandler(this.textBox1_TextChanged);
  135.             this.dateTimePicker1.CustomFormat = "yyyy-MM-dd hh:mm:ss";
  136.             this.dateTimePicker1.Location = new Point(0x54, 0x20);
  137.             this.dateTimePicker1.Name = "dateTimePicker1";
  138.             this.dateTimePicker1.Size = new Size(0xc6, 20);
  139.             this.dateTimePicker1.TabIndex = 2;
  140.             this.dateTimePicker1.ValueChanged += new EventHandler(this.dateTimePicker1_ValueChanged);
  141.             this.label1.AutoSize = true;
  142.             this.label1.Location = new Point(13, 0x26);
  143.             this.label1.Name = "label1";
  144.             this.label1.Size = new Size(0x41, 13);
  145.             this.label1.TabIndex = 3;
  146.             this.label1.Text = "Starting time";
  147.             this.label2.AutoSize = true;
  148.             this.label2.Location = new Point(13, 0x37);
  149.             this.label2.Name = "label2";
  150.             this.label2.Size = new Size(0x3e, 13);
  151.             this.label2.TabIndex = 4;
  152.             this.label2.Text = "Ending time";
  153.             this.dateTimePicker2.CustomFormat = "yyyy-MM-dd hh:mm:ss";
  154.             this.dateTimePicker2.Location = new Point(0x54, 0x37);
  155.             this.dateTimePicker2.Name = "dateTimePicker2";
  156.             this.dateTimePicker2.Size = new Size(200, 20);
  157.             this.dateTimePicker2.TabIndex = 5;
  158.             this.label3.AutoSize = true;
  159.             this.label3.Location = new Point(13, 0x48);
  160.             this.label3.Name = "label3";
  161.             this.label3.Size = new Size(0x2c, 13);
  162.             this.label3.TabIndex = 6;
  163.             this.label3.Text = "Reason";
  164.             this.textBox2.Location = new Point(0x54, 0x51);
  165.             this.textBox2.Multiline = true;
  166.             this.textBox2.Name = "textBox2";
  167.             this.textBox2.Size = new Size(0x216, 0xad);
  168.             this.textBox2.TabIndex = 7;
  169.             this.textBox2.TextChanged += new EventHandler(this.textBox2_TextChanged);
  170.             this.button1.Location = new Point(0x54, 0x116);
  171.             this.button1.Name = "button1";
  172.             this.button1.Size = new Size(0x216, 0x33);
  173.             this.button1.TabIndex = 8;
  174.             this.button1.Text = "Register punishment";
  175.             this.button1.UseVisualStyleBackColor = true;
  176.             this.button1.Click += new EventHandler(this.button1_Click);
  177.             this.button2.Location = new Point(0x54, 0x150);
  178.             this.button2.Name = "button2";
  179.             this.button2.Size = new Size(0x216, 50);
  180.             this.button2.TabIndex = 9;
  181.             this.button2.Text = "Close";
  182.             this.button2.UseVisualStyleBackColor = true;
  183.             this.button2.Click += new EventHandler(this.button2_Click);
  184.             base.AutoScaleDimensions = new SizeF(6f, 13f);
  185.             base.AutoScaleMode = AutoScaleMode.Font;
  186.             base.ClientSize = new Size(0x292, 0x196);
  187.             base.Controls.Add(this.button2);
  188.             base.Controls.Add(this.button1);
  189.             base.Controls.Add(this.textBox2);
  190.             base.Controls.Add(this.label3);
  191.             base.Controls.Add(this.dateTimePicker2);
  192.             base.Controls.Add(this.label2);
  193.             base.Controls.Add(this.label1);
  194.             base.Controls.Add(this.dateTimePicker1);
  195.             base.Controls.Add(this.textBox1);
  196.             base.Controls.Add(this.Username);
  197.             base.FormBorderStyle = FormBorderStyle.Fixed3D;
  198.             base.Name = "BanAccount";
  199.             this.Text = "BanAccount";
  200.             base.Load += new EventHandler(this.BanAccount_Load);
  201.             base.ResumeLayout(false);
  202.             base.PerformLayout();
  203.         }
  204.  
  205.         private void textBox1_TextChanged(object sender, EventArgs e)
  206.         {
  207.         }
  208.  
  209.         private void textBox2_TextChanged(object sender, EventArgs e)
  210.         {
  211.         }
  212.     }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement