private void btnClr_Click(object sender, EventArgs e) { Contacts.Service1 ser = new Contacts.Service1(); BindingSource b = new BindingSource(); b.DataSource = ser.GetCon(); gvCon.DataSource = b; }
private void btn_del_Click(object sender, EventArgs e) { bool DelCon; bool DelConR; Contacts.Service1 s = new Contacts.Service1(); s.DeleteContact(txtId.Text, out DelCon, out DelConR); BindingSource bs = new BindingSource(); bs.DataSource = s.GetCon(); gvCon.DataSource = bs; lblmsg.Text = "Successfully Deleted"; }
private void btn_update_Click(object sender, EventArgs e) { bool updateCon; bool updateConR; Contacts.Service1 s = new Contacts.Service1(); s.UpdateContacts(txtId.Text, txtName.Text, txtDOB.Text, txtMOB.Text, txtEMAIL.Text, txtADR.Text, out updateCon, out updateConR); BindingSource bs = new BindingSource(); bs.DataSource = s.GetCon(); gvCon.DataSource = bs; lblmsg.Text = "Successfully Updated "; }
private void btn_add_Click(object sender, EventArgs e) { if (cmbCon.Items.Count == 0) { MessageBox.Show("Add Group Please !"); return; } bool addConR; bool AddCons; Contacts.Service1 s = new Contacts.Service1(); s.AddContact(myUtill.loginUser.Userid, cmbCon.SelectedValue.ToString(), txtName.Text, txtDOB.Text, txtMOB.Text, txtEMAIL.Text, txtADR.Text, out addConR, out AddCons); BindingSource b = new BindingSource(); b.DataSource = s.GetCon(); gvCon.DataSource = b; lblmsg.Text = "Successfully Added"; }
private void button3_Click(object sender, EventArgs e) { if (cmbCon.Items.Count == 0) { MessageBox.Show("Add Group Please !"); return; } Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; Excel.Range range; string str; int rCnt; int rw = 0; int cl = 0; string filename = ""; if (openFileDialog1.ShowDialog() == DialogResult.OK) { filename = openFileDialog1.FileName; } xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(filename, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); range = xlWorkSheet.UsedRange; rw = range.Rows.Count; cl = range.Columns.Count; string _name = ""; string _mob = ""; string _address = ""; string _email = ""; string _dob = ""; for (rCnt = 1; rCnt <= rw; rCnt++) { //for (cCnt = 1; cCnt <= cl; ) { _name = Convert.ToString((range.Cells[rCnt, 1] as Excel.Range).Value2); _mob = "+" + Convert.ToString((range.Cells[rCnt, 2] as Excel.Range).Value2); _dob = Convert.ToString((range.Cells[rCnt, 3] as Excel.Range).Value2); _email = Convert.ToString((range.Cells[rCnt, 4] as Excel.Range).Value2); _address = Convert.ToString((range.Cells[rCnt, 5] as Excel.Range).Value2); str = _name + ", " + _mob + ", " + _dob; Contacts.Service1 ser = new Contacts.Service1(); try { string sv = ser.ImportContacts(_name, _dob, _mob, _email, _address, myUtill.loginUser.Userid, cmbCon.SelectedValue.ToString()); } catch (Exception ex) { } BindingSource b = new BindingSource(); b.DataSource = ser.GetCon(); gvCon.DataSource = b; } } xlWorkBook.Close(true, null, null); xlApp.Quit(); Marshal.ReleaseComObject(xlWorkSheet); Marshal.ReleaseComObject(xlWorkBook); Marshal.ReleaseComObject(xlApp); }