コード例 #1
0
        public MainPage(LoginPage login)
        {
            InitializeComponent();

            InformationTextBox.Visible = false;
            InformationTextBox.Enabled = false;

            conn = DBUtils.DBConnection();

            this.login = login;

            this.FormClosed  += new FormClosedEventHandler(MainPage_Closed);
            this.FormClosing += new FormClosingEventHandler(MainPage_Closing);

            string sql = "SELECT * FROM StockManagementSystemDatabase.dbo.Product_Cards_Table";

            DBUtils.OpenConnection(conn);

            sCommand = new SqlCommand(sql, conn);
            sAdapter = new SqlDataAdapter(sCommand);
            sBuilder = new SqlCommandBuilder(sAdapter);
            cardSet  = new DataSet();
            sAdapter.Fill(cardSet, "StockManagementSystemDatabase.dbo.Product_Cards_Table");
            cardTable = cardSet.Tables["StockManagementSystemDatabase.dbo.Product_Cards_Table"];

            DBUtils.CloseConnection(conn);

            DataGridView_Products.DataSource    = cardSet.Tables["StockManagementSystemDatabase.dbo.Product_Cards_Table"];
            DataGridView_Products.ReadOnly      = true;
            DataGridView_Products.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        }
コード例 #2
0
        private void MovePage_Load(object sender, EventArgs e)
        {
            // TODO: Bu kod satırı 'stockManagementSystemDatabaseDataSet1.Move_Table' tablosuna veri yükler. Bunu gerektiği şekilde taşıyabilir, veya kaldırabilirsiniz.
            this.move_TableTableAdapter.Fill(this.stockManagementSystemDatabaseDataSet1.Move_Table);
            // TODO: Bu kod satırı 'stockManagementSystemDatabaseDataSet.Move_Table' tablosuna veri yükler. Bunu gerektiği şekilde taşıyabilir, veya kaldırabilirsiniz.
            this.move_TableTableAdapter.Fill(this.stockManagementSystemDatabaseDataSet.Move_Table);
            ProductTextBox.Text    = product;
            ProductTextBox.Enabled = false;

            InsertPanel.Visible = false;
            GridPanel.Visible   = true;

            string sql = "SELECT * FROM StockManagementSystemDatabase.dbo.Move_Table WHERE MoveProductID='" + byID + "';";

            DBUtils.OpenConnection(connection);

            SqlCommand        sCommand = new SqlCommand(sql, connection);
            SqlDataAdapter    sAdapter = new SqlDataAdapter(sCommand);
            SqlCommandBuilder sBuilder = new SqlCommandBuilder(sAdapter);
            DataSet           cardSet  = new DataSet();

            sAdapter.Fill(cardSet, "StockManagementSystemDatabase.dbo.Move_Table");
            DataTable cardTable = cardSet.Tables["StockManagementSystemDatabase.dbo.Move_Table"];

            DBUtils.CloseConnection(connection);

            DataGridView_ByID.DataSource    = cardSet.Tables["StockManagementSystemDatabase.dbo.Move_Table"];
            DataGridView_ByID.ReadOnly      = true;
            DataGridView_ByID.ReadOnly      = true;
            DataGridView_ByID.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        }
コード例 #3
0
        private void TurnBackButton_Click(object sender, EventArgs e)
        {
            DBUtils.CloseConnection(login.getConnection());
            login.Visible = true;
            login.getPasswordTextBox().Clear();

            this.Dispose();
            this.Close();
        }
コード例 #4
0
        private void MainPage_Closed(object sender, FormClosedEventArgs e)
        {
            DBUtils.CloseConnection(login.getConnection());
            login.Visible = true;
            login.getPasswordTextBox().Clear();

            this.Dispose();
            this.Close();
        }
コード例 #5
0
        public void FillDataGridView()
        {
            SqlDataAdapter da;
            DataSet        ds;

            da = new SqlDataAdapter("Select * From StockManagementSystemDatabase.dbo.Product_Cards_Table", conn);
            ds = new DataSet();
            DBUtils.OpenConnection(conn);
            da.Fill(ds, "StockManagementSystemDatabase.dbo.Product_Cards_Table");
            DataGridView_Products.DataSource = ds.Tables["StockManagementSystemDatabase.dbo.Product_Cards_Table"];
            DBUtils.CloseConnection(conn);
        }
コード例 #6
0
        private void FillDataGridView()
        {
            string         sqlstring = "Select * From StockManagementSystemDatabase.dbo.Move_Table WHERE MoveProductID='" + byID + "';";
            SqlDataAdapter da;
            DataSet        ds;

            da = new SqlDataAdapter(sqlstring, connection);
            ds = new DataSet();
            DBUtils.OpenConnection(connection);
            da.Fill(ds, "StockManagementSystemDatabase.dbo.Move_Table");
            DataGridView_ByID.DataSource = ds.Tables["StockManagementSystemDatabase.dbo.Move_Table"];
            DBUtils.CloseConnection(connection);
            SizeMoves = DataGridView_ByID.RowCount;
        }
コード例 #7
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (DataGridView_Products.SelectedCells.Count > 0)
                {
                    int selectedrowindex = DataGridView_Products.SelectedCells[0].RowIndex;

                    DataGridViewRow selectedRow = DataGridView_Products.Rows[selectedrowindex];

                    Product temp = new Product(Convert.ToInt32(selectedRow.Cells[0].Value), selectedRow.Cells[1].Value.ToString(),
                                               selectedRow.Cells[2].Value.ToString(), Convert.ToInt32(selectedRow.Cells[3].Value),
                                               Convert.ToInt32(selectedRow.Cells[4].Value), selectedRow.Cells[5].Value.ToString());
                    Console.WriteLine("delete, temp->\n" + temp.ToString());
                    string     sql     = "DELETE FROM StockManagementSystemDatabase.dbo.Product_Cards_Table WHERE ProductID=@ProductID";
                    SqlCommand command = new SqlCommand(sql, conn);
                    command.Parameters.AddWithValue("@ProductID", temp.getID());

                    DBUtils.OpenConnection(conn);
                    command.ExecuteNonQuery();  //Product_Cards_Table'dan silme
                    DBUtils.CloseConnection(conn);

                    Console.WriteLine("\n>>>>>>>>>>>>>>>>>>>>>Deleted product, deleted product moves!<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
                    string     sql2     = "DELETE FROM StockManagementSystemDatabase.dbo.Move_Table WHERE MoveProductID=@MoveProductID";
                    SqlCommand command2 = new SqlCommand(sql2, conn);
                    command2.Parameters.AddWithValue("@MoveProductID", temp.getID());

                    DBUtils.OpenConnection(conn);
                    command2.ExecuteNonQuery(); //Move_Table'dan silme
                    DBUtils.CloseConnection(conn);

                    MessageBox.Show("Product deleted!", "SUCCESS DELETED");
                }
                else
                {
                    MessageBox.Show("Please, select the element to delete!", "SELECT DELETE ELEMENT");
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.ToString(), "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(conn);
                FillDataGridView();
            }
        }
コード例 #8
0
        private void MovePage_Closed(object sender, FormClosedEventArgs e)
        {
            DBUtils.CloseConnection(mainpage.getlogin().getConnection()); //giris sayfasina doner
            mainpage.getlogin().Visible = true;
            mainpage.getlogin().getPasswordTextBox().Clear();

            this.Dispose();
            this.Close();

            DBUtils.CloseConnection(mainpage.getConnection());
            mainpage.Dispose();
            mainpage.Close();

            /*DBUtils.CloseConnection(mainpage.getlogin().getConnection()); //toptan ciksin diye, ust 3 satiri sil bunu yorumdan cikar
             * mainpage.getlogin().Dispose();
             * mainpage.getlogin().Close();*/
        }
コード例 #9
0
        public static void GetTable(SqlConnection conn, DataTable table, int DataTableSize)
        {
            // Here we create a DataTable with four columns.
            table = new DataTable();
            table.Columns.Add("id", typeof(int));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("unit", typeof(string));
            table.Columns.Add("quantity", typeof(int));

            DBUtils.OpenConnection(conn);

            ///Console.Read();

            string        cmd        = "Select * from Product_Card_Table";
            SqlCommand    command    = new SqlCommand(cmd, conn);
            SqlDataReader dataReader = command.ExecuteReader();

            Product temp = new Product();
            int     size = 0;

            while (dataReader.Read())
            {
                temp.setID((int)dataReader.GetValue(0));
                temp.setName(dataReader.GetValue(1).ToString());
                temp.setUnit(dataReader.GetValue(2).ToString());
                temp.setQuantity((int)dataReader.GetValue(3));

                table.Rows.Add(temp.getID(), temp.getName(), temp.getUnit(), temp.getQuantity());
                size++;
            }

            DataTableSize = size;

            /*int i = 0;
             * foreach (DataRow row in table.Rows)
             * {
             *  Console.WriteLine(table.Rows[i].Field<int>(0) + "\t" + table.Rows[i].Field<string>(1) + "\t"
             + table.Rows[i].Field<string>(2) + "\t" + table.Rows[i].Field<int>(3));
             +  i++;
             + }*/

            dataReader.Close();
            command.Dispose();
            DBUtils.CloseConnection(conn);
        }
コード例 #10
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (DataGridView_ByID.SelectedCells.Count > 0)
                {
                    int selectedrowindex = DataGridView_ByID.SelectedCells[0].RowIndex;

                    DataGridViewRow selectedRow = DataGridView_ByID.Rows[selectedrowindex];

                    MoveProduct temp = new MoveProduct(Convert.ToInt32(selectedRow.Cells[0].Value), selectedRow.Cells[1].Value.ToString(),
                                                       Convert.ToDateTime(selectedRow.Cells[2].Value), Convert.ToInt32(selectedRow.Cells[3].Value), selectedRow.Cells[4].Value.ToString());

                    string     sql     = "DELETE FROM StockManagementSystemDatabase.dbo.Move_Table WHERE MoveProductID=@MoveProductID and MoveDate=@MoveDate and MoveQuantity=@MoveQuantity";
                    SqlCommand command = new SqlCommand(sql, connection);
                    command.Parameters.AddWithValue("@MoveProductID", temp.getMoveProductID());
                    command.Parameters.AddWithValue("@MoveDate", temp.getMoveDate());
                    command.Parameters.AddWithValue("@MoveQuantity", temp.getMoveQuantity());
                    DBUtils.OpenConnection(connection);
                    command.ExecuteNonQuery();
                    DBUtils.CloseConnection(connection);
                    MessageBox.Show("Product Move deleted!", "SUCCESS DELETED");
                }
                else
                {
                    MessageBox.Show("Please, select the element to delete!", "SELECT DELETE ELEMENT");
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.ToString(), "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(connection);
                FillDataGridView();
            }
        }
コード例 #11
0
        private void AddNewProduct_Click(object sender, EventArgs e)
        {
            if (IDTextBox.Text == "")
            {
                MessageBox.Show("ID can't be blank!!!", "Blank ID");
            }
            else if (NameTextBox.Text == "")
            {
                MessageBox.Show("Name can't be blank!!!", "Blank Name");
            }
            else if (UnitListComboBox.Text == "")
            {
                MessageBox.Show("Unit can't be blank!!!", "Blank Quantity");
            }
            else if (QuantityTextBox.Text == "")
            {
                MessageBox.Show("Quantity can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyTextBox.Text == "")
            {
                MessageBox.Show("Money can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyUnitComboBox.Text == "")
            {
                MessageBox.Show("Money Unit can't be blank!!!", "Blank Quantity");
            }
            else
            {
                int size   = -1;
                int result = -1;
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("id", typeof(int));
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("unit", typeof(string));
                    dt.Columns.Add("quantity", typeof(int));
                    dt.Columns.Add("money", typeof(int));
                    dt.Columns.Add("moneyunit", typeof(string));
                    size = 0;

                    DBUtils.OpenConnection(conn);
                    string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID='" + IDTextBox.Text + "' or ProductName='" + NameTextBox.Text.ToUpper() + "';";

                    SqlCommand    command    = new SqlCommand(cmd, conn);
                    SqlDataReader dataReader = command.ExecuteReader();

                    Product temp = new Product();
                    while (dataReader.Read())
                    {
                        temp.setID((int)dataReader.GetValue(0));
                        temp.setName(dataReader.GetValue(1).ToString().ToUpper());
                        temp.setUnit(dataReader.GetValue(2).ToString());
                        temp.setQuantity((int)dataReader.GetValue(3));
                        temp.setMoney((int)dataReader.GetValue(4));
                        temp.setMoneyunit(dataReader.GetValue(5).ToString());

                        if (temp.getID() == Int32.Parse(IDTextBox.Text) | (temp.getName().ToUpper().CompareTo(NameTextBox.Text.ToUpper()) == 0))
                        {
                            dt.Rows.Add(temp.getID(), temp.getName().ToUpper(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());
                            Console.WriteLine(dt.Rows[size].Field <int>(0) + "\t" + dt.Rows[size].Field <string>(1) + "\t"
                                              + dt.Rows[size].Field <string>(2) + "\t" + dt.Rows[size].Field <int>(3) + "\t"
                                              + dt.Rows[size].Field <int>(4) + "\t" + dt.Rows[size].Field <string>(5));
                            Console.WriteLine("BYID - > size:" + size);
                            size++;
                        }
                    }
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    if (size == 0)
                    {
                        string Query = "insert into StockManagementSystemDatabase.dbo.Product_Cards_Table(ProductID,ProductName,ProductUnit,ProductQuantity, ProductMoney, ProductMoneyUnit) " +
                                       "values('" + this.IDTextBox.Text + "','" + this.NameTextBox.Text.ToUpper() + "','" + this.UnitListComboBox.Text + "','" + this.QuantityTextBox.Text +
                                       "','" + this.MoneyTextBox.Text + "','" + this.MoneyUnitComboBox.Text + "');";

                        SqlCommand MyCommand = new SqlCommand(Query, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand.ExecuteNonQuery();
                        MessageBox.Show("Save product", "SUCCESS INSERT");

                        //FillDataGridView();

                        cardTable.Rows.Add(this.IDTextBox.Text, this.NameTextBox.Text.ToUpper(), this.UnitListComboBox.Text, this.QuantityTextBox.Text, this.MoneyTextBox.Text, this.MoneyUnitComboBox.Text);
                        DataGridView_Products.DataSource = cardTable;
                        DataGridView_Products.Refresh();


                        string Query2 = "insert into StockManagementSystemDatabase.dbo.Move_Table(MoveProductID,MoveType,MoveDate,MoveQuantity,MoveQuantityUnit) " +
                                        "values('" + this.IDTextBox.Text + "','entry','" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + this.QuantityTextBox.Text + "','" + this.UnitListComboBox.Text + "');";

                        SqlCommand MyCommand2 = new SqlCommand(Query2, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand2.ExecuteNonQuery();
                        DBUtils.CloseConnection(conn);


                        result = 1;
                    }
                    else
                    {
                        result = 2;
                    }
                }
                catch
                {
                    if (result == 2)
                    {
                        MessageBox.Show("Same Product", "WARNING");
                        IDTextBox.Clear();
                        NameTextBox.Clear();
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("NOLUYO!");
                    }
                }
                finally
                {
                    DBUtils.CloseConnection(conn);
                    DataGridView_Products.DataSource = cardTable;
                    DataGridView_Products.Refresh();
                    FillDataGridView();

                    IDTextBox.Clear();
                    NameTextBox.Clear();
                    UnitListComboBox.Text = "";
                    QuantityTextBox.Clear();
                    MoneyTextBox.Clear();
                    MoneyUnitComboBox.Text = "";
                }
            }
        }
コード例 #12
0
        private void UpdateThisButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id", typeof(int));
                dt.Columns.Add("name", typeof(string));
                dt.Columns.Add("unit", typeof(string));
                dt.Columns.Add("quantity", typeof(int));
                dt.Columns.Add("money", typeof(int));
                dt.Columns.Add("moneyunit", typeof(string));

                DBUtils.OpenConnection(conn);
                string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID=" + IDTextBox.Text + ";";

                SqlCommand    command    = new SqlCommand(cmd, conn);
                SqlDataReader dataReader = command.ExecuteReader();

                if (!dataReader.Read())
                {
                    MessageBox.Show("This product already exists.", "EXIST");
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);
                }
                else
                {
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    string Query = "update StockManagementSystemDatabase.dbo.Product_Cards_Table set ProductID='" + IDTextBox.Text
                                   + "',ProductName='" + NameTextBox.Text + "',ProductUnit='" + UnitListComboBox.Text + "',ProductQuantity='" + QuantityTextBox.Text
                                   + "',ProductMoney='" + this.MoneyTextBox.Text + "',ProductMoneyUnit='" + this.MoneyUnitComboBox.Text + "' WHERE ProductID=@ProductID;";

                    SqlCommand MyCommand = new SqlCommand(Query, conn);

                    MyCommand.Parameters.AddWithValue("@ProductID", IDTextBox.Text.ToString());

                    DBUtils.OpenConnection(conn);
                    MyCommand.ExecuteNonQuery();
                    MessageBox.Show("Update product", "SUCCESS UPDATE");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(conn);
                FillDataGridView();

                InformationTextBox.Visible = false;
                AddNewProduct.Visible      = true;

                IDTextBox.Enabled   = true;
                NameTextBox.Enabled = true;

                IDTextBox.Clear();
                NameTextBox.Clear();
                UnitListComboBox.Text = "";
                QuantityTextBox.Clear();
                MoneyTextBox.Clear();
                MoneyUnitComboBox.Text = "";
            }
        }
コード例 #13
0
        private void SearchProduct_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("name", typeof(string));
            dt.Columns.Add("unit", typeof(string));
            dt.Columns.Add("quantity", typeof(int));
            dt.Columns.Add("money", typeof(int));
            dt.Columns.Add("moneyunit", typeof(string));

            int size      = 0;
            int noChecked = 1;

            try
            {
                DBUtils.OpenConnection(conn);
                string cmd;
                if (ByIDRadioButton.Checked == false && ByNameRadioButton.Checked == false)
                {
                    noChecked = 0;
                }
                else
                {
                    if (ByIDRadioButton.Checked == true)
                    {
                        cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID=" + SearchElementTextBox.Text + ";";
                    }
                    else /*if (ByNameRadioButton.Checked == true)*/
                    {
                        cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductName='" + SearchElementTextBox.Text + "';";
                    }

                    SqlCommand    command    = new SqlCommand(cmd, conn);
                    SqlDataReader dataReader = command.ExecuteReader();

                    Product temp = new Product();
                    while (dataReader.Read())
                    {
                        temp.setID((int)dataReader.GetValue(0));
                        temp.setName(dataReader.GetValue(1).ToString());
                        temp.setUnit(dataReader.GetValue(2).ToString());
                        temp.setQuantity((int)dataReader.GetValue(3));
                        temp.setMoney((int)dataReader.GetValue(4));
                        temp.setMoneyunit(dataReader.GetValue(5).ToString());

                        if (ByIDRadioButton.Checked == true && temp.getID() == Int32.Parse(SearchElementTextBox.Text))
                        {
                            dt.Rows.Add(temp.getID(), temp.getName(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());
                            Console.WriteLine(dt.Rows[size].Field <int>(0) + "\t" + dt.Rows[size].Field <string>(1) + "\t"
                                              + dt.Rows[size].Field <string>(2) + "\t" + dt.Rows[size].Field <int>(3) + "\t"
                                              + dt.Rows[size].Field <int>(4) + "\t" + dt.Rows[size].Field <string>(5));
                            size++;
                        }
                        else if (ByNameRadioButton.Checked == true && temp.getName() == SearchElementTextBox.Text.ToString())
                        {
                            dt.Rows.Add(temp.getID(), temp.getName(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());
                            Console.WriteLine(dt.Rows[size].Field <int>(0) + "\t" + dt.Rows[size].Field <string>(1) + "\t"
                                              + dt.Rows[size].Field <string>(2) + "\t" + dt.Rows[size].Field <int>(3) + "\t"
                                              + dt.Rows[size].Field <int>(4) + "\t" + dt.Rows[size].Field <string>(5));
                            size++;
                        }
                    }
                    dataReader.Close();
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.ToString(), "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(conn);
                if (noChecked == 0)
                {
                    MessageBox.Show("Choose Searching Method!", "Search Method");
                    SearchElementTextBox.Clear();
                }
                else
                {
                    if (size == 0)
                    {
                        MessageBox.Show("Product not found!", "Not Found");
                    }
                    else
                    {
                        string  message = "";
                        int     i       = 0;
                        Product temp    = new Product();

                        foreach (DataRow row in dt.Rows)
                        {
                            temp.setID(dt.Rows[i].Field <int>(0));
                            temp.setName(dt.Rows[i].Field <string>(1));
                            temp.setUnit(dt.Rows[i].Field <string>(2));
                            temp.setQuantity(dt.Rows[i].Field <int>(3));
                            temp.setMoney(dt.Rows[i].Field <int>(4));
                            temp.setMoneyunit(dt.Rows[i].Field <string>(5));

                            message = message + dt.Rows[i].Field <int>(0).ToString() + " - " + dt.Rows[i].Field <string>(1) + " "
                                      + dt.Rows[i].Field <int>(3).ToString() + " " + dt.Rows[i].Field <string>(2) + " and unit price is "
                                      + dt.Rows[i].Field <int>(4).ToString() + dt.Rows[i].Field <string>(5) + "\n";
                            i++;
                        }

                        MovePage movepage = new MovePage(conn, Convert.ToInt32(SearchElementTextBox.Text), message, this, temp.getName(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());

                        DataGridView_Products.DataSource = cardTable;
                        SearchElementTextBox.Clear();

                        movepage.Show();
                        this.Visible = false;
                    }
                }
                FillDataGridView();
            }
        }
コード例 #14
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            int state = 2;

            try
            {
                if (MoveTypeComboBox.Text.ToString().CompareTo("out") == 0 & Convert.ToInt32(MoveQuantityTextBox.Text) > this.quantity)
                {
                    MessageBox.Show("Product in stock is not enough!", "INVALID QUANTITY");
                    state = 1;
                }
                else
                {
                    string sql = "INSERT into StockManagementSystemDatabase.dbo.Move_Table(MoveProductID, MoveType, MoveDate, MoveQuantity, MoveQuantityUnit)"
                                 + "values('" + MoveProductIDTextBox.Text + "','" + MoveTypeComboBox.Text + "','" + MoveDateTimePicker.Value.ToString("yyyy-MM-dd")
                                 + "','" + MoveQuantityTextBox.Text + "','" + UnitComboBox.Text + "');";
                    SqlCommand command = new SqlCommand(sql, connection);
                    DBUtils.OpenConnection(connection);
                    command.ExecuteNonQuery();
                    DBUtils.CloseConnection(connection);

                    int newquantity = 0;
                    if (MoveTypeComboBox.Text.ToString().CompareTo("entry") == 0)
                    {
                        newquantity = this.quantity + Convert.ToInt32(MoveQuantityTextBox.Text);
                    }
                    else if (MoveTypeComboBox.Text.ToString().CompareTo("out") == 0)
                    {
                        newquantity = this.quantity - Convert.ToInt32(MoveQuantityTextBox.Text);
                    }

                    string Query = "update StockManagementSystemDatabase.dbo.Product_Cards_Table set ProductID='" + byID
                                   + "',ProductName='" + this.name + "',ProductUnit='" + this.unit + "',ProductQuantity='" + newquantity
                                   + "',ProductMoney='" + this.money + "',ProductMoneyUnit='" + this.moneyunit + "' WHERE ProductID=@ProductID;";

                    SqlCommand MyCommand = new SqlCommand(Query, connection);

                    MyCommand.Parameters.AddWithValue("@ProductID", byID);

                    DBUtils.OpenConnection(connection);
                    MyCommand.ExecuteNonQuery();
                    DBUtils.CloseConnection(connection);

                    mainpage.FillDataGridView();

                    MessageBox.Show("Product Move added!", "SUCCESS INSERTED");
                    state = 2;
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.ToString(), "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(connection);
                FillDataGridView();

                if (state == 2)
                {
                    InsertPanel.Visible        = false;
                    GridPanel.Visible          = true;
                    TurnBackPictureBox.Visible = true;
                    turnbackButton.Visible     = true;
                    MoveTypeComboBox.Text      = "";
                    MoveQuantityTextBox.Clear();
                    UnitComboBox.Text       = "";
                    MoveDateTimePicker.Text = "";
                }
                else if (state == 1)
                {
                    InsertPanel.Visible        = true;
                    GridPanel.Visible          = false;
                    TurnBackPictureBox.Visible = false;
                    turnbackButton.Visible     = false;
                    MoveQuantityTextBox.Clear();
                }
            }
        }