Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace EvaTools
- {
- using EvaTools.Misc;
- using EvaTools.SQL;
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- public class BanAccount : Form
- {
- private Button button1;
- private Button button2;
- private IContainer components = null;
- private DateTimePicker dateTimePicker1;
- private DateTimePicker dateTimePicker2;
- private Label label1;
- private Label label2;
- private Label label3;
- private TextBox textBox1;
- private TextBox textBox2;
- private Label Username;
- public BanAccount()
- {
- this.InitializeComponent();
- }
- private void BanAccount_Load(object sender, EventArgs e)
- {
- this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
- this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
- this.dateTimePicker1.CustomFormat = "yyyy-MM-dd 00:00:00.000";
- this.dateTimePicker2.CustomFormat = "yyyy-MM-dd 00:00:00.000";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (QueryChecks.containsQuotes(this.textBox1.Text))
- {
- MessageBox.Show("Username field contains ' or \" symbols. It isn't allowed.");
- }
- else if (QueryChecks.containsQuotes(this.textBox2.Text))
- {
- MessageBox.Show("Reason field contains ' or \" symbols. It isn't allowed.");
- }
- else if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
- {
- MessageBox.Show("Punishment begin time is bigger as punishment end time. This isn't possible.");
- }
- else if (this.textBox1.Text.Length < 1)
- {
- MessageBox.Show("Username field is empty.");
- }
- else
- {
- sqlMain main = new sqlMain(dataStore.sqlConnectionString);
- int num = 0;
- string[] strArray = InitializeArrays.InitStringArray(new string[1]);
- main.SelectDB("ACCOUNT");
- if (main.ReadInt("select count(*) from TB_User where StrUserID='" + this.textBox1.Text + "'") < 1)
- {
- MessageBox.Show("User with such username not found.");
- }
- else
- {
- strArray = main.getSingleArray("select JID,StrUserID from TB_User where StrUserID='" + this.textBox1.Text + "'");
- if (main.ReadInt("select count(*) from _Punishment where UserJID='" + strArray[0] + "' and Executor='AutomatedPunisher'") > 0)
- {
- int num2 = main.ReadInt("select SerialNo from _Punishment where UserJID='" + strArray[0] + "'");
- main.exec("delete from _BlockedUser where SerialNo='" + num2 + "'");
- main.exec("delete from _Punishment where SerialNo='" + num2 + "'");
- MessageBox.Show("User was banned by automated punisher, and that punishment was removed from database.");
- }
- if (main.ReadInt("select count(*) from _BlockedUser where UserJID='" + strArray[0] + "'") > 0)
- {
- MessageBox.Show("This user is already blocked.");
- }
- else
- {
- 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')";
- main.exec(query);
- num = main.ReadInt("select top 1 SerialNo from _Punishment order by SerialNo desc");
- 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, "')" });
- main.exec(str2);
- MessageBox.Show("Account successfully banned.");
- base.Close();
- }
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- base.Close();
- }
- private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
- {
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing && (this.components != null))
- {
- this.components.Dispose();
- }
- base.Dispose(disposing);
- }
- private void InitializeComponent()
- {
- this.Username = new Label();
- this.textBox1 = new TextBox();
- this.dateTimePicker1 = new DateTimePicker();
- this.label1 = new Label();
- this.label2 = new Label();
- this.dateTimePicker2 = new DateTimePicker();
- this.label3 = new Label();
- this.textBox2 = new TextBox();
- this.button1 = new Button();
- this.button2 = new Button();
- base.SuspendLayout();
- this.Username.AutoSize = true;
- this.Username.Location = new Point(13, 13);
- this.Username.Name = "Username";
- this.Username.Size = new Size(0x37, 13);
- this.Username.TabIndex = 0;
- this.Username.Text = "Username";
- this.textBox1.Location = new Point(0x54, 6);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new Size(0xc6, 20);
- this.textBox1.TabIndex = 1;
- this.textBox1.TextChanged += new EventHandler(this.textBox1_TextChanged);
- this.dateTimePicker1.CustomFormat = "yyyy-MM-dd hh:mm:ss";
- this.dateTimePicker1.Location = new Point(0x54, 0x20);
- this.dateTimePicker1.Name = "dateTimePicker1";
- this.dateTimePicker1.Size = new Size(0xc6, 20);
- this.dateTimePicker1.TabIndex = 2;
- this.dateTimePicker1.ValueChanged += new EventHandler(this.dateTimePicker1_ValueChanged);
- this.label1.AutoSize = true;
- this.label1.Location = new Point(13, 0x26);
- this.label1.Name = "label1";
- this.label1.Size = new Size(0x41, 13);
- this.label1.TabIndex = 3;
- this.label1.Text = "Starting time";
- this.label2.AutoSize = true;
- this.label2.Location = new Point(13, 0x37);
- this.label2.Name = "label2";
- this.label2.Size = new Size(0x3e, 13);
- this.label2.TabIndex = 4;
- this.label2.Text = "Ending time";
- this.dateTimePicker2.CustomFormat = "yyyy-MM-dd hh:mm:ss";
- this.dateTimePicker2.Location = new Point(0x54, 0x37);
- this.dateTimePicker2.Name = "dateTimePicker2";
- this.dateTimePicker2.Size = new Size(200, 20);
- this.dateTimePicker2.TabIndex = 5;
- this.label3.AutoSize = true;
- this.label3.Location = new Point(13, 0x48);
- this.label3.Name = "label3";
- this.label3.Size = new Size(0x2c, 13);
- this.label3.TabIndex = 6;
- this.label3.Text = "Reason";
- this.textBox2.Location = new Point(0x54, 0x51);
- this.textBox2.Multiline = true;
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new Size(0x216, 0xad);
- this.textBox2.TabIndex = 7;
- this.textBox2.TextChanged += new EventHandler(this.textBox2_TextChanged);
- this.button1.Location = new Point(0x54, 0x116);
- this.button1.Name = "button1";
- this.button1.Size = new Size(0x216, 0x33);
- this.button1.TabIndex = 8;
- this.button1.Text = "Register punishment";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new EventHandler(this.button1_Click);
- this.button2.Location = new Point(0x54, 0x150);
- this.button2.Name = "button2";
- this.button2.Size = new Size(0x216, 50);
- this.button2.TabIndex = 9;
- this.button2.Text = "Close";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new EventHandler(this.button2_Click);
- base.AutoScaleDimensions = new SizeF(6f, 13f);
- base.AutoScaleMode = AutoScaleMode.Font;
- base.ClientSize = new Size(0x292, 0x196);
- base.Controls.Add(this.button2);
- base.Controls.Add(this.button1);
- base.Controls.Add(this.textBox2);
- base.Controls.Add(this.label3);
- base.Controls.Add(this.dateTimePicker2);
- base.Controls.Add(this.label2);
- base.Controls.Add(this.label1);
- base.Controls.Add(this.dateTimePicker1);
- base.Controls.Add(this.textBox1);
- base.Controls.Add(this.Username);
- base.FormBorderStyle = FormBorderStyle.Fixed3D;
- base.Name = "BanAccount";
- this.Text = "BanAccount";
- base.Load += new EventHandler(this.BanAccount_Load);
- base.ResumeLayout(false);
- base.PerformLayout();
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement