Ejemplo n.º 1
0
        public List<List<string>> ColValues(string _tblName)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id, user_hash);

            List<List<string>> gd = new List<List<string>>();
            string query = "SELECT * FROM " + _tblName + ";";
            string countq = "SELECT COUNT(*) FROM " + _tblName + ";";
            int count = dbc.Count(countq);
            List<string> IDs = dbc.Select("SELECT id FROM " + _tblName + ";");

            for (int i = 0; i < count; i++)
            {
                List<string> gd1 = dbc.Select("SELECT * FROM "+_tblName+" WHERE id = " + IDs[i].ToString() + ";");
                gd.Add(gd1);
            }
            return gd;
        }
Ejemplo n.º 2
0
        private void btn1_GD_insert_InsertGang_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            label_GD_insert_newGangSuccess.Visible = false;

            if (dbc.Count("SELECT COUNT(id) FROM graphics_vars_gang WHERE gang_number = '"+txtBox_gang_num.Text+"';") > 0)
            {
                MessageBox.Show("Please enter new gang number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            List<string> g_fldNames = new List<string>();
            List<string> g_fldVals = new List<string>();

            g_fldNames.Add("gang_number");
            g_fldVals.Add(txtBox_gang_num.Text);

            dbc.Insert(g_fldNames, "graphics_vars_gang", g_fldVals, user_id_lbl.Text); //TODO: uncomment
            label_GD_insert_newGangSuccess.Visible = true;
        }
Ejemplo n.º 3
0
        private void button_GD_insert_InsertJob_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);

            TableLayoutPanel tlp_gd_insert_job = (TableLayoutPanel)((Control)sender).Tag;
            List<string> j_fldNames = new List<string>();
            List<string> j_fldVals = new List<string>();
            string s_id = tlp_gd_insert_job.GetControlFromPosition(2, 14).Name;

            // checking duplicate entry of job -->
            string query = " SELECT cust_po_number, sales_vars.id ";
            query += " FROM sales_vars ";
            query += " WHERE cust_po_number = '" + dbc.SelectSingle("cust_po_number", "sales_vars", "id", s_id) + "'; ";

            DataSet ds = new DataSet();
            int count = 0;

            ds = dbc.SelectMyDA(query);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (dbc.Count("SELECT COUNT(id) FROM graphics_vars_job WHERE sales_vars_id = '" + ds.Tables[0].Rows[i][1].ToString() + "';") > 0)
                    count++;
                if (count == ds.Tables[0].Rows.Count)
                    return;
            }

            // <--

            j_fldNames.AddRange(new string[] { "sales_vars_id", "graphics_vars_gang_id", "job_number", "Retailer", "ProjectedDueDate", "ActualDueDate", "PinCover", "Personalization_job", "CardRatio", "Other_Barcode", "MinPrintQty", "MagStripe", "Encode", "user_id" });

            j_fldVals.Add(s_id);
            j_fldVals.Add(((ComboBox)tlp_gd_insert_job.GetControlFromPosition(0, 11)).SelectedItem.ToString());
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(0, 1).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(1, 3).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(2, 7).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(2, 9).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(1, 11).Text);

            if (((CheckBox)tlp_gd_insert_job.GetControlFromPosition(2, 11)).CheckState == CheckState.Checked)
                j_fldVals.Add("Y");
            else
                j_fldVals.Add("N");

            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(0, 13).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(1, 13).Text);
            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(2, 13).Text);

            if (((CheckBox)tlp_gd_insert_job.GetControlFromPosition(0, 15)).CheckState == CheckState.Checked)
                j_fldVals.Add("Y");
            else
                j_fldVals.Add("N");

            j_fldVals.Add(tlp_gd_insert_job.GetControlFromPosition(1, 15).Text);
            j_fldVals.Add(user_id_lbl.Text);

            dbc.Insert(j_fldNames, "graphics_vars_job", j_fldVals, user_id_lbl.Text); //TODO: uncomment

            tlp_gd_insert_job.GetControlFromPosition(2, 15).Tag = tlp_gd_insert_job.GetControlFromPosition(0, 1).Text;
            tlp_gd_insert_job.GetControlFromPosition(2, 15).Enabled = true;
            tlp_gd_insert_job.GetControlFromPosition(2, 15).Click += new EventHandler(t_gd_insert_buttonClick);
        }
Ejemplo n.º 4
0
        private void btn_GD_insert_loadPO_Click(object sender, EventArgs e)
        {
            // --> Get po details data based on customer po number
            if (listView_GD_insert_newPOs.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select the PO entry first.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //label_GD_insert_update_status.Visible = false;
            //tableLayoutPanel_GD_insert_job.Controls.Clear();
            string po_entry_id = "";
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            List<string> fldNames2 = new List<string>();

            // --> Job Tabpage(s)
            // adding field names of po_details table -->
            fldNames.Clear();
            fldNames.Add("cust_name"); //i 0
            fldNames.Add("req_date");
            fldNames.Add("card_denom");
            fldNames.Add("card_material");
            fldNames.Add("order_qty");
            fldNames.Add("lamination");
            fldNames.Add("card_name");
            fldNames.Add("id");
            fldNames.Add("id"); //i 8
            fldNames.Add("user_id");
            fldNames.Add("card_size"); //i 10
            fldNames.Add("timestamp");
            //<--

            po_entry_id = listView_GD_insert_newPOs.SelectedItems[0].Tag.ToString();

            DataSet ds = new DataSet();
            //DataSet ds2 = new DataSet();
            FormFunctions fFunc = new FormFunctions(user_id_lbl.Text, user_hash_lbl.Text);

            string[] cbox_items = fFunc.getComboItems("", "", "DISTINCT(gang_number)", "graphics_vars_gang", _order_by: "id");

            string query = "SELECT " + string.Join(", ", fldNames.ToArray());
            query += " FROM sales_vars ";
            query += " WHERE cust_po_number = '" + po_entry_id + "'";
            string query2 = " GROUP BY cust_po_number; ";
            //ds2 = dbc.SelectMyDA(query+query2);
            ds = dbc.SelectMyDA(query);

            this.tabControl_GD_insert.TabPages.Clear();
            for (int j = 0; j < dbc.Count("SELECT count(id) from sales_vars where cust_po_number = '" + po_entry_id + "';"); j++)
            {
                TabPage tabPage_job = new TabPage("Job " + (j + 1).ToString());
                TableLayoutPanel tlp_GD_insert_job = new TableLayoutPanel();
                //tlp_GD_insert_job = tableLayoutPanel_GD_insert_job;
                //tlp_GD_insert_job.Controls.Clear();
                tlp_GD_insert_job.Name = "tlp_GD_insert_job" + (j + 1).ToString();

                tlp_GD_insert_job.ColumnCount = 3;
                tlp_GD_insert_job.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
                tlp_GD_insert_job.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
                tlp_GD_insert_job.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
                tlp_GD_insert_job.Dock = System.Windows.Forms.DockStyle.Fill;
                tlp_GD_insert_job.Location = new System.Drawing.Point(3, 3);
                tlp_GD_insert_job.RowCount = 16;
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.25F));
                tlp_GD_insert_job.Size = new System.Drawing.Size(809, 539);
                tlp_GD_insert_job.TabIndex = 0;

                tabPage_job.Controls.Add(tlp_GD_insert_job);
                //tabPage_job.Location = new System.Drawing.Point(4, 22);
                //tabPage_job.Name = "tabPage3";
                //tabPage_job.Padding = new System.Windows.Forms.Padding(3);
                //tabPage_job.Size = new System.Drawing.Size(815, 545);
                tabPage_job.TabIndex = j+1;
                //tabPage_job.Text = "Jobs";
                tabPage_job.UseVisualStyleBackColor = true;
                this.tabControl_GD_insert.TabPages.Add(tabPage_job);

                //--> adding label names to table
                List<string> lblNames = new List<string>();
                lblNames.AddRange(new string[] { "JobID", "CustomerName", "PODate", "CardName", "Retailer", "Denomination", "Order Qty", "CoreMaterial", "CustomerDueDate", "PO", "TypeOfCard", "ProjectedDueDate", "Sales", "Lamination", "ActualDueDate", "GangID", "PinCover", "Personalization Job", "CardRatio", "Other", "Minimum Print Qty:", "Mag Stripe", "Encode" });

                for (int i = 0; i < lblNames.Count; i++)
                {
                    Label t_gd_insert_label1 = new Label();
                    Label t_gd_insert_label2 = new Label();
                    Label t_gd_insert_label3 = new Label();
                    Button t_gd_insert_button1 = new Button();

                    int temp1;
                    if (i < 21)
                    {
                        t_gd_insert_label1.Text = lblNames[i].ToString();
                        t_gd_insert_label2.Text = lblNames[i + 1].ToString();
                        t_gd_insert_label3.Text = lblNames[i + 2].ToString();
                    }
                    else
                    {
                        t_gd_insert_label1.Text = lblNames[i].ToString();
                        t_gd_insert_label2.Text = lblNames[i + 1].ToString();
                    }

                    temp1 = Int32.Parse(Math.Floor(double.Parse(i.ToString()) / 3).ToString());
                    i++; i++;
                    temp1 = temp1 * 2;
                    tlp_GD_insert_job.Controls.Add(t_gd_insert_label1, 0, temp1);
                    tlp_GD_insert_job.Controls.Add(t_gd_insert_label2, 1, temp1);
                    if (i < 23)
                        tlp_GD_insert_job.Controls.Add(t_gd_insert_label3, 2, temp1);
                    else
                    {
                        t_gd_insert_button1.Text = "Save Info";
                        t_gd_insert_button1.Name = ds.Tables[0].Rows[j][8].ToString();
                        t_gd_insert_button1.Tag = tlp_GD_insert_job;
                        tlp_GD_insert_job.Controls.Add(t_gd_insert_button1, 2, temp1);
                    }

                    t_gd_insert_button1.Click += new EventHandler(button_GD_insert_InsertJob_Click);
                }

                for (int i = 0; i < lblNames.Count; i++)
                {
                    Label t_gd_insert_label = new Label(); t_gd_insert_label.Dock = DockStyle.Fill;
                    TextBox t_gd_insert_textbox = new TextBox();
                    CheckBox t_gd_insert_chkbox = new CheckBox();
                    Button t_gd_insert_button = new Button();
                    ComboBox t_gd_insert_combobox = new ComboBox();

                    switch (i)
                    {
                        case 0:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 0, 1);
                            break;
                        case 1:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[0].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 1, 1);
                            break;
                        case 2:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[11].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 2, 1);
                            break;
                        case 3:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[6].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 0, 3);
                            break;
                        case 4:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 1, 3);
                            break;
                        case 5:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[2].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 2, 3);
                            break;
                        case 6:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[4].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 0, 5);
                            break;
                        case 7:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[3].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 1, 5);
                            break;
                        case 8:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[1].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 2, 5);
                            break;
                        case 9:
                            t_gd_insert_label.Text = po_entry_id;
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 0, 7);
                            break;
                        case 10:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[10].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 1, 7);
                            break;
                        case 11:
                            t_gd_insert_textbox.Enabled = false;
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 2, 7);
                            break;
                        case 12:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[9].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 0, 9);
                            break;
                        case 13:
                            t_gd_insert_label.Text = ds.Tables[0].Rows[j].ItemArray[5].ToString();
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_label, 1, 9);
                            break;
                        case 14:
                            t_gd_insert_textbox.Enabled = false;
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 2, 9);
                            break;
                        case 15:
                            t_gd_insert_combobox.DropDownStyle = ComboBoxStyle.DropDownList;
                            t_gd_insert_combobox.FlatStyle = FlatStyle.Popup;
                            t_gd_insert_combobox.Items.Clear();
                            t_gd_insert_combobox.Items.Add("Initial");
                            t_gd_insert_combobox.Items.AddRange(cbox_items);
                            t_gd_insert_combobox.SelectedItem = "Initial";
                            //t_gd_insert_label.Text = "0000";
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_combobox, 0, 11);
                            break;
                        case 16:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 1, 11);
                            break;
                        case 17:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_chkbox, 2, 11);
                            break;
                        case 18:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 0, 13);
                            break;
                        case 19:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 1, 13);
                            break;
                        case 20:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 2, 13);
                            break;
                        case 21:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_chkbox, 0, 15);
                            break;
                        case 22:
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_textbox, 1, 15);
                            t_gd_insert_button.Text = "Print Sheet";
                            t_gd_insert_button.Enabled = false;
                            tlp_GD_insert_job.Controls.Add(t_gd_insert_button, 2, 15);
                            break;
                    }
                }
            }
            // <--

            //--> Gang tabpage
            TabPage tabPage_gang = new TabPage("Gang");
            TableLayoutPanel tlp_GD_insert_gang = new TableLayoutPanel();

            // adding field names of po_details table -->
            fldNames.Clear();
            fldNames.Add("cust_name"); //i 0
            fldNames.Add("cust_po_number");
            fldNames.Add("SUM(order_qty)");
            fldNames.Add("card_material");
            fldNames.Add("num_colors");
            fldNames.Add("lamination");
            fldNames.Add("card_name");
            fldNames.Add("COUNT(id)");
            fldNames.Add("id"); //i 8
            fldNames.Add("user_id");
            fldNames.Add("id"); //i 10

            query = "SELECT " + string.Join(", ", fldNames.ToArray());
            query += " FROM sales_vars ";
            query += " WHERE cust_po_number = '" + po_entry_id + "'";
            query += " GROUP BY cust_po_number; ";
            ds.Clear();
            ds = dbc.SelectMyDA(query);

            label_GD_insert_1x1.Text = ds.Tables[0].Rows[0][0].ToString();
            label_GD_insert_0x3.Text = ds.Tables[0].Rows[0][1].ToString();
            label_GD_insert_1x3.Text = ds.Tables[0].Rows[0][2].ToString();
            label_GD_insert_0x5.Text = ds.Tables[0].Rows[0][3].ToString();
            label_GD_insert_0x9.Text = ds.Tables[0].Rows[0][4].ToString();
            label_GD_insert_0x13.Text = ds.Tables[0].Rows[0][5].ToString();

            comboBox_GD_insert_0x0.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox_GD_insert_0x0.FlatStyle = FlatStyle.Popup;
            comboBox_GD_insert_0x0.Items.Clear();
            comboBox_GD_insert_0x0.Items.Add("New");
            comboBox_GD_insert_0x0.Items.AddRange(cbox_items);

            button_gd_insert_gangsave.Tag = ds.Tables[0].Rows[0][8].ToString();

            int up_size = 0;

            //TableLayoutPanel tlp_GD_insert_gang_job = new TableLayoutPanel(); //TODO: make generic table layout panel by copying properties
            //tlp_GD_insert_gang_job = tableLayoutPanel_GD_insert_JobD; //TODO: make generic table layout panel by copying properties

            DataSet ds2 = new DataSet();
            string query3 = "SELECT card_name, up_size, graphics_vars_job.id, job_number ";
            //query3 += ", gang_number.gang_number_id ";
            query3 += " FROM sales_vars ";
            query3 += " JOIN graphics_vars_job on sales_vars_id = sales_vars.id ";
            query3 += " WHERE cust_po_number = '" + po_entry_id + "' AND graphics_vars_gang_id = '0'";
            query3 += " ORDER BY job_number; ";
            ds2 = dbc.SelectMyDA(query3);

            Label t_label0x1 = new Label();
            Button t_button0x1 = new Button();
            Label t_label1 = new Label();
            Label t_label2 = new Label();
            Label t_label3 = new Label();
            Label t_label4 = new Label();

            tableLayoutPanel_GD_insert_JobD.Controls.Clear();
            t_label0x1.Text = "Job Information";
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_label0x1, 0, 0);

            t_button0x1.Text = "Update";
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_button0x1, 1, 0);
            t_button0x1.Click += new EventHandler(t_button0x1Click);

            t_label1.Text = "Job Number";
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_label1, 0, 1);

            t_label2.Text = "Job Name";
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_label2, 1, 1);

            t_label3.Text = "Job Up Size";
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_label3, 2, 1);

            t_label4.Text = "Action";
            t_label4.Tag = ds2.Tables[0].Rows.Count;
            tableLayoutPanel_GD_insert_JobD.Controls.Add(t_label4, 3, 1);

            for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
            {
                TextBox t_gangjob_textBox = new TextBox();
                Label t_gangjob_label1 = new Label();
                Label t_gangjob_label2 = new Label();
                Button t_gangjob_button = new Button();

                t_gangjob_label1.AutoSize = true;
                t_gangjob_label1.Text = ds2.Tables[0].Rows[i][3].ToString();

                t_gangjob_label2.AutoSize = true;
                t_gangjob_label2.Text = ds2.Tables[0].Rows[i][0].ToString();

                t_gangjob_textBox.Text = ds2.Tables[0].Rows[i][1].ToString();
                t_gangjob_textBox.Tag = ds2.Tables[0].Rows[i][1].ToString();

                t_gangjob_button.Text = "Insert Up-size";
                t_gangjob_button.Tag = ds2.Tables[0].Rows[i][2].ToString();

                tableLayoutPanel_GD_insert_JobD.SuspendLayout();
                tableLayoutPanel_GD_insert_JobD.Controls.Add(t_gangjob_label1, 0, i + 2);
                tableLayoutPanel_GD_insert_JobD.Controls.Add(t_gangjob_label2, 1, i + 2);
                tableLayoutPanel_GD_insert_JobD.Controls.Add(t_gangjob_textBox, 2, i + 2);
                tableLayoutPanel_GD_insert_JobD.Controls.Add(t_gangjob_button, 3, i + 2);
                tableLayoutPanel_GD_insert_JobD.ResumeLayout();

                up_size += Int32.Parse(ds2.Tables[0].Rows[i][1].ToString());

                t_gangjob_textBox.TextChanged += t_textBoxInsert_TextChanged;
                t_gangjob_button.Click += new EventHandler(t_gangjob_button_Click);
            }
            label_GD_insert_2x3.Text = up_size.ToString();
            int temp_up_size = 1;
            if (up_size != 0)
                temp_up_size = up_size;
            label_GD_insert_2x5.Text = (Int32.Parse(label_GD_insert_1x3.Text) / temp_up_size).ToString();

            tlp_GD_insert_gang = tableLayoutPanel_GD_insert_PoD;
            tabPage_gang.Controls.Add(tlp_GD_insert_gang);
            tabPage_gang.TabIndex = 0;
            tabPage_gang.UseVisualStyleBackColor = true;
            this.tabControl_GD_insert.TabPages.Add(tabPage_gang);
            // <--

            //--> Mid tabpage
            TabPage tabPage_mid = new TabPage("Mid");
            TableLayoutPanel tlp_gd_insert_mid = new TableLayoutPanel();
            Label t_lbl3 = new Label();
            ComboBox t_combo4 = new ComboBox();
            Button t_btn1 = new Button();
            Button t_btn2 = new Button();

            tlp_gd_insert_mid.ColumnCount = 2;
            tlp_gd_insert_mid.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            tlp_gd_insert_mid.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            tlp_gd_insert_mid.Dock = System.Windows.Forms.DockStyle.Fill;
            tlp_gd_insert_mid.AutoScroll = true;

            t_lbl3.Text = "GangID";
            t_combo4.Items.AddRange(cbox_items);
            t_btn1.Text = "Save";
            t_btn1.Click += new EventHandler(t_btn1_Click);

            t_btn2.Text = "Print";
            t_btn2.Click += new EventHandler(t_btn2_Click);
            t_btn2.Enabled = false;

            tlp_gd_insert_mid.Controls.Add(t_lbl3, 0, 0);
            tlp_gd_insert_mid.Controls.Add(t_btn1, 1, 0);
            tlp_gd_insert_mid.Controls.Add(t_combo4, 0, 1);
            tlp_gd_insert_mid.Controls.Add(t_btn2, 0, 1);

            DataSet ds3 = new DataSet();
            string query4 = "SHOW COLUMNS FROM graphics_vars_gang;";
            ds3 = dbc.SelectMyDA(query4);

            for (int row = 0; row < 7; row++)
            {
                for (int col = 0; col < 1; col++)
                {
                    Label t_lbl1 = new Label(); t_lbl1.Dock = DockStyle.Fill;
                    Label t_lbl2 = new Label(); t_lbl2.Dock = DockStyle.Fill;
                    CheckBox t_chkBox = new CheckBox(); t_chkBox.Dock = DockStyle.Fill;
                    ComboBox t_comboBox = new ComboBox(); t_comboBox.Dock = DockStyle.Fill; t_comboBox.Enabled = false;

                    t_lbl1.Text = ds3.Tables[0].Rows[(row * 2) + 17][0].ToString();
                    t_lbl2.Text = ds3.Tables[0].Rows[(row * 2) + 18][0].ToString();

                    t_chkBox.Tag = t_comboBox;
                    t_comboBox.Tag = t_lbl1.Text;

                    tlp_gd_insert_mid.Controls.Add(t_lbl1, col, ((row * 2) + 2));
                    tlp_gd_insert_mid.Controls.Add(t_lbl2, col + 1, ((row * 2) + 2));

                    tlp_gd_insert_mid.Controls.Add(t_chkBox, col, ((row * 2) + 3));
                    tlp_gd_insert_mid.Controls.Add(t_comboBox, col + 1, ((row * 2) + 3));

                    t_chkBox.CheckStateChanged += new EventHandler(t_chkBox_CheckStateChanged);
                }
            }
            tabPage_mid.Controls.Add(tlp_gd_insert_mid);
            tabPage_mid.TabIndex = this.tabControl_GD_insert.TabPages.Count;
            tabPage_mid.UseVisualStyleBackColor = true;
            this.tabControl_GD_insert.TabPages.Add(tabPage_mid);
            //<--
        }
Ejemplo n.º 5
0
        private void btn2_GD_insert_InsertD_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            List<string> fldVals = new List<string>();
            string query = ((Button)sender).Tag.ToString(); // TODO: can replace with "". Plugged in value for testing purposes

            string gang_number = "Initial";
            if (comboBox_GD_insert_0x0.SelectedItem.ToString() == "New")
            {
                gang_number = textBox_GD_insert_0x1.Text;
                if (dbc.Count("SELECT COUNT(id) FROM graphics_vars_gang WHERE gang_number = '" + textBox_GD_insert_0x1.Text + "';") > 0)
                {
                    MessageBox.Show("Please enter new gang number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
                gang_number = comboBox_GD_insert_0x0.SelectedItem.ToString();

            if (dbc.Count("SELECT COUNT(id) FROM graphics_vars_gang WHERE sales_vars_id = '" + label_GD_insert_0x3.Text + "' AND gang_number = '" + gang_number + "';") > 0)
                return;
            // adding field names -->
            fldNames.Clear();
            fldNames.AddRange(new string[] {"user_id", "sales_vars_id", "gang_number", "sheet_size", "print_qty", "issue_qty", "PrintOnFaceFront", "PrintOnFaceBack", "SideGuideFront", "SideGuideBack", "UVCoatingBack", "up_size" });
            // <--

            // adding field values -->
            fldVals.Add(user_id_lbl.Text);
            fldVals.Add(label_GD_insert_0x3.Text);
            fldVals.Add(gang_number);
            fldVals.Add(textBox_GD_insert_1x5.Text);
            fldVals.Add(textBox_GD_insert_2x7.Text);
            fldVals.Add(textBox_GD_insert_2x9.Text);
            fldVals.Add(textBox_GD_insert_0x7.Text);
            fldVals.Add(textBox_GD_insert_1x7.Text);
            fldVals.Add(textBox_GD_insert_0x11.Text);
            fldVals.Add(textBox_GD_insert_1x11.Text);
            fldVals.Add(textBox_GD_insert_1x13.Text);
            fldVals.Add(label_GD_insert_2x3.Text);
            // -->

            dbc.Insert(fldNames, "graphics_vars_gang", fldVals, user_id_lbl.Text); // TODO: uncomment

            button_GD_insert_gang_PS.Enabled = true;
            button_GD_insert_gang_PS.Tag = gang_number;
        }