private void btnSerch_Click(object sender, EventArgs e) { Business.Person Personlist = new Business.Person(); Personlist.Ntiolecode = txtSerch.Text; Personlist.FirstName = txtSerchName.Text; if (txtSerch.Text == "" && txtSerchName.Text == "") { MessageBox.Show("لطفا یکی ار فیلد هارا برای جستجو پر کنید."); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = Personlist.Read(); } if (txtSerch.Text != string.Empty) { Personlist.serch(); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = Personlist.serch(); } if (txtSerchName.Text != string.Empty) { Personlist.serchName(); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = Personlist.serchName(); } }
public List <Person> Read() { //ارتباط با دیتابیس SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=E:\Alborz\AlborzProject\Parking\ParkingDB.sdf"; SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "Select * from [Person]"; DataTable myDataTable = new DataTable(); SqlDataAdapter myDataAdapter = new SqlDataAdapter(); myDataAdapter.SelectCommand = myCommand; myDataAdapter.Fill(myDataTable); List <Person> lstResult = new List <Person>(); foreach (DataRow r in myDataTable.Rows) { Person p1 = new Business.Person(); p1.FirstName = r["FirstName"].ToString(); p1.LastName = r["LastName"].ToString(); lstResult.Add(p1); } return(lstResult); }
private void btnInsert_Click(object sender, EventArgs e) { UI.frmPerson insert = new UI.frmPerson(); Business.Person Personlist = new Business.Person(); insert.Show(); dataGridView1.DataSource = Personlist.Read(); //ReadFromDatabase(); }
private void btnSave_Click(object sender, EventArgs e) { Business.Person newPerson = new Business.Person(); newPerson.FirstName = txtFirstName.Text; newPerson.LastName = txtLastName.Text; newPerson.Tell = txtTell.Text; newPerson.Cell = txtCell.Text; newPerson.NationalCode = txtNationalCode.Text; newPerson.Insert(); MessageBox.Show("عملیات با موفقیت انجام شد"); }
private void btnDelet_Click(object sender, EventArgs e) { Business.Person Personlist = new Business.Person(); var result = MessageBox.Show("آیا مایل به حذف این کاربر هتسید؟", "هشدار", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Personlist.ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["clmnID"].Value); Personlist.Deleat(); dataGridView1.AutoGenerateColumns = true; MessageBox.Show("حذف با موفقیت انجام شد"); dataGridView1.DataSource = Personlist.Read(); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtFirstName.Text == "" && txtLastName.Text == "" && txtNationalCode.Text == "" && txtTell.Text == "" && txtCall.Text == "") { MessageBox.Show("لطفا فیلد هایی خالی را پر کنید"); } Business.Person insart = new Business.Person(); insart.Ntiolecode = txtNationalCode.Text; insart.FirstName = txtFirstName.Text; insart.Lastname = txtLastName.Text; insart.Tell = txtTell.Text; insart.Call = txtCall.Text; insart.Insert(); MessageBox.Show("ثبت با موفقیت انجام شد"); this.Close(); }
/// <summary> /// Handle one request. /// </summary> /// <param name="request">The request to handle.</param> /// <returns>A successful response.</returns> /// <remarks>If the method fails, it will throw an exception, corresponding to the failure types /// in http://xlentmatch.com/wiki/FailureResponse_Message#Error_Types</remarks> private static SuccessResponse HandleOne(Request request) { var response = new SuccessResponse(request); Business.Person person = null; try { person = Business.Person.Get(int.Parse(request.KeyValue)); } catch (Exception) { } switch (request.RequestType) { case "Get": if (person == null) { throw new NotFoundException(request.ClientName, request.EntityName, request.KeyValue); } response.Data = new Data(); Copy(person.Model, response.Data); break; case "Update": if (person == null) { throw new NotFoundException(request.ClientName, request.EntityName, request.KeyValue); } Copy(request.Data, person.Model); break; case "Create": if (person != null) { throw new MovedException(person.Model.Id.ToString()); } person = Business.Person.Create(); Copy(request.Data, person.Model); response.Key.Value = person.Model.Id.ToString(); break; default: throw new ArgumentOutOfRangeException("request", string.Format("Unknown request type: \"{0}\"", request.RequestType)); } return(response); }
private void btnEdit_Click_1(object sender, EventArgs e) { Business.Person editperson = new Business.Person(); UI.frmPersonEdit personEdit = new UI.frmPersonEdit(); #region setProperties personEdit.Name = dataGridView1.CurrentRow.Cells["clmnFirstName"].Value.ToString(); personEdit.lastName = dataGridView1.CurrentRow.Cells["clmnLastname"].Value.ToString(); personEdit.Tell = dataGridView1.CurrentRow.Cells["clmnTell"].Value.ToString(); personEdit.Cell = dataGridView1.CurrentRow.Cells["clmnCell"].Value.ToString(); personEdit.NationalCode = dataGridView1.CurrentRow.Cells["clmnNationalCode"].Value.ToString(); personEdit.ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["clmnID"].Value.ToString()); personEdit.ShowDialog(); MessageBox.Show("ویرایش با موفقیت انجام شد"); dataGridView1.DataSource = editperson.Read(); #endregion }
private void btnSave_Click(object sender, EventArgs e) { var result = MessageBox.Show("آیا مایل به ویرایش این کاربر هتسید؟", "اطلاع", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Business.Person personEdit = new Business.Person(); #region send data to business>person personEdit.ID = this.ID; personEdit.FirstName = txtFirstName.Text; personEdit.Lastname = txtLastName.Text; personEdit.Call = txtCall.Text; personEdit.Tell = txtTell.Text; personEdit.Ntiolecode = txtNationalCode.Text; #endregion personEdit.Update(); MessageBox.Show("ویرایش با موفقیت انجام شد "); this.Hide(); } }
private void frmPersonsList_Load(object sender, EventArgs e) { Business.Person persons = new Business.Person(); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = persons.Read(); }
public int SavePerson(Business.Person person) { count++; person.LastUpdated = DateTime.Now; return(count); }