private void btnOS3_update_Click(object sender, EventArgs e) { if (validate_aerobicMemberUpdate()) { Buisness_Logic.AreobicMember areo = new Buisness_Logic.AreobicMember(); Buisness_Logic.AreobicMemberRepository areoRepo = new Buisness_Logic.AreobicMemberRepository(); areo.MemberID = int.Parse(txteditmem_memid.Text); areo.name = txteditmem_name.Text; areo.nic = txteditmem_nic.Text; areo.addresss = txteditmem_address.Text; areo.phone = txteditmem_phone.Text; //areo.dob = string.Format("{0:M/d/yyyy}", datetimeeditmem.Value.ToShortDateString()); areo.dob = datetimeeditmem.Value.ToShortDateString(); areo.gender = cmdeditmemGender.SelectedItem.ToString(); areo.service_type = cmbeditmemserve.SelectedItem.ToString(); if (areoRepo.updateOtherMembers(areo)) { MessageBox.Show("Record updated succesfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record update failed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool addOtherMembers_Exist(Buisness_Logic.AreobicMember am) { DataLayer.dbConnect con = new DataLayer.dbConnect(); con.openConnection(); bool temp1 = false; try { string q2 = "INSERT INTO tbl_areobic_member VALUES (@memid, @stype)"; SqlCommand cmd2 = new SqlCommand(q2, con.getConnection()); cmd2.Parameters.AddWithValue("@memid", am.MemberID); cmd2.Parameters.AddWithValue("@stype", am.service_type); cmd2.ExecuteNonQuery(); temp1 = true; } catch (Exception exareo1) { throw; } if (temp1 == true) { return(true); } else { return(false); } }
private void btnAddMember_Click(object sender, EventArgs e) { try { if (validate_aerobicMember()) { Buisness_Logic.AreobicMemberRepository areorep = new Buisness_Logic.AreobicMemberRepository(); Buisness_Logic.AreobicMember areo = new Buisness_Logic.AreobicMember(); areo.name = txtOS2_memName.Text; areo.addresss = txtaddress.Text; areo.nic = txtOS2_nic.Text; areo.phone = txtOS2_phone.Text; areo.gender = cmbOS2_gender.SelectedItem.ToString(); areo.service_type = cmbOS2_serviceType.SelectedItem.ToString(); areo.dob = string.Format("{0:M/d/yyyy}", dateTime_OS2Mem.Value.ToShortDateString()); if (alreadyMember == true) { areo.MemberID = int.Parse(txtOS2_memId.Text); if (areorep.addOtherMembers_Exist(areo)) { MessageBox.Show("Success", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (areorep.addOtherMembers_notExist(areo)) { MessageBox.Show("Success", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed.", "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception exaeo) { MessageBox.Show(exaeo.Message, "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOS3_searchMem_Click(object sender, EventArgs e) { if (validate_search_areo_tab2()) { try { Buisness_Logic.AreobicMemberRepository aerorep = new Buisness_Logic.AreobicMemberRepository(); Buisness_Logic.AreobicMember arm = new Buisness_Logic.AreobicMember(); int memID = string.IsNullOrWhiteSpace(txteditmem_memid.Text) ? 0 : int.Parse(txteditmem_memid.Text); if (aerorep.searchAerobicMemOnly(memID, txteditmem_name.Text, txteditmem_nic.Text, arm)) { if (arm.MemberID == 0) { // clear_Tab2Areaobic(); } else { MessageBox.Show("Record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); txteditmem_memid.Text = arm.MemberID.ToString(); txteditmem_nic.Text = arm.nic; datetimeeditmem.Value = DateTime.Parse(arm.dob); txteditmem_address.Text = arm.addresss; cmdeditmemGender.SelectedItem = arm.gender; txteditmem_phone.Text = arm.phone.ToString(); cmbeditmemserve.SelectedItem = arm.service_type; txteditmem_name.Text = arm.name; } } else { MessageBox.Show("No record found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception sere) { MessageBox.Show(sere.Message, "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btn_tab1search_Click(object sender, EventArgs e) { try { int memberID; string nic, name; memberID = string.IsNullOrWhiteSpace(txtM_memID.Text) ? 0 : int.Parse(txtM_memID.Text); nic = txtM_nic.Text; name = txtM_name.Text; Buisness_Logic.AreobicMemberRepository areo = new Buisness_Logic.AreobicMemberRepository(); Buisness_Logic.AreobicMember arm = new Buisness_Logic.AreobicMember(); if (areo.searchAerobicMemOnly(memberID, name, nic, arm)) { MessageBox.Show("The member is already registerd aerobic member.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); // set values to gymMember class txtM_name.Text = arm.name; dateTimePickerMem.Value = DateTime.Parse(arm.dob); cmbM_gender.SelectedItem = arm.gender; txtM_phone.Text = arm.phone; txtM_address.Text = arm.addresss; txtM_nic.Text = arm.nic; } else { MessageBox.Show("No record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception sd) { throw; } }
private void btnOS2_searchMember_Click(object sender, EventArgs e) { if (validate_search_areo_tab1()) { try { Buisness_Logic.AreobicMemberRepository aerorep = new Buisness_Logic.AreobicMemberRepository(); Buisness_Logic.AreobicMember arm = new Buisness_Logic.AreobicMember(); int memID = string.IsNullOrWhiteSpace(txtOS2_memId.Text) ? 0 : int.Parse(txtOS2_memId.Text); aerorep.searchAerobicMem(memID, txtOS2_memName.Text, txtOS2_nic.Text, arm); if (arm.MemberID == 0) { clear_add_areoic(); } else { txtOS2_memId.Text = arm.MemberID.ToString(); txtOS2_nic.Text = arm.nic; dateTime_OS2Mem.Value = DateTime.Parse(arm.dob); txtaddress.Text = arm.addresss; cmbOS2_gender.SelectedItem = arm.gender; txtOS2_phone.Text = arm.phone.ToString(); cmbOS2_serviceType.SelectedItem = arm.service_type; txtOS2_memName.Text = arm.name; } } catch (Exception sere) { MessageBox.Show(sere.Message, "Data Insertion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void searchAerobicMem(int id, string name, string nic, Buisness_Logic.AreobicMember arm) { bool temp = false, temp1 = false; DataLayer.dbConnect cons = new DataLayer.dbConnect(); cons.openConnection(); SqlTransaction trn = cons.getConnection().BeginTransaction(); try { //qery one string q1 = "select * from tbl_member where regNo=@regNo or nic=@nic or name=@name"; SqlCommand cmd1 = new SqlCommand(q1, cons.getConnection()); cmd1.Transaction = trn; cmd1.Parameters.AddWithValue("@regNo", id); cmd1.Parameters.AddWithValue("@nic", nic); cmd1.Parameters.AddWithValue("@name", name); SqlDataAdapter da1 = new SqlDataAdapter(cmd1); DataTable dt1 = new DataTable(); da1.Fill(dt1); if (dt1.Rows.Count > 0) { arm.MemberID = int.Parse(dt1.Rows[0]["regNo"].ToString()); arm.name = dt1.Rows[0]["name"].ToString(); arm.nic = dt1.Rows[0]["nic"].ToString(); arm.dob = dt1.Rows[0]["dob"].ToString(); arm.gender = dt1.Rows[0]["gender"].ToString(); arm.addresss = dt1.Rows[0]["address"].ToString(); arm.phone = dt1.Rows[0]["phone"].ToString(); temp = true; } //query 2 string q2 = "select * from tbl_areobic_member where memberID=@memberID"; SqlCommand cmd2 = new SqlCommand(q2, cons.getConnection()); cmd2.Transaction = trn; cmd2.Parameters.AddWithValue("@memberID", arm.MemberID); SqlDataAdapter da2 = new SqlDataAdapter(cmd2); DataTable dt2 = new DataTable(); da2.Fill(dt2); if (dt2.Rows.Count > 0) { arm.service_type = dt2.Rows[0]["service_type"].ToString(); temp1 = true; } trn.Commit(); } catch (Exception nex) { trn.Rollback(); throw; } if (temp1 == true && temp == true) { MessageBox.Show("Record found. The member is a already registered Areobic member.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (temp == true && temp1 == false) { MessageBox.Show("Record found. The member is already registered Gym member.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No Record found..", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool addOtherMembers_notExist(Buisness_Logic.AreobicMember am) { DataLayer.dbConnect con = new DataLayer.dbConnect(); con.openConnection(); SqlTransaction trn1 = con.getConnection().BeginTransaction(); bool temp1 = false, status = true; try { string qt1 = "select * from tbl_member where name=@name and nic=@nic"; SqlCommand qt = new SqlCommand(qt1, con.getConnection()); DataTable dtw = new DataTable(); SqlDataAdapter daw = new SqlDataAdapter(qt); qt.Parameters.AddWithValue("@name", am.name); qt.Parameters.AddWithValue("@nic", am.nic); qt.Transaction = trn1; daw.Fill(dtw); if (dtw.Rows.Count > 0) { status = false; } if (status == true) { //qery one string q1 = "Insert into tbl_member(name, dob,address,nic,gender,phone) values (@name, @dob,@address,@nic,@gender,@phone)"; SqlCommand cmd1 = new SqlCommand(q1, con.getConnection()); cmd1.Transaction = trn1; cmd1.Parameters.AddWithValue("@name", am.name); cmd1.Parameters.AddWithValue("@dob", am.dob); cmd1.Parameters.AddWithValue("@address", am.addresss); cmd1.Parameters.AddWithValue("@nic", am.nic); cmd1.Parameters.AddWithValue("@gender", am.gender); cmd1.Parameters.AddWithValue("@phone", am.phone); cmd1.ExecuteNonQuery(); //query two string q2 = "SELECT regNo FROM tbl_member WHERE name=@name AND nic=@nic"; SqlCommand cmdx = new SqlCommand(q2, con.getConnection()); SqlDataAdapter da = new SqlDataAdapter(cmdx); DataTable dt = new DataTable(); cmdx.Transaction = trn1; cmdx.Parameters.AddWithValue("@name", am.name); cmdx.Parameters.AddWithValue("@nic", am.nic); da.Fill(dt); if (dt.Rows.Count > 0) { am.MemberID = int.Parse(dt.Rows[0]["regNo"].ToString()); } string q3 = "INSERT INTO tbl_areobic_member VALUES (@memid, @stype)"; SqlCommand cmd2 = new SqlCommand(q3, con.getConnection()); cmd2.Transaction = trn1; cmd2.Parameters.AddWithValue("@memid", am.MemberID); cmd2.Parameters.AddWithValue("@stype", am.service_type); cmd2.ExecuteNonQuery(); trn1.Commit(); temp1 = true; } else { MessageBox.Show("This member already exists.", "Infromation", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exareo1) { throw; } if (temp1 == true) { return(true); } else { return(false); } }