private void importWO_Click(object sender, EventArgs e) { ImportLL ill = new ImportLL(); ill.Show(); this.Hide(); }
private void dataGridViewWoList_CellContentClick(object sender, DataGridViewCellEventArgs e) { int i; i = dataGridViewWoList.SelectedCells[0].RowIndex; string woPTSNslctd = dataGridViewWoList.Rows[i].Cells[1].Value.ToString(); if (e.ColumnIndex == 7) { DetailWO dwo = new DetailWO(); string cust = dataGridViewWoList.Rows[e.RowIndex].Cells[0].Value.ToString(); string woPtsn = dataGridViewWoList.Rows[e.RowIndex].Cells[1].Value.ToString(); string modelNo = dataGridViewWoList.Rows[e.RowIndex].Cells[2].Value.ToString(); string model = dataGridViewWoList.Rows[e.RowIndex].Cells[3].Value.ToString(); string woNo = dataGridViewWoList.Rows[e.RowIndex].Cells[4].Value.ToString(); //string processName = dataGridViewWoList.Rows[e.RowIndex].Cells[4].Value.ToString(); string woQty = dataGridViewWoList.Rows[e.RowIndex].Cells[5].Value.ToString(); string woUsage = dataGridViewWoList.Rows[e.RowIndex].Cells[6].Value.ToString(); dwo.tbCustomer.Text = cust; dwo.tbwoPTSN.Text = woPtsn; dwo.tbwoNo.Text = woNo; dwo.tbmodelNo.Text = modelNo; dwo.tbmodel.Text = model; dwo.totalUsage.Text = woQty; dwo.woQty.Text = woUsage; dwo.Show(); this.Hide(); //MessageBox.Show((e.RowIndex + 1) + " Row " + (e.ColumnIndex + 1) + " Column button clicked "); } if (e.ColumnIndex == 8) { ImportLL il = new ImportLL(); string woPtsn = dataGridViewWoList.Rows[e.RowIndex].Cells[1].Value.ToString(); string cust = dataGridViewWoList.Rows[e.RowIndex].Cells[0].Value.ToString(); il.Show(); il.tbWoPTSN.Text = woPtsn; il.tbCust.Text = cust; connection.Open(); string queryProcessDropDown = "SELECT process_Name FROM tbl_customer WHERE custname = '" + cust + "'"; try { using (MySqlDataAdapter adpt = new MySqlDataAdapter(queryProcessDropDown, connection)) { DataTable dset = new DataTable(); adpt.Fill(dset); if (dset.Rows.Count > 0) { string process = dset.Rows[0][0].ToString().Replace(" ", String.Empty);; int totalProcess = process.Split(',').Length; var processName = process.Split(','); for (int j = 0; j < totalProcess; j++) { il.cmbProcess.Items.Add(processName[j]); il.cmbProcess.ValueMember = processName[j].ToString(); } } else { } } connection.Close(); } catch (Exception ex) { // tampilkan pesan error MessageBox.Show(ex.Message); } this.Hide(); //MessageBox.Show((e.RowIndex + 1) + " Row " + (e.ColumnIndex + 1) + " Column button clicked "+model+""); } if (e.ColumnIndex == 9) { string woPtsn = dataGridViewWoList.Rows[e.RowIndex].Cells[1].Value.ToString(); Compare cowl = new Compare(); cowl.cmbWOPtsn.Text = woPtsn; cowl.Show(); this.Hide(); } if (e.ColumnIndex == 10) { string message = "Do you want to delete this Work Order and Loading List record for WO PTSN " + woPTSNslctd + " ?"; string title = "Delete Work Order"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { var cmd = new MySqlCommand("", connection); string querydeleteWO = "DELETE FROM tbl_wo WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeleteWODetail = "DELETE FROM tbl_wodetail WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeleteModel = "DELETE FROM tbl_model WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeleteLL = "DELETE FROM tbl_ll WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeleteLLDetail = "DELETE FROM tbl_lldetail WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeletePartCode = "DELETE FROM tbl_partcodedetail WHERE wo_PTSN = '" + woPTSNslctd + "'"; string querydeleteReel = "DELETE FROM tbl_reel WHERE wo_PTSN= '" + woPTSNslctd + "'"; string querydeleteResult = "DELETE FROM tbl_resultcompare WHERE wo_PTSN = '" + woPTSNslctd + "'"; connection.Open(); string[] allQuery = { querydeleteWO, querydeleteWODetail, querydeleteModel, querydeleteLL, querydeleteLLDetail, querydeletePartCode, querydeleteReel, querydeleteResult }; for (int j = 0; j < allQuery.Length; j++) { cmd.CommandText = allQuery[j]; //Masukkan perintah/query yang akan dijalankan ke dalam CommandText cmd.ExecuteNonQuery(); //Jalankan perintah / query dalam CommandText pada database } connection.Close(); WorkOrder wo = new WorkOrder(); wo.Show(); this.Hide(); MessageBox.Show("Record Deleted successfully", "Work Order Record", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { } } }
private void cmbWOModel_SelectedIndexChanged_1(object sender, EventArgs e) { cmbLLModel.ResetText(); cmbLLModel.Enabled = true; tbModel.Text = ""; tbMachine.Text = ""; tbPWBType.Text = ""; tbProgNo.Text = ""; tbStencil.Text = ""; tbPCB.Text = ""; woQty.Text = ""; llQty.Text = ""; compareQty.Text = ""; compareQty.BackColor = SystemColors.Control; while (dataGridViewCompareLLWO.Rows.Count > 0) { dataGridViewCompareLLWO.Rows.RemoveAt(0); } cmbLLModel.Items.Clear(); // to split model and process string str = cmbWOModel.Text; char ch = '|'; var model = str.Split(ch); connection.Open(); string queryLLDropDown = "SELECT model_No, process_Name FROM tbl_ll WHERE model_No = '" + model[0].Replace(" ", "") + "' AND process_Name = '" + model[1].Replace(" ", "") + "' "; try { using (MySqlDataAdapter adpt = new MySqlDataAdapter(queryLLDropDown, connection)) { DataTable dset = new DataTable(); adpt.Fill(dset); if (dset.Rows.Count > 0) { for (int i = 0; i < dset.Rows.Count; i++) { cmbLLModel.Items.Add(dset.Rows[i][0] + " | " + dset.Rows[i][1]); cmbLLModel.ValueMember = dset.Rows[i][1].ToString(); } } else { string message = "No any Loading List for selected Work Order, Do you want to upload Loading List File?"; string title = "Confirmation Upload Loading List "; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { ImportLL ill = new ImportLL(); ill.tbWoPTSN.Text = model[0].Replace(" ", ""); ill.Show(); this.Hide(); } } } connection.Close(); } catch (Exception ex) { // tampilkan pesan error MessageBox.Show(ex.Message); } }
private void cmbWOModel_SelectedIndexChanged(object sender, EventArgs e) { cmbLL.ResetText(); cmbLL.Enabled = true; label16.Visible = false; label3.Visible = false; tbCustomer.Text = ""; tbModel.Text = ""; tbPWBType.Text = ""; tbStencil.Text = ""; tbPCB.Text = ""; woQty.Text = ""; llQty.Text = ""; lbSummaryLLWO.Text = ""; lbSummaryWOLL.Text = ""; compareQty.Text = ""; comparePartcode.Text = ""; gbSummary.Visible = false; compareQty.BackColor = SystemColors.Control; comparePartcode.BackColor = SystemColors.Control; partCodeUsedNotMatchLLWO = 0; partCodeUsedNotMatchWOLL = 0; partCodeNotMatchLLWO = 0; partCodeNotMatchWOLL = 0; LLWONMPartCodes = ""; WOLLNMPartCodes = ""; dataGridViewCompareLLWO.DataSource = null; dataGridViewCompareLLWO.Refresh(); dataGridViewCompareWOLL.DataSource = null; dataGridViewCompareWOLL.Refresh(); while (dataGridViewCompareLLWO.Columns.Count > 0) { dataGridViewCompareLLWO.Columns.RemoveAt(0); } while (dataGridViewCompareWOLL.Columns.Count > 0) { dataGridViewCompareWOLL.Columns.RemoveAt(0); } cmbLL.Items.Clear(); string woPTSN = cmbWOPtsn.Text; string queryLLDropDown = "SELECT wo_PTSN FROM tbl_ll WHERE wo_PTSN = '" + woPTSN + "'GROUP BY wo_PTSN"; try { connection.Open(); using (MySqlDataAdapter adpt = new MySqlDataAdapter(queryLLDropDown, connection)) { DataTable dset = new DataTable(); adpt.Fill(dset); if (dset.Rows.Count > 0) { for (int i = 0; i < dset.Rows.Count; i++) { cmbLL.Items.Add(dset.Rows[i][0]); cmbLL.ValueMember = dset.Rows[i][0].ToString(); } } else { string message = "No any Loading List for selected Work Order, Do you want to upload Loading List File?"; string title = "Confirmation Upload Loading List "; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { ImportLL ill = new ImportLL(); ill.tbWoPTSN.Text = woPTSN; try { string queryCustName = "SELECT customer FROM tbl_wo WHERE wo_PTSN = '" + woPTSN + "'"; using (MySqlDataAdapter adt = new MySqlDataAdapter(queryCustName, connection)) { DataTable dst = new DataTable(); adt.Fill(dst); if (dst.Rows.Count > 0) { ill.tbCust.Text = dst.Rows[0]["customer"].ToString(); } } string queryProcessDropDown = "SELECT tbl_customer.process_Name FROM tbl_wo, tbl_customer WHERE tbl_wo.customer = tbl_customer.custname AND tbl_wo.wo_PTSN = '" + woPTSN + "'"; using (MySqlDataAdapter adpts = new MySqlDataAdapter(queryProcessDropDown, connection)) { DataTable dsets = new DataTable(); adpts.Fill(dsets); if (dsets.Rows.Count > 0) { string process = dsets.Rows[0][0].ToString().Replace(" ", String.Empty);; int totalProcess = process.Split(',').Length; var processName = process.Split(','); for (int j = 0; j < totalProcess; j++) { ill.cmbProcess.Items.Add(processName[j]); ill.cmbProcess.ValueMember = processName[j].ToString(); } } else { } } } catch (Exception ex) { // tampilkan pesan error MessageBox.Show(ex.Message); } ill.Show(); this.Hide(); } } } connection.Close(); } catch (Exception ex) { connection.Close(); // tampilkan pesan error MessageBox.Show(ex.Message); } }