namespace SHNDecrypt
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class columnMultiply : Form
    {
        private Button btnGo;
        private CheckBox checkBox1;
        private ComboBox comboBox1;
        private IContainer components;
        private frmMain frmColMulti;
        private Label label3;
        private Label label4;
        private TextBox txtFactor;

        public columnMultiply(frmMain form)
        {
            this.frmColMulti = form;
            this.InitializeComponent();
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            int num = this.frmColMulti.file.getColIndex(this.comboBox1.Items[this.comboBox1.SelectedIndex].ToString());
            if (num >= 0)
            {
                double num2 = 0.0;
                try
                {
                    num2 = double.Parse(this.txtFactor.Text);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                    return;
                }
                string str = this.frmColMulti.file.table.Columns[num].DataType.ToString();
                if (!this.checkBox1.Checked)
                {
                    for (int i = 0; i < this.frmColMulti.file.table.Rows.Count; i++)
                    {
                        try
                        {
                            switch (str)
                            {
                                case "System.UInt16":
                                {
                                    this.frmColMulti.file.table.Rows[i][num] = (ushort) (((ushort) this.frmColMulti.file.table.Rows[i][num]) * num2);
                                    continue;
                                }
                                case "System.UInt32":
                                {
                                    this.frmColMulti.file.table.Rows[i][num] = (uint) (((uint) this.frmColMulti.file.table.Rows[i][num]) * num2);
                                    continue;
                                }
                                case "System.SByte":
                                {
                                    this.frmColMulti.file.table.Rows[i][num] = (sbyte) (((sbyte) this.frmColMulti.file.table.Rows[i][num]) * num2);
                                    continue;
                                }
                                case "System.Byte":
                                {
                                    this.frmColMulti.file.table.Rows[i][num] = (byte) (((byte) this.frmColMulti.file.table.Rows[i][num]) * num2);
                                    continue;
                                }
                            }
                            this.frmColMulti.file.table.Rows[i][num] = (int) (((int) this.frmColMulti.file.table.Rows[i][num]) * num2);
                        }
                        catch (Exception exception2)
                        {
                            MessageBox.Show(exception2.Message);
                            break;
                        }
                    }
                }
                else if (this.frmColMulti.dataGrid.SelectedRows.Count != 0)
                {
                    foreach (DataGridViewRow row in this.frmColMulti.dataGrid.SelectedRows)
                    {
                        try
                        {
                            switch (str)
                            {
                                case "System.UInt16":
                                {
                                    this.frmColMulti.file.table.Rows[row.Index][num] = (ushort) (((ushort) this.frmColMulti.file.table.Rows[row.Index][num]) * num2);
                                    continue;
                                }
                                case "System.UInt32":
                                {
                                    this.frmColMulti.file.table.Rows[row.Index][num] = (uint) (((uint) this.frmColMulti.file.table.Rows[row.Index][num]) * num2);
                                    continue;
                                }
                                case "System.SByte":
                                {
                                    this.frmColMulti.file.table.Rows[row.Index][num] = (sbyte) (((sbyte) this.frmColMulti.file.table.Rows[row.Index][num]) * num2);
                                    continue;
                                }
                                case "System.Byte":
                                {
                                    this.frmColMulti.file.table.Rows[row.Index][num] = (byte) (((byte) this.frmColMulti.file.table.Rows[row.Index][num]) * num2);
                                    continue;
                                }
                            }
                            this.frmColMulti.file.table.Rows[row.Index][num] = (int) (((int) this.frmColMulti.file.table.Rows[row.Index][num]) * num2);
                        }
                        catch (Exception exception3)
                        {
                            MessageBox.Show(exception3.Message);
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select the appropriate rows to modify.");
                    this.frmColMulti.SQLStatus.Text = "Please select the appropriate rows to modify.";
                }
                this.frmColMulti.SQLStatus.Text = this.comboBox1.SelectedItem.ToString() + " column has been multiplied by " + num2.ToString() + ".";
            }
        }

        private void columnMultiply_Load(object sender, EventArgs e)
        {
            if (this.frmColMulti.file == null)
            {
                base.Close();
            }
            else
            {
                this.init();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void init()
        {
            if (this.frmColMulti.file.table != null)
            {
                this.comboBox1.Items.Clear();
                for (int i = 0; i < this.frmColMulti.file.table.Columns.Count; i++)
                {
                    this.comboBox1.Items.Add(this.frmColMulti.file.table.Columns[i].ColumnName);
                }
                this.comboBox1.SelectedIndex = 0;
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(columnMultiply));
            this.btnGo = new Button();
            this.txtFactor = new TextBox();
            this.comboBox1 = new ComboBox();
            this.checkBox1 = new CheckBox();
            this.label3 = new Label();
            this.label4 = new Label();
            base.SuspendLayout();
            this.btnGo.Location = new Point(0x3f, 0x41);
            this.btnGo.Name = "btnGo";
            this.btnGo.Size = new Size(0xd7, 30);
            this.btnGo.TabIndex = 6;
            this.btnGo.Text = "Multiply";
            this.btnGo.UseVisualStyleBackColor = true;
            this.btnGo.Click += new EventHandler(this.btnGo_Click);
            this.txtFactor.Location = new Point(0x3f, 0x27);
            this.txtFactor.Name = "txtFactor";
            this.txtFactor.Size = new Size(0xd7, 20);
            this.txtFactor.TabIndex = 5;
            this.txtFactor.Text = "1";
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Location = new Point(0x3f, 12);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new Size(0xd7, 0x15);
            this.comboBox1.TabIndex = 8;
            this.checkBox1.AutoSize = true;
            this.checkBox1.Location = new Point(0x3f, 0x65);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.Size = new Size(0x52, 0x11);
            this.checkBox1.TabIndex = 0x15;
            this.checkBox1.Text = "In Selection";
            this.checkBox1.UseVisualStyleBackColor = true;
            this.label3.AutoSize = true;
            this.label3.Location = new Point(12, 15);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x2d, 13);
            this.label3.TabIndex = 20;
            this.label3.Text = "Column:";
            this.label4.AutoSize = true;
            this.label4.Location = new Point(0x11, 0x2a);
            this.label4.Name = "label4";
            this.label4.Size = new Size(40, 13);
            this.label4.TabIndex = 0x13;
            this.label4.Text = "Factor:";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x121, 0x7f);
            base.Controls.Add(this.checkBox1);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.txtFactor);
            base.Controls.Add(this.btnGo);
            base.Controls.Add(this.comboBox1);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "columnMultiply";
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "Column Multiplier";
            base.Load += new EventHandler(this.columnMultiply_Load);
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

