private void tồnKhoToolStripMenuItem_Click(object sender, EventArgs e) { frmKhoTB fr = new frmKhoTB(); fr.chichoxemvabc = true; fr.ShowDialog(); }
private void tHIẾTBỊToolStripMenuItem_Click(object sender, EventArgs e) { frmKhoTB fr = new frmKhoTB(); fr.Chu_vu = Chuc_vu; fr.ShowDialog(); }
private void btnThemTenTB_Click(object sender, EventArgs e) { try { frmKhoTB fr = new frmKhoTB(); fr.ShowDialog(); if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlDataAdapter da3 = new SqlDataAdapter("select * from THIETBI", conn); ds2.Tables["THIETBI"].Clear(); da3.Fill(ds2, "THIETBI"); // tao khoa chinh DataColumn[] pk = new DataColumn[1]; pk[0] = ds2.Tables["THIETBI"].Columns[1]; ds2.Tables["THIETBI"].PrimaryKey = pk; conn.Close(); showDataToCombobox_MA_TB(); //// cap nhat gia cho nhung thiet bi da duoc them int rowcount = dataGridView1.RowCount; if (cbbMaTB.Items.Count == 0) { dataGridView1.Rows.Clear(); } else { //// kiem tra xem ma thiet bi nay co ton tai o nha cung cap nauy khong for (int i = 0; i < rowcount; i++) { //MessageBox.Show((table.Rows.Contains(dataGridView1.Rows[0].Cells[0].Value.ToString()).ToString())); if (table.Rows.Contains(dataGridView1.Rows[i].Cells[0].Value.ToString()) == false) { /// xoa hang da them dataGridView1.Rows.RemoveAt(i); rowcount--; i--; } } } if (rowcount != 0) { for (int i = 0; i < rowcount; i++) { DataRow r = ds2.Tables["THIETBI"].Rows.Find(dataGridView1.Rows[i].Cells[0].Value.ToString()); if (r == null) { return; } double x = double.Parse(r[6].ToString()); dataGridView1.Rows[i].Cells[4].Value = x; x = double.Parse(r[7].ToString()); dataGridView1.Rows[i].Cells[5].Value = x; dataGridView1.Rows[i].Cells[3].Value = int.Parse(r[5].ToString()); dataGridView1.Rows[i].Cells[1].Value = r[2].ToString(); } } } catch { } }