private void dataGridViewX1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { distributor dis = new distributor(); if (dataGridViewX1.CurrentRow.Cells[0].Value != null) { dis.id_distributor = (int)dataGridViewX1.CurrentRow.Cells[0].Value; dis.name_distributor = dataGridViewX1.CurrentRow.Cells[1].Value.ToString(); dis._address = dataGridViewX1.CurrentRow.Cells[2].Value.ToString(); ExportModule.F_Sender(dis); this.Close(); } }
public int InsertDoitac(distributor e) { try { data.distributors.InsertOnSubmit(e); data.SubmitChanges(); } catch (Exception ee) { throw ee; } return(e.id_distributor); }
public void UpdateDoitac(distributor e) { try { distributor ee = data.distributors.SingleOrDefault(a => a.id_distributor == e.id_distributor); ee.id_distributor = e.id_distributor; ee.name_distributor = e.name_distributor; ee._address = e._address; data.SubmitChanges(); } catch (Exception eee) { throw eee; } }
private void btnluu_Click(object sender, EventArgs e) { if (txtID.Text.Equals("")) { if (txtTen.Text.Equals("") && txtTen.Text.Equals("") && txtdiachi.Text.Equals("")) { MessageBox.Show("Nhập đầy đủ thông tin"); } else { distributor ee = new distributor(); ee.name_distributor = txtTen.Text; ee._address = txtdiachi.Text; dt.InsertDoitac(ee); } } else { if (txtTen.Text.Equals("") && txtTen.Text.Equals("") && txtdiachi.Text.Equals("")) { MessageBox.Show("Nhập đầy đủ thông tin"); } else { distributor ee = new distributor(); ee.id_distributor = int.Parse(txtID.Text); ee.name_distributor = txtTen.Text; ee._address = txtdiachi.Text; dt.UpdateDoitac(ee); } } dgvdoitac.DataSource = dt.SelectAllDoitac(); btnthem.Enabled = true; btnsua.Enabled = true; btnxoa.Enabled = true; btnluu.Enabled = false; btnhuy.Enabled = false; }
private void SetFactory(distributor d) { textBoxUITypeEditor5.TextBox.Text = "" + d.id_distributor; textBoxX2.Text = d.name_distributor; textBoxX3.Text = d._address; }