public void loaddatarcvdet() { String intlotcode = lblInternalcode.Text.Trim(); MainMenu frm = new MainMenu(); //get data from table List <object[]> data = new List <object[]>(); data = frm.get_data_table_transaction("tbreceivingdetails", intlotcode, "id", ""); dataGridView1.Rows.Clear(); if (data.Count > 0) { dataGridView1.Rows.Add(data.Count); for (int i = 0; i < data.Count; i++) { dataGridView1.Rows[i].Height = 50; dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString(); if (data[i][5] != null) { dataGridView1.Rows[i].Cells[1].Value = data[i][5].ToString(); } dataGridView1.Rows[i].Cells[2].Value = data[i][4].ToString(); dataGridView1.Rows[i].Cells[3].Value = data[i][7].ToString(); } } Delete_columnbutton(); //load data summary loaddatasummary(); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == null) { return; } if (e.ColumnIndex == 3 && e.RowIndex >= 0 && dataGridView1.Rows.Count > 0) { DialogResult dialogResult = MessageBox.Show("Are you sure to delete Value " + this.dataGridView1.Rows[e.RowIndex].Cells[1].Value + "?", "Delete", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Int32 n = e.RowIndex; Int32 id = 0; String intlotcode = lblInternalcode.Text.Trim(); MainMenu frm = new MainMenu(); List <object[]> data = new List <object[]>(); data = frm.get_data_table_transaction("tbreceivingdetails", intlotcode, "id", ""); for (int i = 0; i <= n; i++) { if (i == n) { id = Int32.Parse(data[i][0].ToString()); } } String connString = Konek(); MySqlConnection conn5 = new MySqlConnection(connString); conn5.Open(); try { MySqlCommand mySql3 = conn5.CreateCommand(); mySql3.CommandText = "update tbreceivingdetails set tipe=@tipe,grade=@grade,fweight=0,intlotcode=@intlotcode, moddatetime=@moddatetime where id=@id"; mySql3.Parameters.AddWithValue("@tipe", ""); mySql3.Parameters.AddWithValue("@grade", ""); mySql3.Parameters.AddWithValue("@intlotcode", "4del"); mySql3.Parameters.AddWithValue("@moddatetime", frm.get_server_time()); mySql3.Parameters.AddWithValue("@id", id.ToString()); mySql3.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } loaddatarcvdet(); } } }