Пример #1
0
        private void button_GD_insert_gang_PS_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            FormFunctions fFunc = new FormFunctions(user_id_lbl.Text, user_hash_lbl.Text);
            List<string> fldVals = new List<string>();
            DataSet ds = new DataSet();

            // adding labels -->
            fldNames.Clear();
            fldNames.AddRange(new string[] {"GangID", "CustomerName", "PO", "Qty", "UP", "Material", "Size", "RequireQty", "PrintQty", "IssueQty", "PrintOnFaceFront", "PrintOnFaceBack", "NumberOfColorFront", "NumberOfColorBack", "SideGuideFront", "SideGuideBack", "UVCoatingFront", "UVCoatingBack" });
            // <--

            // adding table fields -->
            fldVals.AddRange(new string[] { "gang_number", "cust_name", "cust_po_number", "(SELECT SUM(order_qty) FROM sales_vars WHERE sales_vars.cust_po_number = '"+dbc.SelectSingle("cust_po_number", "sales_vars", "id", dbc.SelectSingle("sales_vars_id", "graphics_vars_gang", "gang_number", ((Button)sender).Tag.ToString()))+"')", "up_size", "card_material", "sheet_size", "require_qty", "print_qty", "issue_qty", "PrintOnFaceFront", "PrintOnFaceBack", "NumberOfColorFront", "NumberOfColorBack", "SideGuideFront", "SideGuideBack", "UVCoatingFront", "UVCoatingBack" });
            // <--

            string query = " SELECT " + string.Join(", ", fldVals);
            query += " FROM graphics_vars_gang ";
            query += " JOIN sales_vars ON sales_vars.id = sales_vars_id ";
            query += " WHERE gang_number = " + ((Button)sender).Tag.ToString();

            ds = dbc.SelectMyDA(query);

            fFunc.createXML_gang("Press Information Sheet", fldNames, ds);
        }
Пример #2
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);
        }
Пример #3
0
        private void button_GD_edit_JobD_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);

            string query = "";
            //string gang_id = dbc.SelectSingle("id", "gang_number", "gang_number_id", comboBox_GD_edit_PoD0x1.SelectedItem.ToString());

            for (int i = 0; i < Int32.Parse(tableLayoutPanel_GD_edit_JobD.GetControlFromPosition(3, 0).Tag.ToString()); i++)
            {
                string gang_id = dbc.SelectSingle("id", "gang_number", "gang_number_id", tableLayoutPanel_GD_edit_JobD.GetControlFromPosition(1, i + 1).Text);
                query = "UPDATE po_details SET ";
                query += " gang_number_id = '" + gang_id + "', ";
                query += " sheet_size = '" + textBox_GD_edit_PoD1x5.Text + "', ";
                query += " print_qty = '" + textBox_GD_edit_PoD2x7.Text + "', ";
                query += " issue_qty = '" + textBox_GD_edit_PoD2x9.Text + "', ";
                query += " PrintOnFaceFront = '" + textBox_GD_edit_PoD0x7.Text + "', ";
                query += " PrintOnFaceBack = '" + textBox_GD_edit_PoD1x7.Text + "', ";
                query += " SideGuideFront = '" + textBox_GD_edit_PoD0x11.Text + "', ";
                query += " SideGuideBack = '" + textBox_GD_edit_PoD1x11.Text + "', ";
                query += " UVCoatingBack = '" + textBox_GD_edit_PoD1x13.Text + "',";
                query += " job_number = '" + tableLayoutPanel_GD_edit_JobD.GetControlFromPosition(0, i + 1).Text + "', ";
                query += " up_size = '" + tableLayoutPanel_GD_edit_JobD.GetControlFromPosition(3, i + 1).Text + "' ";
                query += " WHERE id = '" + tableLayoutPanel_GD_edit_JobD.GetControlFromPosition(0, i + 1).Tag.ToString() + "' ;";

                dbc.Update(query); // TODO: uncomment
            }
            label_GD_edit_update_status.Visible = true;
            label_GD_edit_update_status.Text = "Update Successful !";
        }
Пример #4
0
        private void button_GD_edit_loadPoD_Click(object sender, EventArgs e)
        {
            // --> Get po details data based on customer po number
            if (listView_GD_edit_searchResult.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select the PO entry first.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            label_GD_edit_update_status.Visible = false;
            string po_entry_id = "";
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);

            // adding field names of po_details table -->
            fldNames.Clear();
            fldNames.Add("cust_name"); //i 0
            fldNames.Add("cust_po_number"); //i 1
            fldNames.Add("order_qty"); //i 2
            fldNames.Add("card_material"); //i 3
            fldNames.Add("num_colors"); //i 4
            fldNames.Add("lamination"); //i 5
            fldNames.Add("card_name"); //i 6
            fldNames.Add("gang_number.gang_number_id"); //i 7
            fldNames.Add("po_details.id"); //i 8
            fldNames.Add("po_details.user_id"); //i 9
            fldNames.Add("po_entry_id"); //i 10
            fldNames.Add("po_details.gang_number_id"); //i 11
            fldNames.Add("sheet_size"); //i 12
            fldNames.Add("PrintOnFaceFront"); //i 13
            fldNames.Add("PrintOnFaceBack"); //i 14
            fldNames.Add("SideGuideFront"); //i 15
            fldNames.Add("SideGuideBack"); //i 16
            fldNames.Add("UVCoatingBack"); //i 17
            fldNames.Add("print_qty"); //i 18
            fldNames.Add("issue_qty"); //i 19
            //<--

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

            DataSet ds = new DataSet();
            FormFunctions fFunc = new FormFunctions(user_id_lbl.Text, user_hash_lbl.Text);
            string[] cbox_items = fFunc.getComboItems("", "", "gang_number_id", "gang_number", _order_by: "id", _whrClause: " WHERE id != 1 AND id != 2 ");

            string query = "SELECT " + string.Join(", ", fldNames.ToArray());
            query += " FROM po_details ";
            query += " JOIN po_entry ON po_entry.id = po_details.po_entry_id ";
            query += " JOIN gang_number ON po_details.gang_number_id = gang_number.id ";
            query += " WHERE po_entry_id = '" + po_entry_id + "';";
            //query += " GROUP BY cust_po_number; ";
            ds = dbc.SelectMyDA(query);

            int order_qty = 0;
            int job_lines = ds.Tables[0].Rows.Count;

            for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                order_qty += Int32.Parse(ds.Tables[0].Rows[j][2].ToString());

            label_GD_edit_PoD1x1.Text = ds.Tables[0].Rows[0][0].ToString();
            label_GD_edit_PoD0x3.Text = ds.Tables[0].Rows[0][1].ToString();
            label_GD_edit_PoD1x3.Text = order_qty.ToString();
            label_GD_edit_PoD0x5.Text = ds.Tables[0].Rows[0][3].ToString();
            label_GD_edit_PoD0x9.Text = ds.Tables[0].Rows[0][4].ToString();
            label_GD_edit_PoD0x13.Text = ds.Tables[0].Rows[0][5].ToString();

            comboBox_GD_edit_PoD0x1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox_GD_edit_PoD0x1.FlatStyle = FlatStyle.Popup;
            comboBox_GD_edit_PoD0x1.Items.Clear();
            comboBox_GD_edit_PoD0x1.Items.AddRange(cbox_items);
            comboBox_GD_edit_PoD0x1.SelectedItem = dbc.SelectSingle("gang_number_id", "gang_number", "id", ds.Tables[0].Rows[0][11].ToString());

            textBox_GD_edit_PoD1x5.Text = ds.Tables[0].Rows[0][12].ToString();
            textBox_GD_edit_PoD0x7.Text = ds.Tables[0].Rows[0][13].ToString();
            textBox_GD_edit_PoD1x7.Text = ds.Tables[0].Rows[0][14].ToString();
            textBox_GD_edit_PoD0x11.Text = ds.Tables[0].Rows[0][15].ToString();
            textBox_GD_edit_PoD1x11.Text = ds.Tables[0].Rows[0][16].ToString();
            textBox_GD_edit_PoD1x13.Text = ds.Tables[0].Rows[0][17].ToString();
            textBox_GD_edit_PoD2x7.Text = ds.Tables[0].Rows[0][18].ToString();
            textBox_GD_edit_PoD2x9.Text = ds.Tables[0].Rows[0][19].ToString();

            checkedListBox_GD_edit_PoD2x0.Items.Clear();
            checkedListBox_GD_edit_PoD2x0.Items.Add("Initial");
            checkedListBox_GD_edit_PoD2x0.Items.AddRange(fFunc.getComboItems("", "", "gang_number_id", "gang_number", _order_by: "id", _whrClause: " WHERE id != 1 AND id != 2 "));

            for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                checkedListBox_GD_edit_PoD2x0.SetItemChecked(checkedListBox_GD_edit_PoD2x0.Items.IndexOf(ds.Tables[0].Rows[j][7].ToString()), true);

            DataSet ds2 = new DataSet();
            string query2 = "SELECT card_name, up_size, po_details.id, job_number, gang_number.gang_number_id ";
            query2 += " FROM po_details ";
            query2 += " JOIN gang_number on gang_number.id = po_details.gang_number_id ";
            query2 += " WHERE po_entry_id = '" + po_entry_id + "' ORDER BY job_number; ";
            ds2 = dbc.SelectMyDA(query2);
            int up_size = 0;

            Label t_label1 = new Label();
            Label t_label2 = new Label();
            Label t_label3 = new Label();
            Label t_label4 = new Label();

            tableLayoutPanel_GD_edit_JobD.Controls.Clear();
            t_label1.Text = "Job Number";
            tableLayoutPanel_GD_edit_JobD.Controls.Add(t_label1, 0, 0);

            t_label2.Text = "Gang Number";
            tableLayoutPanel_GD_edit_JobD.Controls.Add(t_label2, 1, 0);

            t_label3.Text = "Job Name";
            tableLayoutPanel_GD_edit_JobD.Controls.Add(t_label3, 2, 0);

            t_label4.Text = "Job UP Size";
            t_label4.Tag = ds2.Tables[0].Rows.Count;
            tableLayoutPanel_GD_edit_JobD.Controls.Add(t_label4, 3, 0);

            for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
            {
                TextBox t_textBox = new TextBox();
                TextBox t_textBox2 = new TextBox();
                Label t_label = new Label();
                ComboBox t_cbox = new ComboBox();

                t_textBox.Text = ds2.Tables[0].Rows[i][3].ToString();
                t_textBox.Tag = ds2.Tables[0].Rows[i][2].ToString();

                t_cbox.Items.Add("Initial");
                t_cbox.Items.AddRange(cbox_items);
                t_cbox.SelectedItem = "Initial";
                t_cbox.SelectedItem = txtBox_gang_num.Text;
                t_cbox.SelectedItem = ds2.Tables[0].Rows[i][4].ToString();

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

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

                tableLayoutPanel_GD_edit_JobD.SuspendLayout();
                tableLayoutPanel_GD_edit_JobD.Controls.Add(t_textBox, 0, i + 1);
                tableLayoutPanel_GD_edit_JobD.Controls.Add(t_cbox, 1, i + 1);
                tableLayoutPanel_GD_edit_JobD.Controls.Add(t_label, 2, i + 1);
                tableLayoutPanel_GD_edit_JobD.Controls.Add(t_textBox2, 3, i + 1);
                tableLayoutPanel_GD_edit_JobD.ResumeLayout();

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

                t_textBox2.TextChanged += t_textBoxEdit_TextChanged;
            }
            label_GD_edit_PoD2x3.Text = up_size.ToString();
            label_GD_edit_PoD2x5.Text = (Int32.Parse(label_GD_edit_PoD1x3.Text) / up_size).ToString();
        }
Пример #5
0
        void t_gangjob_button_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            string str_buttonTag = ((Button)sender).Tag.ToString();

            string gang_number = "Initial";
            if (comboBox_GD_insert_0x0.SelectedItem.ToString() == "New")
                gang_number = textBox_GD_insert_0x1.Text;
            else if(comboBox_GD_insert_0x0.SelectedItem != null)
                gang_number = comboBox_GD_insert_0x0.SelectedItem.ToString();

            string query = " UPDATE graphics_vars_job ";
            query += " SET graphics_vars_gang_id = " + gang_number + ", ";
            query += " up_size = " + label_GD_insert_2x3.Tag.ToString();
            query += " WHERE id = " + str_buttonTag;

            dbc.Update(query);

            // Updating total up size in graphics_vars_gang table -->
            query = " SELECT up_size, id, sales_vars_id ";
            query += " FROM graphics_vars_gang ";
            query += " WHERE gang_number = '" + dbc.SelectSingle("graphics_vars_gang_id", "graphics_vars_job", "id", str_buttonTag) + "'; ";

            DataSet ds = new DataSet();
            int up_size = 0;
            ds = dbc.SelectMyDA(query);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (label_GD_insert_0x3.Text != ds.Tables[0].Rows[i][2].ToString())
                    up_size += Int32.Parse(ds.Tables[0].Rows[i][0].ToString());
            }
            up_size += Int32.Parse(label_GD_insert_2x3.Tag.ToString());

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                query = " UPDATE graphics_vars_gang ";
                query += " SET up_size = " + up_size.ToString() + " ";
                query += " WHERE id = " + ds.Tables[0].Rows[i][1].ToString();

                dbc.Update(query);
            }
            //<--
        }
Пример #6
0
        private void PO_Entry_IBtn1_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            List<string> fldVals = new List<string>();

            // checking input : cust_po_num, cust_name, cust_req_date -->
            if (textBox_Cust_PO_Num.Text != "")
            {
                if (dbc.SelectSingle("id", "sales_vars", "cust_po_number", textBox_Cust_PO_Num.Text) != "")
                {
                    MessageBox.Show("Duplicate Customer PO Number. Please recheck the PO number and enter again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else
                    MessageBox.Show("PO Number verified successfully !", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Please enter PO number.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (textBox_Cust_Name.Text == "")
            {
                MessageBox.Show("Please enter customer name.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string selectedDate = dateTimePicker_Cust_Req_Date.Value.Year.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Month.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Day.ToString();
            string todaysDate = DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString();
            if (selectedDate == todaysDate)
            {
                MessageBox.Show("Please select future date.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            // <--

            // adding field names & field values of po_entry table -->
            fldNames.Clear();
            fldNames.Add("order_qty");
            fldNames.Add("card_name");
            fldNames.Add("card_denom");
            fldNames.Add("cvv");
            fldNames.Add("card_size");
            fldNames.Add("card_thickness");
            fldNames.Add("card_material");
            fldNames.Add("num_colors");
            fldNames.Add("lamination");
            fldNames.Add("magnetic");
            fldNames.Add("pin");
            fldNames.Add("barcode");
            fldNames.Add("sol");
            fldNames.Add("hot_stamp");
            fldNames.Add("signature_panel");
            fldNames.Add("silk_screen");
            fldNames.Add("hole_punch");
            fldNames.Add("single_pack");
            fldNames.Add("bundle_pack");
            fldNames.Add("inner_box");
            fldNames.Add("outer_box"); //21 == i 20
            //<--

            /*
            fldNames.Add("user_id");
            fldVals.Add(user_id_lbl.Text);

            fldNames.Add("cust_po_number");
            fldVals.Add(textBox_Cust_PO_Num.Text);

            fldNames.Add("cust_name");
            fldVals.Add(textBox_Cust_Name.Text);

            if (textBox_Cust_Notes.Text != "")
            {
                fldNames.Add("notes");
                fldVals.Add(textBox_Cust_Notes.Text);
            }

            fldNames.Add("req_date");
            fldVals.Add(dateTimePicker_Cust_Req_Date.Value.Year.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Month.ToString() + "-" + dateTimePicker_Cust_Req_Date.Value.Day.ToString());
            */
            //<--

            textBox_Cust_PO_Num_copy.Text = textBox_Cust_PO_Num.Text;
            //dbc.Insert(fldNames, "po_entry", fldVals, user_id_lbl.Text); // TODO: uncomment
            PoD_IBtn3.Enabled = false;

            tableLayoutPanel1_SA_insert_addDetails.Controls.Clear();
            tableLayoutPanel1_SA_insert_addDetails.ColumnCount = 0;

            Label t_lbl1 = new Label(); t_lbl1.Text = "PO Detail Fields";
            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl1, 0, 0);

            for (int i = 0; i < 21; i++)
            {
                Label t_lable2 = new Label();
                t_lable2.Text = fldNames[i];
                tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lable2, 0, i + 1);
            }

            Label t_lbl3 = new Label();
            Label t_lbl4 = new Label();
            t_lbl3.Text = "Gang Number:";
            t_lbl4.Text = "Job Number:";
            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl3, 0, 22);
            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl4, 0, 23);

            PoD_IBtn2_Click(this.PO_Entry_IBtn1, new EventArgs()); // To add empty column with default values.

            label_SA_insertPoDSuccess.Visible = false;
        }
Пример #7
0
        // Get po details data based upon customer po number entered into textbox
        private void PoD_IBtn3_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            // --> Get po details data based on customer po number
            string po_entry_id = dbc.SelectSingle("id", "sales_vars", "cust_po_number", textBox_Cust_PO_Num_copy.Text);
            if (po_entry_id == "")
            {
                MessageBox.Show("Couldn't find Customer PO Number. Please recheck the PO number and search again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PoD_IBtn2.Enabled = false;
                PoD_IBtn1.Enabled = false;
                return;
            }
            PoD_IBtn2.Enabled = true;
            PoD_IBtn1.Enabled = true;
            label_SA_insertPoDSuccess.Visible = false;
            PO_Entry_IBtn1.Enabled = false;

            tableLayoutPanel1_SA_insert_addDetails.Controls.Clear();
            // adding field names of po_details table -->
            fldNames.Clear();
            fldNames.Add("order_qty");
            fldNames.Add("card_name");
            fldNames.Add("card_denom");
            fldNames.Add("cvv");
            fldNames.Add("card_size");
            fldNames.Add("card_thickness");
            fldNames.Add("card_material");
            fldNames.Add("num_colors");
            fldNames.Add("lamination");
            fldNames.Add("magnetic");
            fldNames.Add("pin");
            fldNames.Add("barcode");
            fldNames.Add("sol");
            fldNames.Add("hot_stamp");
            fldNames.Add("signature_panel");
            fldNames.Add("silk_screen");
            fldNames.Add("hole_punch");
            fldNames.Add("single_pack");
            fldNames.Add("bundle_pack");
            fldNames.Add("inner_box");
            fldNames.Add("outer_box"); // 21 == i20
            fldNames.Add("id");
            //<--

            DataSet ds = new DataSet();
            string query = "SELECT " + string.Join(", ", fldNames.ToArray());
            query += " FROM sales_vars WHERE cust_po_number = '" + textBox_Cust_PO_Num_copy.Text + "'; ";
            ds = dbc.SelectMyDA(query);
            // <--

            // Adding Column Headers for table layout panel 1 -->
            Label t_lbl2 = new Label();
            t_lbl2.Text = "PO Detail Fields";
            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl2, 0, 0);
            //<--

            // adding field names to table layout panel 1 -->
            for (int i = 0; i < 21; i++)
            {
                Label t_lbl = new Label();
                t_lbl.Text = fldNames[i];

                tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl, 0, i + 1);
            }
            //<--

            // adding gang number and job number to table layout panel 1 -->
            Label t_lbl4 = new Label();
            Label t_lbl5 = new Label();

            t_lbl4.Text = "Gang Number:";
            t_lbl5.Text = "Job Number:";

            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl4, 0, 22);
            tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl5, 0, 23);
            // <--

            // adding data columns with field values from database for selected PO number
            int colCount = 1;
            FormFunctions fFunc = new FormFunctions(user_id_lbl.Text, user_hash_lbl.Text);

            tableLayoutPanel1_SA_insert_addDetails.ColumnCount = colCount;
            this.tableLayoutPanel1_SA_insert_addDetails.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            tableLayoutPanel1_SA_insert_addDetails.GetControlFromPosition(0, 0).Tag = ds.Tables[0].Rows.Count; // add col count to 0,0 position tag.

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                colCount++;
                this.tableLayoutPanel1_SA_insert_addDetails.ColumnCount = colCount;
                this.tableLayoutPanel1_SA_insert_addDetails.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());

                Label t_lbl3 = new Label();
                t_lbl3.Text = "PO Detail Values " + (i + 1).ToString();
                tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl3, i + 1, 0);

                for (int j = 0; j < 21; j++)
                {
                    Panel t_panel = new Panel();
                    ComboBox t_combo = new ComboBox();
                    TextBox t_textBox = new TextBox();

                    t_textBox.Location = new Point(3, 30);

                    t_combo.Items.Add("Other");
                    t_combo.SelectedItem = "Other";

                    t_combo.Location = new System.Drawing.Point(4, 6);
                    t_combo.Size = new System.Drawing.Size(121, 13);
                    //t_combo.Tag = new TableLayoutPanelCellPosition(i, j);
                    t_combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    t_combo.FlatStyle = FlatStyle.Popup;

                    t_panel.AutoSize = true;
                    t_panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                    t_panel.BorderStyle = BorderStyle.FixedSingle;

                    t_panel.SuspendLayout();
                    if (j >= 4 & j < 21)
                    {
                        t_combo.Items.AddRange(fFunc.getComboItems("group_id", (j - 2).ToString(), "member_description", "po_specs"));
                        t_panel.Controls.Add(t_combo);
                        t_combo.SelectedItem = ds.Tables[0].Rows[i][j].ToString();
                        t_combo.Tag = ds.Tables[0].Rows[i][j].ToString();

                        if ((string)t_combo.SelectedItem == "Other")
                        {
                            t_textBox.Text = ds.Tables[0].Rows[i][j].ToString();
                            t_panel.Controls.Add(t_textBox);
                        }
                    }
                    else
                    {
                        t_textBox.Text = ds.Tables[0].Rows[i][j].ToString();
                        t_textBox.Location = new System.Drawing.Point(4, 6);
                        t_panel.Controls.Add(t_textBox);
                    }
                    t_panel.ResumeLayout();

                    tableLayoutPanel1_SA_insert_addDetails.SuspendLayout();
                    tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_panel, i + 1, j + 1);
                    tableLayoutPanel1_SA_insert_addDetails.ResumeLayout();

                    t_panel.Enabled = false;
                }

                // adding gang number and job number, fetched with po_details.id -->
                string str1 = dbc.SelectSingle("gang_number", "graphics_vars_gang", "id", dbc.SelectSingle("graphics_vars_gang_id", "graphics_vars_job", "sales_vars_id", ds.Tables[0].Rows[i][21].ToString()));
                string str2 = dbc.SelectSingle("job_number", "graphics_vars_job", "sales_vars_id", ds.Tables[0].Rows[i][21].ToString());

                Label t_lbl6 = new Label();
                Label t_lbl7 = new Label();
                t_lbl6.Text = str1;
                tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl6, i+1, 22);
                t_lbl7.Text = str2;
                tableLayoutPanel1_SA_insert_addDetails.Controls.Add(t_lbl7, i+1, 23);
                // <--
            }

            // To display total order quantity -->
            int totalOrderQty = 0;
            for (int j = 1; j < colCount; j++)
            {
                if (tableLayoutPanel1_SA_insert_addDetails.GetControlFromPosition(j, 1).GetChildAtPoint(new Point(4, 6)).Text != "")
                    totalOrderQty += Int32.Parse(tableLayoutPanel1_SA_insert_addDetails.GetControlFromPosition(j, 1).GetChildAtPoint(new Point(4, 6)).Text);
            }
            Label_SA_insert_OrderQty2.Text = totalOrderQty.ToString();
            // <--
        }
Пример #8
0
        private void button_SA_edit_getData_Click(object sender, EventArgs e)
        {
            // --> Get po details data based on customer po number
            if (listView1_SA_edit_search.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select the PO entry first.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            button_SA_edit_PoD.Visible = true;
            button_SA_edit_PoD.Enabled = true;
            label_SA_updateSuccess.Visible = false;

            string po_entry_id = "";
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);

            tableLayoutPanel1_SA_edit_addDetails.Controls.Clear();
            // adding field names of po_details table -->
            fldNames.Clear();
            fldNames.Add("order_qty");
            fldNames.Add("card_name");
            fldNames.Add("card_denom");
            fldNames.Add("cvv");
            fldNames.Add("card_size");
            fldNames.Add("card_thickness");
            fldNames.Add("card_material");
            fldNames.Add("num_colors");
            fldNames.Add("lamination");
            fldNames.Add("magnetic");
            fldNames.Add("pin");
            fldNames.Add("barcode");
            fldNames.Add("sol");
            fldNames.Add("hot_stamp");
            fldNames.Add("signature_panel");
            fldNames.Add("silk_screen");
            fldNames.Add("hole_punch");
            fldNames.Add("single_pack");
            fldNames.Add("bundle_pack");
            fldNames.Add("inner_box");
            fldNames.Add("outer_box"); //21 == i20
            fldNames.Add("id");
            //<--

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

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

            string query = "SELECT " + string.Join(", ", fldNames.ToArray());
            query += " FROM sales_vars WHERE cust_po_number = '" + listView1_SA_edit_search.SelectedItems[0].SubItems[1].Text + "'; ";
            ds = dbc.SelectMyDA(query);
            // <--

            label11.Text = "Customer Name: "+ dbc.SelectSingle("cust_name", "sales_vars", "cust_po_number", po_entry_id);
            label12.Text = "Customer PO#:  "+ po_entry_id;
            label11.Visible = true;
            label12.Visible = true;

            // Adding Column Headers for table layout panel 1 -->
            Label t_lbl2 = new Label(); t_lbl2.Text = "PO Detail Fields";
            tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl2, 0, 0);
            //<--

            // adding field names to table layout panel 1 -->
            for (int i = 0; i < 21; i++)
            {
                Label t_lbl = new Label();
                t_lbl.Text = fldNames[i];

                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl, 0, i + 1);
            }
            //<--

            // adding gang number and job number to table layout panel 1 -->
            Label t_lbl4 = new Label();
            Label t_lbl5 = new Label();
            Label t_lbl8 = new Label();
            Label t_lbl9 = new Label();

            t_lbl4.Text = "Gang Number:";
            t_lbl5.Text = "Job Number:";
            t_lbl8.Text = "Data Approval:";
            t_lbl9.Text = "Art Approval:";

            tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl4, 0, 22);
            tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl5, 0, 23);
            tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl8, 0, 24);
            tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl9, 0, 25);
            // <--

            // adding data columns with field values from database for selected PO number -->
            int colCount = 1;
            tableLayoutPanel1_SA_edit_addDetails.ColumnCount = colCount;
            this.tableLayoutPanel1_SA_edit_addDetails.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                colCount++;
                this.tableLayoutPanel1_SA_edit_addDetails.ColumnCount = colCount;
                this.tableLayoutPanel1_SA_edit_addDetails.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());

                Label t_lbl3 = new Label(); t_lbl3.Text = "PO Detail Values " + (i + 1).ToString();
                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl3, i + 1, 0);

                for (int j = 0; j < 21; j++)
                {
                    Panel t_panel = new Panel();
                    ComboBox t_combo = new ComboBox();
                    TextBox t_textBox = new TextBox();

                    t_textBox.Location = new Point(3, 30);

                    t_combo.Items.Add("Other");
                    t_combo.SelectedItem = "Other";

                    t_combo.Location = new System.Drawing.Point(4, 6);
                    t_combo.Size = new System.Drawing.Size(121, 13);
                    //t_combo.Tag = new TableLayoutPanelCellPosition(i, j);
                    t_combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    t_combo.FlatStyle = FlatStyle.Popup;

                    t_panel.AutoSize = true;
                    t_panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                    t_panel.BorderStyle = BorderStyle.FixedSingle;

                    t_panel.SuspendLayout();
                    if (j >= 4 & j < 21)
                    {
                        t_combo.Items.AddRange(fFunc.getComboItems("group_id", (j-2).ToString(), "member_description", "po_specs"));
                        t_panel.Controls.Add(t_combo);
                        t_combo.SelectedItem = ds.Tables[0].Rows[i][j].ToString();
                        t_combo.Tag = ds.Tables[0].Rows[i][j].ToString();

                        if ((string)t_combo.SelectedItem == "Other")
                        {
                            t_textBox.Text = ds.Tables[0].Rows[i][j].ToString();
                            t_panel.Controls.Add(t_textBox);
                        }
                    }
                    else
                    {
                        t_textBox.Text = ds.Tables[0].Rows[i][j].ToString();
                        t_textBox.Location = new System.Drawing.Point(4, 6);
                        t_panel.Controls.Add(t_textBox);
                    }
                    t_panel.ResumeLayout();

                    tableLayoutPanel1_SA_edit_addDetails.SuspendLayout();
                    tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_panel, i + 1, j + 1);
                    tableLayoutPanel1_SA_edit_addDetails.ResumeLayout();

                    t_combo.SelectedIndexChanged += t_combo_SelectedIndexChanged;
                }

                tableLayoutPanel1_SA_edit_addDetails.GetControlFromPosition((colCount - 1), 21).Tag = ds.Tables[0].Rows[i][21]; // Adding tag to indicate row id

                // adding gang number and job number, fetched with po_details.id -->
                string str1 = dbc.SelectSingle("graphics_vars_gang_id", "graphics_vars_job", "sales_vars_id", ds.Tables[0].Rows[i][21].ToString());
                string str2 = dbc.SelectSingle("job_number", "graphics_vars_job", "sales_vars_id", ds.Tables[0].Rows[i][21].ToString());

                string str3 = dbc.SelectSingle("DataApproved", "sales_vars", "id", ds.Tables[0].Rows[i][21].ToString());
                string str4 = dbc.SelectSingle("ArtApproved", "sales_vars", "id", ds.Tables[0].Rows[i][21].ToString());

                Label t_lbl6 = new Label();
                Label t_lbl7 = new Label();
                CheckBox t_chkBox1 = new CheckBox();
                CheckBox t_chkBox2 = new CheckBox();

                t_lbl6.Text = str1;
                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl6, i + 1, 22);
                t_lbl7.Text = str2;
                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_lbl7, i + 1, 23);
                // <--

                // adding checkboxes for data and art appoval -->
                if (str1 == "" || str2 == "")
                {
                    t_chkBox1.Enabled = false;
                    t_chkBox2.Enabled = false;
                }

                if (str3 == "Y")
                    t_chkBox1.Checked = true;
                if (str4 == "Y")
                    t_chkBox2.Checked = true;
                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_chkBox1, i + 1, 24);
                tableLayoutPanel1_SA_edit_addDetails.Controls.Add(t_chkBox2, i + 1, 25);
                // <--
            }
            // <--

            // To display total order quantity -->
            int totalOrderQty = 0;
            for (int j = 1; j < colCount; j++)
            {
                totalOrderQty += Int32.Parse((tableLayoutPanel1_SA_edit_addDetails.GetControlFromPosition(j, 1).GetChildAtPoint(new Point(4, 6)).Text == "" ? "0" : tableLayoutPanel1_SA_edit_addDetails.GetControlFromPosition(j, 1).GetChildAtPoint(new Point(4, 6)).Text));
            }
            Label_SA_edit_OrderQty2.Text = totalOrderQty.ToString();
            // <--
        }
Пример #9
0
        private void Button_PT_view_updateLS_Click(object sender, EventArgs e)
        {
            ConnectToMySQL dbc = new ConnectToMySQL(user_id_lbl.Text, user_hash_lbl.Text);
            FormFunctions fFunc = new FormFunctions(user_id_lbl.Text, user_hash_lbl.Text);

            string[] machines = fFunc.getComboItems("deptID", "1", "machine_name", "machines", _order_by: "machine_name");

            tLP_PT_view.Controls.Clear();
            tLP_PT_view.ColumnCount = 2*(machines.Length);
            tLP_PT_view.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            for(int i = 0; i < tLP_PT_view.ColumnCount; i++)
                tLP_PT_view.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.AutoSize));

            for (int i = 0; i < machines.Length; i++ )
            {

                Label t_label = new Label();
                DateTimePicker tp = new DateTimePicker();
                DateTimePicker dp = new DateTimePicker();

                tp.Format = DateTimePickerFormat.Time;
                tp.ShowUpDown = true;
                tp.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0);

                t_label.Text = machines[i];
                tLP_PT_view.Controls.Add(t_label, i, 0);
                tLP_PT_view.SetColumnSpan(t_label, 2);
                tLP_PT_view.Controls.Add(dp, (i*2), 1);
                tLP_PT_view.Controls.Add(tp, ((i*2)+1), 1);
            }

            string query = " SELECT gang_number, PrintingType ";
            query += " FROM graphics_vars_gang ";
            query += " JOIN sales_vars ON sales_vars.cust_po_number = sales_vars_id ";
            query += " WHERE Printing = 'Y'";
            query += " AND ArtApproved = 'Y'";
            query += " GROUP BY gang_number ";

            DataSet ds = new DataSet();
            ds = dbc.SelectMyDA(query);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                List<Label> row = new List<Label>();

                for (int j = 0; j < tLP_PT_view.ColumnCount; j++)
                {
                    Label t_label2 = new Label(); t_label2.AutoSize = true;
                    Label t_label3 = new Label(); t_label2.AutoSize = true;
                    if (ds.Tables[0].Rows[i][1].ToString() == tLP_PT_view.GetControlFromPosition(j, 0).Text)
                    {

                        t_label2.Text = ds.Tables[0].Rows[i][0].ToString();
                        t_label3.Text = "";

                        row.Add(t_label2);
                        row.Add(t_label3);
                    }
                    else
                    {
                        t_label2.Text = "";
                        t_label3.Text = "";

                        row.Add(t_label2);
                        row.Add(t_label3);
                    }
                    j++;
                }

                tLP_PT_view.Controls.AddRange(row.ToArray());

                for (int j = 0; j < tLP_PT_view.ColumnCount; j++)
                {
                    Control ctrl = tLP_PT_view.GetControlFromPosition(j, i + 1);
                    string issueQty = "1";
                    Double timeReqd = 1;

                    if (ctrl.GetType() == typeof(Label))
                    {
                        if (row[j].Text != "")
                        {
                            string str = tLP_PT_view.GetControlFromPosition(j+1, i + 1).Text;
                            DateTime dt = (DateTime)tLP_PT_view.GetControlFromPosition(j+1, i + 1).Tag;
                            row[j + 1].Text = "S: " + dt.ToString();
                            issueQty = dbc.SelectSingle("issue_qty", "graphics_vars_gang", "gang_number", row[j].Text);
                            timeReqd = fFunc.getJobRuntime(tLP_PT_view.GetControlFromPosition(j, 0).Text, issueQty);
                            //row[j + 1].Text += " F: " + tLP_PT_view.GetControlFromPosition(j, i + 1).Tag.ToString() + " " + ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.AddHours(timeReqd).ToShortTimeString();
                            dt = dt.AddHours(timeReqd);
                            //row[j + 1].Tag = ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.AddHours(timeReqd).ToShortTimeString();
                            row[j + 1].Text += " F: "+ dt.ToString();
                            row[j + 1].Tag = dt;
                        }
                    }
                    else
                    {
                        if (row[j].Text != "")
                        {
                            DateTime dt = new DateTime(((DateTimePicker)ctrl).Value.Year, ((DateTimePicker)ctrl).Value.Month, ((DateTimePicker)ctrl).Value.Day, ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.Hour, ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.Minute, ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.Second);

                            string str = "S: " + dt.ToString() + "+" ;
                            issueQty = dbc.SelectSingle("issue_qty", "graphics_vars_gang", "gang_number", row[j].Text);
                            timeReqd = fFunc.getJobRuntime(tLP_PT_view.GetControlFromPosition(j,0).Text, issueQty);
                            //row[j + 1].Text += " F: " + ((DateTimePicker)ctrl).Value.ToShortDateString() + " " + ((DateTimePicker)tLP_PT_view.GetControlFromPosition(j + 1, i + 1)).Value.AddHours(timeReqd).ToShortTimeString();
                            dt = dt.AddHours(timeReqd);
                            str += " F: " + dt.ToString();
                            row[j + 1].Text = str;
                            row[j + 1].Tag = dt;
                        }
                    }
                    j++;
                }
            }
        }