コード例 #1
0
ファイル: Form1.cs プロジェクト: hcs-scheduler/scheduler
        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);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hcs-scheduler/scheduler
        private void button_SA_edit_PoD_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            List<string> fldVals = new List<string>();
            List<string> addtFldVals = new List<string>();
            TableLayoutPanel TLP = new TableLayoutPanel();
            string[] str = new string[] { };
            DataSet ds = new DataSet();

            if (((Control)sender).Name == "button_SA_edit_PoD")
                TLP = tableLayoutPanel1_SA_edit_addDetails;
            else
                TLP = (TableLayoutPanel)sender;

            // setting up start column and adding remaining values like user_id, po number, cust name, req date, notes -->
            int startColCount = 1;
            if (TLP.GetControlFromPosition(0, 0).Tag != null)
            {
                startColCount = Int32.Parse(TLP.GetControlFromPosition(0, 0).Tag.ToString()) + 1; // get col count from 0,0 position tag.
                string query = "SELECT cust_po_number, notes, cust_name, DATE_FORMAT(req_date, '%Y-%m-%d')";
                query += " FROM sales_vars WHERE cust_po_number = '" + TLP.GetControlFromPosition(startColCount, 20).Tag.ToString() + "'; ";
                ds = dbc.SelectMyDA(query);
                addtFldVals.Add(user_id_lbl.Text);
                for (int i = 0; i < ds.Tables[0].Rows[0].ItemArray.Length; i++)
                    addtFldVals.Add(ds.Tables[0].Rows[0].ItemArray[i].ToString());
            }
            else if(TLP.Name != "tableLayoutPanel1_SA_edit_addDetails")
            {
                addtFldVals.Add(user_id_lbl.Text);
                addtFldVals.Add(textBox_Cust_PO_Num.Text);
                addtFldVals.Add(textBox_Cust_Notes.Text);
                addtFldVals.Add(textBox_Cust_Name.Text);
                addtFldVals.Add(dateTimePicker_Cust_Req_Date.Value.Year.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Month.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Day.ToString());
            }
            // <--

            // adding field values and inserting for po_details table -->
            List<string> fldNames2 = new List<string>();
            fldNames2.Add("user_id");
            fldNames2.Add("cust_po_number");
            fldNames2.Add("notes");
            fldNames2.Add("cust_name");
            fldNames2.Add("req_date");
            for (int i = startColCount; i < TLP.ColumnCount; i++)
            {
                fldVals.Clear();
                for (int j = 1; j <= 21; j++)
                {
                    if (TLP.GetControlFromPosition(i, j).GetChildAtPoint(new Point(4, 6)).Text == "Other")
                        fldVals.Add(TLP.GetControlFromPosition(i, j).GetChildAtPoint(new Point(3, 30)).Text);
                    else
                        fldVals.Add(TLP.GetControlFromPosition(i, j).GetChildAtPoint(new Point(4, 6)).Text);
                }

                /*
                string s = TLP.GetControlFromPosition(i, 21).Tag.ToString();
                if (((Control)sender).Name == "button_SA_edit_PoD")
                    str = tableLayoutPanel1_SA_edit_addDetails.GetControlFromPosition(i, 21).Tag.ToString().Remove(TLP.GetControlFromPosition(i, 21).Tag.ToString().Length - 1).Split('&');
                else
                    str = TLP.GetControlFromPosition(i, 21).Tag.ToString().Remove(TLP.GetControlFromPosition(i, 21).Tag.ToString().Length - 1).Split('&');
                */

                fldVals.AddRange(addtFldVals.ToArray());
                //if (fldNames.Count == 21)
                //    fldNames.RemoveAt(21);
                if (fldNames.Count == 22)
                    fldNames.RemoveAt(21);

                if (Int32.Parse(TLP.GetControlFromPosition(startColCount, 21).Tag.ToString()) == 0)
                {
                    fldNames.AddRange(fldNames2);
                    dbc.Insert(fldNames, "sales_vars", fldVals, user_id_lbl.Text); // TODO: uncomment
                    fldNames2.Clear();
                }
                else
                {
                    fldNames.AddRange(new string[] {"DataApproved", "ArtApproved" });

                    if (((CheckBox)TLP.GetControlFromPosition(i, 24)).CheckState == CheckState.Checked)
                        fldVals.Add("Y");
                    else
                        fldVals.Add("N");

                    if (((CheckBox)TLP.GetControlFromPosition(i, 25)).CheckState == CheckState.Checked)
                        fldVals.Add("Y");
                    else
                        fldVals.Add("N");

                    string query = "UPDATE sales_vars SET ";
                    for (int j = 0; j < fldNames.Count; j++)
                    {
                        query += fldNames[j] + " = '" + fldVals[j] + "'";
                        if (j != fldNames.Count - 1)
                            query += ", ";
                    }
                    query += " WHERE id ='" + TLP.GetControlFromPosition(i, 21).Tag.ToString() + "';";
                    dbc.Update(query); // TODO: uncomment
                    fldNames.RemoveAt(22);
                }
            }
            // <--
            if (((Control)sender).Name == "button_SA_edit_PoD")
                label_SA_updateSuccess.Visible = true;
            else
                label_SA_insertPoDSuccess.Visible = true;
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: hcs-scheduler/scheduler
        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;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: hcs-scheduler/scheduler
        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;
        }