private void backButton_Click(object sender, EventArgs e) { LoadingList ll = new LoadingList(); ll.Show(); this.Hide(); }
private void loadingListToolStripMenuItem_Click(object sender, EventArgs e) { LoadingList LL = new LoadingList(); LL.toolStripUsername.Text = toolStripUsername.Text; LL.Show(); this.Hide(); }
private void dataGridViewLLList_CellContentClick(object sender, DataGridViewCellEventArgs e) { int i; i = dataGridViewLLList.SelectedCells[0].RowIndex; string woPTSNslctd = dataGridViewLLList.Rows[i].Cells[1].Value.ToString(); string processslctd = dataGridViewLLList.Rows[i].Cells[2].Value.ToString(); if (e.ColumnIndex == 11) { DetailLL dll = new DetailLL(); string cust = dataGridViewLLList.Rows[e.RowIndex].Cells[0].Value.ToString(); string modelNo = dataGridViewLLList.Rows[e.RowIndex].Cells[1].Value.ToString(); string process = dataGridViewLLList.Rows[e.RowIndex].Cells[2].Value.ToString(); string model = dataGridViewLLList.Rows[e.RowIndex].Cells[3].Value.ToString(); string machine = dataGridViewLLList.Rows[e.RowIndex].Cells[4].Value.ToString(); string pwbType = dataGridViewLLList.Rows[e.RowIndex].Cells[5].Value.ToString(); string prog = dataGridViewLLList.Rows[e.RowIndex].Cells[6].Value.ToString(); string rev = dataGridViewLLList.Rows[e.RowIndex].Cells[7].Value.ToString(); string mainpcb = dataGridViewLLList.Rows[e.RowIndex].Cells[8].Value.ToString(); string stencil = dataGridViewLLList.Rows[e.RowIndex].Cells[10].Value.ToString(); dll.tbCustomer.Text = cust; dll.tbWoPTSN.Text = modelNo; dll.tbProcess.Text = process; dll.tbModel.Text = model; dll.tbPWBType.Text = pwbType; dll.tbMachine.Text = machine; dll.tbProg.Text = prog; dll.tbRev.Text = rev; dll.tbPcbNo.Text = mainpcb; dll.tbStencil.Text = stencil; dll.Show(); this.Hide(); } if (e.ColumnIndex == 12) { string message = "Do you want to delete this Loading List " + woPTSNslctd + " " + processslctd + " ?"; string title = "Delete Loading List"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { var cmd = new MySqlCommand("", connection); string querydeleteLL = "DELETE FROM tbl_ll WHERE wo_PTSN = '" + woPTSNslctd + "' AND process_Name = '" + processslctd + "'"; string querydeleteLLDetail = "DELETE FROM tbl_lldetail WHERE wo_PTSN = '" + woPTSNslctd + "' AND process_Name = '" + processslctd + "'"; string querydeletePartCode = "DELETE FROM tbl_partcodedetail WHERE wo_PTSN = '" + woPTSNslctd + "' AND process_Name = '" + processslctd + "'"; string querydeleteReel = "DELETE FROM tbl_reel WHERE wo_PTSN = '" + woPTSNslctd + "' AND process_Name = '" + processslctd + "'"; string querydeleteResult = "DELETE FROM tbl_resultcompare WHERE wo_PTSN = '" + woPTSNslctd + "' AND process_Name = '" + processslctd + "'"; connection.Open(); string[] allQuery = { 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(); LoadingList ll = new LoadingList(); ll.Show(); this.Hide(); MessageBox.Show("Record Deleted successfully", "Loading List Record", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { } } }
private void saveButton_Click(object sender, EventArgs e) { try { backButton.Enabled = false; StartProgress("Loading..."); //lf.Show(); string cust = tbCust.Text; string woPTSN = tbWoPTSN.Text; string modelLL = tbModel.Text; string machine = tbMachine.Text; string pwbType = tbPWBType.Text; string prog = tbProg.Text; string rev = tbRev.Text; string pcb = tbPcbNo.Text; string stencil = tbStencil.Text; string remark = tbRemark.Text; string process = cmbProcess.Text; saveButton.Enabled = false; if (woPTSN == "" | process == "" | modelLL == "" | machine == "" | pwbType == "" | prog == "" | pcb == "") { CloseProgress(); MessageBox.Show("Unable to import Work Order without fill data properly", "Work Order", MessageBoxButtons.OK, MessageBoxIcon.Error); saveButton.Enabled = true; backButton.Enabled = true; } else { try { var cmd = new MySqlCommand("", connection); string cekmodel = "SELECT wo_PTSN, process_Name FROM tbl_ll WHERE wo_PTSN = '" + woPTSN + "'AND process_Name ='" + process + "'"; string cekPCB = "SELECT * FROM tbl_lldetail WHERE partcode = '" + pcb + "' AND wo_PTSN = '" + woPTSN + "' AND reel = 'PCB'"; string queryLL = "INSERT INTO tbl_ll VALUES('','" + cust + "','" + woPTSN + "','" + process + "','" + modelLL + "','" + machine + "','" + pwbType + "','" + prog + "','" + rev + "','" + pcb + "','" + llUsage + "','" + stencil + "','" + remark + "')"; string queryInputPCB = "INSERT INTO tbl_lldetail VALUES ('" + woPTSN + "','" + process + "','PCB', '" + pcb + "', '1', '1');"; string queryAddPartCodePCB = "INSERT INTO tbl_partcodedetail VALUES ('" + woPTSN + "','" + process + "','PCB', '" + pcb + "', '','PCB' ); "; connection.Open(); //Buka koneksi using (MySqlDataAdapter dscmd = new MySqlDataAdapter(cekmodel, connection)) { DataSet ds = new DataSet(); dscmd.Fill(ds); if (ds.Tables[0].Rows.Count >= 1) { lf.Hide(); MessageBox.Show("Loading List Data with WO PTSN " + woPTSN + " and Process " + process + " already uploaded", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); //custom messageBox to show error backButton.Enabled = true; } else { MySqlCommand cmddb = new MySqlCommand(cekPCB, connection); MySqlDataAdapter da = new MySqlDataAdapter(cmddb); DataSet ds1 = new DataSet(); da.Fill(ds1); int l = ds1.Tables[0].Rows.Count; if (l == 0) { string[] allQuery = { queryLL, queryInputPCB, queryAddPartCodePCB }; for (int i = 0; i < allQuery.Length; i++) { cmd.CommandText = allQuery[i]; //Masukkan perintah/query yang akan dijalankan ke dalam CommandText cmd.ExecuteNonQuery(); //Jalankan perintah / query dalam CommandText pada database } } else { string[] allQuery = { queryLL, queryAddPartCodePCB }; for (int i = 0; i < allQuery.Length; i++) { cmd.CommandText = allQuery[i]; //Masukkan perintah/query yang akan dijalankan ke dalam CommandText cmd.ExecuteNonQuery(); //Jalankan perintah / query dalam CommandText pada database } } for (int i = 0; i < dataGridViewLL.Rows.Count; i++) { string prtCode = dataGridViewLL.Rows[i].Cells[1].Value.ToString(); if (prtCode != "") { // query insert data part code string StrQuery = "INSERT INTO tbl_partcodedetail VALUES ('" + woPTSN + "','" + process + "','" + dataGridViewLL.Rows[i].Cells[0].Value.ToString() + "','" + dataGridViewLL.Rows[i].Cells[1].Value.ToString() + "', '" + dataGridViewLL.Rows[i].Cells[2].Value.ToString() + "', '" + dataGridViewLL.Rows[i].Cells[5].Value.ToString() + "');"; cmd.CommandText = StrQuery; cmd.ExecuteNonQuery(); } } String reelID = ""; String qty = ""; String loc = ""; int altNo = 1; for (int j = 0; j < dataGridViewLL.Rows.Count; j++) { if (dataGridViewLL.Rows[j].Cells[0].Value.ToString() != "") { reelID = dataGridViewLL.Rows[j].Cells[0].Value.ToString(); qty = dataGridViewLL.Rows[j].Cells[3].Value.ToString(); altNo = 1; string StrQueryReelDetail = "INSERT INTO tbl_reel VALUES ('','" + reelID + "', '" + woPTSN + "','" + process + "','" + dataGridViewLL.Rows[j].Cells[3].Value.ToString() + "', '" + dataGridViewLL.Rows[j].Cells[4].Value.ToString() + "', '" + dataGridViewLL.Rows[j].Cells[6].Value.ToString() + "');"; cmd.CommandText = StrQueryReelDetail; cmd.ExecuteNonQuery(); string StrQueryLLDetail = "INSERT INTO tbl_lldetail VALUES ('" + woPTSN + "','" + process + "','" + reelID + "', '" + dataGridViewLL.Rows[j].Cells[1].Value.ToString() + "','" + altNo + "', '" + qty + "');"; cmd.CommandText = StrQueryLLDetail; cmd.ExecuteNonQuery(); } else { //update location loc = dataGridViewLL.Rows[j].Cells[4].Value.ToString(); string StrQueryAddLoc = "UPDATE tbl_reel SET loc = CONCAT(loc,'" + loc + "') " + "WHERE reel = '" + reelID + "' AND tbl_reel.WO_ptsn = '" + woPTSN + "' and tbl_reel.process_Name = '" + process + "'"; cmd.CommandText = StrQueryAddLoc; cmd.ExecuteNonQuery(); } } connection.Close(); //Tutup koneksi CloseProgress(); MessageBox.Show("Loading List Successfully saved", "Loading List", MessageBoxButtons.OK, MessageBoxIcon.Information); saveButton.Enabled = true; backButton.Enabled = true; cmbProcess.Items.Remove(cmbProcess.SelectedItem); filepathLL.Text = ""; tbModel.Text = ""; tbPWBType.Text = ""; tbMachine.Text = ""; tbProg.Text = ""; tbRev.Text = ""; tbPcbNo.Text = ""; tbStencil.Text = ""; totalPoint.Text = ""; totalPart.Text = ""; dataGridViewLL.DataSource = null; dataGridViewLL.Refresh(); var count = cmbProcess.Items.Count; if (count > 0) { MessageBox.Show("Continue Import Other Process", "Loading List", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbProcess.SelectedItem = cmbProcess.Items[0]; } else if (count == 0) { string message = "Do you want to compare this Loading List ?"; string title = "Compare WO vs LL"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { Compare cowl = new Compare(); //cowl.cmbWOModel.SelectedItem = cowl.cmbWOModel.Items[0]; cowl.cmbWOPtsn.SelectedItem = tbWoPTSN.Text; cowl.Show(); this.Hide(); } else { LoadingList ll = new LoadingList(); ll.Show(); this.Hide(); } } } } } catch (Exception ex) { CloseProgress(); connection.Close(); MessageBox.Show(ex.Message.ToString()); backButton.Enabled = true; saveButton.Enabled = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }