private void txtMemberName_Enter(object sender, EventArgs e) { Community.DBLayer dbLayer = new Community.DBLayer(); bool Result = dbLayer.CheckFamily(txtFCardNo.Text); if (Result) { usp_SEL_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_SEL_tblFamilyMember, txtFCardNo.Text); if (txtMemberName.Text == "") { MessageBox.Show("No Member Found!", "Unable to Find"); btnFCardNo.Enabled = false; } else { btnFCardNo.Enabled = true; } } else { MessageBox.Show("Card Does Not Exist!"); txtMemberName.Text = ""; btnFCardNo.Enabled = false; } }
private void Print_NIC() { try { string NIC = dgvNIC.CurrentRow.Cells[3].Value.ToString(); Community.DBLayer dblayer = new Community.DBLayer(); SqlConnection con = new SqlConnection(Community.DBLayer.con_String); string query = richTextBox1.Text; string query1 = "NIC = '" + NIC + "'"; query = query.Replace("NIC = @NIC", query1); SqlCommand cmd = new SqlCommand(query, con); cmd.CommandType = CommandType.Text; DataTable dt = new DataTable(); SqlDataAdapter ada = new SqlDataAdapter(cmd); ada.Fill(dt); MCKJ.Reports.Members.frmViewer frm = new MCKJ.Reports.Members.frmViewer(); MCKJ.Reports.Members.rptNIC rpt = new MCKJ.Reports.Members.rptNIC(); rpt.SetDataSource(dt); frm.crystalReportViewer1.ReportSource = rpt; frm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void User_Right() { Community.DBLayer DBLayer = new Community.DBLayer(); SqlConnection con = new SqlConnection(Community.DBLayer.con_String); try { SqlCommand cmd = new SqlCommand("Select Write,Modify,[Delete] from tblPermission Where UserID =" + UserID + " And SecurityLevelID= " + SecurityLevelID, con); cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { rNew = Convert.ToBoolean(reader.GetValue(0)); rEdit = Convert.ToBoolean(reader.GetValue(1)); rDelete = Convert.ToBoolean(reader.GetValue(2)); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } //return chk_Right; }
private void btnFCardNo_Click(object sender, EventArgs e) { rbDeath.Enabled = true; rbMarriage.Enabled = true; rbMarriageOutside.Enabled = true; rbNewCard.Enabled = true; rbDivorce.Enabled = true; Community.DBLayer DBLayer = new Community.DBLayer(); string ID = txtFCardNo.Text; string Name = this.txtMemberName.Text; bool result = DBLayer.TRANSFER(ID, Name); if (txtMemberName.Text == "" || txtFCardNo.Text == "00000") { MessageBox.Show("Please fill the field!", "Error"); } else { if (result) { this.Width = 628; this.Height = 358; this.CenterToScreen(); txtMemberName.Enabled = false; btnFCardNo.Enabled = false; //label19.Hide(); grbMain.Show(); ReadOnly(true); grBox1.Show(); grBox1.Enabled = true; rbDivorce.Enabled = true; txtFCardNo.ReadOnly = true; if (rbActive.Checked) { dpIncident.Text = DateTime.Today.ToShortDateString(); } usp_SEL_TSF_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_SEL_TSF_tblFamilyMember, ID, Name); // usp_SEL_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_SEL_tblFamilyMember, ID); } else { MessageBox.Show("Member Not Found! May be Inactive or not Exist in " + "'" + txtFCardNo.Text + "'" + " .", "Unable to Search"); } if (rbActive.Checked == false) { rbInActive.Checked = true; } } }
private void btnSave_Click(object sender, EventArgs e) { Community.DBLayer Chk = new Community.DBLayer(); Community.DBLayer dblayer = new Community.DBLayer(); txtHName.Text = txtHNameT.Text; try { int ID = Convert.ToInt32(txtMemberID.Text); string FCardNo = txtFCardNo.Text; string FCardNoT = txtFCardNoT.Text; string Academic = txtAcdemicEdu.Text; string BAddress = txtBAddress.Text; string Bgroup = txtBGroup.Text; string BName = txtBName.Text; string BPhone = txtBPhone.Text; string Gender = txtGender.Text; string AgeGroup = txtAdult.Text; string CMIC = txtCMIC.Text; string CNIC = txtCNIC.Text; string Designation = txtDesignation.Text; string Email = txtEmail.Text; string Fax = txtFax.Text; string Mobile = txtMobile.Text; string Name = txtName.Text; string Professional = txtProfessionalEdu.Text; string Technical = txtTechnicalEdu.Text; string Type = txtTypeWork.Text; string Website = txtWebsite.Text; string DOB = txtDOBYear.Text; string LRealation = txtRelation.Text; string LRelationT = cmbRelationT.Text; string FName = txtFName.Text; string HName = txtHNameT.Text; bool Active = rbActive.Checked; bool ActiveT = rbActiveT.Checked; string Reason = Reason1(); DateTime Incident = Convert.ToDateTime(dpIncident.Text); string Status = cmbMaritalStatus.Text; string OutOf = cmbOutof.SelectedText; DateTime EntryDate = Convert.ToDateTime(dpEntryDate.Text); string FromCard = ""; if (txtFromCard.Text != "") { FromCard = txtFromCard.Text + " , " + txtFCardNoT.Text; } else { FromCard = txtFCardNo.Text; } string ToCard = ""; if (txtToCard.Text != "") { ToCard = txtToCard + " , " + txtFCardNoT.Text; } else { ToCard = txtFCardNoT.Text; } string TempDOB = Convert.ToDateTime(DOB).ToString("dd-MM-yyyy"); DialogResult Confirm = MessageBox.Show("Are you sure??", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // bool Result1 = Chk.CHK_DVC(FCardNoT, LRelationT, HName); bool Result2 = dblayer.CheckFamily(FCardNoT); if (Result2 == false) { MessageBox.Show("Family Card No Does Not Exist! Please Insert Valid Card Number", "Error"); } else { if (mode == 1 || mode == 2) { if (CheckFields()) { if (Confirm == DialogResult.Yes) { btnCancel.Visible = false; btnSubmit.Visible = false; txtFCardNo.Enabled = true; boxTransfer.Visible = false; usp_SEL_tblFamilyMemberTableAdapter.Update1(ID, FCardNo, Name, LRealation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, Reason, Incident, Status, OutOf, EntryDate, txtFromCard.Text, ToCard, Convert.ToDateTime(TempDOB), "", "", "", new DBLayer().GetUserID()); usp_SEL_tblFamilyMemberTableAdapter.Insert1(FCardNoT, Name, LRelationT, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, ActiveT, Reason, Incident, Status, OutOf, EntryDate, FromCard, txtToCard.Text, Convert.ToDateTime(TempDOB), "", "", "", new DBLayer().GetUserID()); MessageBox.Show("Transferred Succesfully!", "Success"); exit = 1; btnCancel_Click(sender, e); } } } else if (mode == 3) { if (txtFCardNoT.Text != "" && cmbRelationT.Text != "") { if (Confirm == DialogResult.Yes) { btnCancel.Visible = false; btnSubmit.Visible = false; txtFCardNo.Enabled = true; boxTransfer.Visible = false; usp_SEL_tblFamilyMemberTableAdapter.Update1(ID, FCardNo, Name, LRealation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, Reason, Incident, Status, OutOf, EntryDate, FromCard, ToCard, Convert.ToDateTime(TempDOB), "", "", "", new DBLayer().GetUserID()); usp_SEL_tblFamilyMemberTableAdapter.Insert1(FCardNoT, Name, LRelationT, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, ActiveT, Reason, Incident, Status, OutOf, EntryDate, FromCard, ToCard, Convert.ToDateTime(TempDOB), "", "", "", new DBLayer().GetUserID()); MessageBox.Show("Transferred Succesfully!", "Success"); exit = 1; btnCancel_Click(sender, e); } } else { MessageBox.Show("Fields could not be left Blank!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //else if (mode == 2) //{ // if (Confirm = DialogResult.Yes) //{ // btnCancel.Visible = false; // btnSubmit.Visible = false; // txtFCardNo.Enabled = true; // boxTransfer.Visible = false; // usp_SEL_tblFamilyMemberTableAdapter.Update1(ID, FCardNo, Name, LRealation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, Reason, Incident, Status, OutOf, EntryDate); // usp_SEL_tblFamilyMemberTableAdapter.Insert1(FCardNoT, Name, LRelationT, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, ActiveT, Reason, Incident, Status, OutOf, EntryDate); // MessageBox.Show("Transferred Succesfully!", "Success"); // exit = 1; // btnCancel_Click(sender, e); //} } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnFCardNo_Click(object sender, EventArgs e) { txtFCardNo_Leave(sender, e); string x = txtFCardNo.Text; Community.DBLayer dblayer = new Community.DBLayer(); if (txtFCardNo.Text == "") { MessageBox.Show("Please Insert Family Card Number", "Family Card Required", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { bool result = dblayer.CheckFamily(txtFCardNo.Text); if (result) { usp_SEL_FAMILYTableAdapter.Leader(comDataSet.usp_SEL_FAMILY, txtFCardNo.Text); //if (DGRenewal.Rows.Count == 0) //{ // btnEdit.Enabled = false; // btnPrint.Enabled = false; //} //else //{ // btnEdit.Enabled = false; // btnPrint.Enabled = false; //} if (txtFCardNo.Text == "") { txtFCardNo.Text = x; } btnViewInfo_Click(sender, e); usp_SEL_tblFamilyMemberTableAdapter.FillActive(comDataSet.usp_SEL_tblFamilyMember, txtFCardNo.Text); txtTotalMembers.Text = comDataSet.usp_SEL_tblFamilyMember.Rows.Count.ToString(); GetFemaleInformation(txtFCardNo.Text); usp_Male_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_Male_tblFamilyMember, txtFCardNo.Text, "Male"); int Male = DGInfo.Rows.Count; CalculateAge(); usp_SEL_tblFamilyMemberTableAdapter.FillAdult(comDataSet.usp_SEL_tblFamilyMember, txtFCardNo.Text); int Adults = comDataSet.usp_SEL_tblFamilyMember.Rows.Count; txtAdult.Text = Adults.ToString(); int Minor = Male - Adults; txtMinor.Text = Minor.ToString(); if (DBLayer.User_Right(UserID, SecurityLevelID, "[Modify]")) { btnEdit.Enabled = true; } else { btnEdit.Enabled = false; } if (DBLayer.User_Right(UserID, SecurityLevelID, "[Delete]")) { btnDelete.Enabled = true; } else { btnDelete.Enabled = false; } if (DBLayer.User_Right(UserID, SecurityLevelID, "[Write]")) { btnAdd.Enabled = true; } else { btnAdd.Enabled = false; } //Get Selected Family Card Renewal Info usp_SEL_RenewalTableAdapter.Fill(comDataSet.usp_SEL_Renewal, txtFCardNo.Text); btnViewInfo.Enabled = true; this.AcceptButton = btnAdd; btnPrint.Enabled = true; //btnDelete.Enabled = true; if (txtFCardNo.Text == "") { txtFCardNo.Text = x; } //if() } else { MessageBox.Show("Family CardNo doesnot exist! Please enter a Valid CardNo.", "Invalid CardNo.", MessageBoxButtons.OK, MessageBoxIcon.Stop); btnAdd.Enabled = false; btnEdit.Enabled = false; DGRenewal.Enabled = false; btnViewInfo.Enabled = false; btnPrint.Enabled = false; } } }