Example #1
0
        //===========================================================================================

        //==============================ACTION MINUS, PLUS OR DELETE DATA============================
        private void dgv_request_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CRUD sql = new CRUD();

            //fungsi fokus ke scan barcode
            this.ActiveControl = t_barcode;
            t_barcode.Focus();
            if (dgv_request.Columns[e.ColumnIndex].Name == "Delete")
            {
                String DEL        = dgv_request.SelectedRows[0].Cells[1].Value.ToString();
                String cmd_delete = "DELETE FROM returnorder_line WHERE RETURN_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + DEL + "'";
                sql.ExecuteNonQuery(cmd_delete);
                retreive();
                qty();
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "plus")
            {
                //ckon.con.Close();
                String _id2 = dgv_request.SelectedRows[0].Cells[0].Value.ToString();
                String ID = dgv_request.SelectedRows[0].Cells[1].Value.ToString();
                String quantity = dgv_request.SelectedRows[0].Cells[7].Value.ToString();
                String subtotal = dgv_request.SelectedRows[0].Cells[10].Value.ToString();
                String price = dgv_request.SelectedRows[0].Cells[5].Value.ToString();
                int    new_price = Int32.Parse(price); int new_subtotal = Int32.Parse(subtotal);
                //mencari good qty dari tabel inventory
                try
                {
                    ckon.sqlCon().Open();
                    String cmd_inv = "SELECT * FROM inventory WHERE ARTICLE_ID = '" + _id2 + "'";
                    ckon.sqlDataRd = sql.ExecuteDataReader(cmd_inv, ckon.sqlCon());

                    if (ckon.sqlDataRd.HasRows)
                    {
                        while (ckon.sqlDataRd.Read())
                        {
                            GOOD_QTY_PLUS = Convert.ToInt32(ckon.sqlDataRd["GOOD_QTY"].ToString());
                        }
                    }

                    int new_qty = Int32.Parse(quantity);
                    new_qty      = new_qty + 1;
                    new_subtotal = new_subtotal + new_price;
                    //BANDINGKAN, JIKA LEBIH BESAR DARI GOOD_QTY JGN DI EKSEKUSI
                    if (new_qty > GOOD_QTY_PLUS)
                    {
                        MessageBox.Show("Quantity Exceeded");
                    }
                    else
                    {
                        String update = "UPDATE returnorder_line SET QUANTITY='" + new_qty + "', SUBTOTAL='" + new_subtotal + "' WHERE RETURN_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + ID + "'";
                        sql.ExecuteNonQuery(update);
                        retreive();
                        qty();
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (ckon.sqlDataRd != null)
                    {
                        ckon.sqlDataRd.Close();
                    }

                    if (ckon.sqlCon().State == ConnectionState.Open)
                    {
                        ckon.sqlCon().Close();
                    }
                }
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "minus")
            {
                String ID = dgv_request.SelectedRows[0].Cells[1].Value.ToString();
                String quantity = dgv_request.SelectedRows[0].Cells[7].Value.ToString();
                String subtotal = dgv_request.SelectedRows[0].Cells[10].Value.ToString();
                String price = dgv_request.SelectedRows[0].Cells[5].Value.ToString();
                int    new_price = Int32.Parse(price); int new_subtotal = Int32.Parse(subtotal);
                int    new_qty = Int32.Parse(quantity);
                new_qty      = new_qty - 1;
                new_subtotal = new_subtotal - new_price;
                if (new_qty <= 0)
                {
                    MessageBox.Show("Minimum QTY 1");
                }
                else
                {
                    String update = "UPDATE returnorder_line SET QUANTITY='" + new_qty + "', SUBTOTAL='" + new_subtotal + "' WHERE RETURN_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + ID + "'";
                    sql.ExecuteNonQuery(update);
                    retreive();
                    qty();
                }
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "quantity")
            {
                String    ID       = dgv_request.SelectedRows[0].Cells[1].Value.ToString();
                String    name     = dgv_request.SelectedRows[0].Cells[2].Value.ToString();
                String    size     = dgv_request.SelectedRows[0].Cells[3].Value.ToString();
                String    color    = dgv_request.SelectedRows[0].Cells[4].Value.ToString();
                String    price    = dgv_request.SelectedRows[0].Cells[5].Value.ToString();
                String    quantity = dgv_request.SelectedRows[0].Cells[7].Value.ToString();
                String    from     = "Ret_Order";
                w_editQty edit_qty = new w_editQty();
                edit_qty.detail(l_transaksi.Text, ID, name, size, color, price, quantity);
                edit_qty.menu_asal(from);
                edit_qty.cek_qty();
                edit_qty.ShowDialog();
            }
        }
Example #2
0
        //==================================================================================
        //==================KLIK DATA HAPUS, PLUS, OR MINUS DATA===========================
        private void dgv_request_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CRUD sql = new CRUD();

            if (dgv_request.Columns[e.ColumnIndex].Name == "Delete")
            {
                String DEL     = dgv_request.SelectedRows[0].Cells[0].Value.ToString();
                String cmd_del = "DELETE FROM requestorder_line WHERE REQUEST_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + DEL + "'";
                sql.ExecuteNonQuery(cmd_del);

                retreive();
                qty();
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "plus")
            {
                String ID = dgv_request.SelectedRows[0].Cells[0].Value.ToString();
                String quantity = dgv_request.SelectedRows[0].Cells[6].Value.ToString();
                String subtotal = dgv_request.SelectedRows[0].Cells[9].Value.ToString();
                String price = dgv_request.SelectedRows[0].Cells[4].Value.ToString();
                int    new_price = Int32.Parse(price); int new_subtotal = Int32.Parse(subtotal);
                int    new_qty = Int32.Parse(quantity);
                new_qty      = new_qty + 1;
                new_subtotal = new_subtotal + new_price;

                String cmd_update = "UPDATE requestorder_line SET QUANTITY='" + new_qty + "', SUBTOTAL='" + new_subtotal + "' WHERE REQUEST_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + ID + "'";
                sql.ExecuteNonQuery(cmd_update);

                retreive();
                qty();
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "minus")
            {
                String ID = dgv_request.SelectedRows[0].Cells[0].Value.ToString();
                String quantity = dgv_request.SelectedRows[0].Cells[6].Value.ToString();
                String subtotal = dgv_request.SelectedRows[0].Cells[9].Value.ToString();
                String price = dgv_request.SelectedRows[0].Cells[4].Value.ToString();
                int    new_price = Int32.Parse(price); int new_subtotal = Int32.Parse(subtotal);
                int    new_qty = Int32.Parse(quantity);
                new_subtotal = new_subtotal - new_price;
                new_qty      = new_qty - 1;
                if (new_qty <= 0)
                {
                    MessageBox.Show("Minimum QTY 1");
                }
                else
                {
                    String cmd_update = "UPDATE requestorder_line SET QUANTITY='" + new_qty + "', SUBTOTAL='" + new_subtotal + "' WHERE REQUEST_ORDER_ID='" + l_transaksi.Text + "' AND ARTICLE_ID='" + ID + "'";
                    sql.ExecuteNonQuery(cmd_update);

                    retreive();
                    qty();
                }
            }
            if (dgv_request.Columns[e.ColumnIndex].Name == "quantity")
            {
                String    ID       = dgv_request.SelectedRows[0].Cells[0].Value.ToString();
                String    name     = dgv_request.SelectedRows[0].Cells[1].Value.ToString();
                String    size     = dgv_request.SelectedRows[0].Cells[2].Value.ToString();
                String    color    = dgv_request.SelectedRows[0].Cells[3].Value.ToString();
                String    price    = dgv_request.SelectedRows[0].Cells[4].Value.ToString();
                String    quantity = dgv_request.SelectedRows[0].Cells[6].Value.ToString();
                String    from     = "Req_order";
                w_editQty edit_qty = new w_editQty();
                edit_qty.detail(l_transaksi.Text, ID, name, size, color, price, quantity);
                edit_qty.menu_asal(from);
                edit_qty.ShowDialog();
            }
        }