Beispiel #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Community.DBLayer dblayer = new Community.DBLayer();
            if (CheckFields())
            {
                try
                {
                    string       Gender         = cmbGender.Text;
                    DateTime     IssueDate      = Convert.ToDateTime(dpIssueDate.Text);
                    string       DOB            = Year();
                    string       Address        = txtAddress.Text;
                    string       Area           = cmbArea.Text;
                    string       BAddress       = txtBAddress.Text;
                    string       BName          = txtBName.Text;
                    string       BPhone         = txtBPhone.Text;
                    string       City           = cmbCity.Text;
                    string       Country        = txtCountry.Text;
                    string       Designattion   = txtDesignation.Text;
                    string       Email          = txtEmail.Text;
                    string       Leader         = txtFamilyLeader.Text;
                    string       FamilyName     = txtFamilyName.Text;
                    string       Fax            = txtFax.Text;
                    string       FCardNo        = txtFCardNo.Text;
                    string       Mobile         = txtMobile.Text;
                    string       Nukh           = cmbNukh.Text;
                    string       Phone          = txtPhone.Text;
                    string       Sign           = cmbSign.Text;
                    string       TypeWork       = cmbType.Text;
                    string       Village        = cmbVillage.Text;
                    string       Website        = txtWebsite.Text;
                    string       ParentFCardNo  = txtParentFCardNo.Text.PadLeft(5, '0');
                    string       RenewalDueFrom = txtRenewalDueFrom.Text;
                    DialogResult Result         = MessageBox.Show("Are you sure??", "Confirmation", MessageBoxButtons.YesNo);
                    if (Result == DialogResult.Yes)
                    {
                        if (mode == 1)
                        {
                            bool result = dblayer.CheckFamily(txtFCardNo.Text);
                            if (result)
                            {
                                MessageBox.Show("Family Card No already exist! Please insert new Card No", "Invalid Card No", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                txtFCardNo.Focus();
                            }
                            else
                            {
                                usp_SEL_FAMILYTableAdapter.Insert1(FCardNo, IssueDate, FamilyName, Leader, Gender, DOB, Country, City, Nukh, Sign, Village, Area, Address, Phone, Mobile, BName, TypeWork, Designattion, BAddress, BPhone, Fax, Email, Website, true, ParentFCardNo, RenewalDueFrom, DBLayer.GetUserID());
                                //usp_SEL_FAMILYTableAdapter.Fill(comDataSet.usp_SEL_FAMILY);
                                MessageBox.Show("Saved Succesfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                EmptyFields();
                                txtFCardNo.Focus();
                            }
                            lbl.Text = Header;
                        }

                        else if (mode == 0)
                        {
                            if (chk_active == "True")
                            {
                                usp_SEL_FAMILYTableAdapter.Update1(FCardNo, IssueDate, FamilyName, Leader, Gender, DOB, Country, City, Nukh, Sign, Village, Area, Address, Phone, Mobile, BName, TypeWork, Designattion, BAddress, BPhone, Fax, Email, Website, true, ParentFCardNo, RenewalDueFrom, DBLayer.GetUserID());
                            }
                            else
                            {
                                usp_SEL_FAMILYTableAdapter.Update1(FCardNo, IssueDate, FamilyName, Leader, Gender, DOB, Country, City, Nukh, Sign, Village, Area, Address, Phone, Mobile, BName, TypeWork, Designattion, BAddress, BPhone, Fax, Email, Website, false, ParentFCardNo, RenewalDueFrom, DBLayer.GetUserID());
                            }

                            //usp_SEL_FAMILYTableAdapter.Fill(comDataSet.usp_SEL_FAMILY);
                            MessageBox.Show("Updated Succesfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtFCardNo.Enabled = true;
                            grb1.Hide();
                            Disable_Btn(true);
                            grbSearch.Show();
                            lbl.Text = Header;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                this.AcceptButton = btnAdd;
            }
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (CheckFields())
            {
                try
                {
                    string   FCardNo      = txtFCardNo.Text;
                    string   Academic     = txtAcdemicEdu.Text;
                    string   BAddress     = txtBAddress.Text;
                    string   Bgroup       = cmbBGroup.Text;
                    string   BName        = txtBName.Text;
                    string   BPhone       = txtBPhone.Text;
                    string   Gender       = cmbGender.Text;
                    string   AgeGroup     = cmbAdult.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         = cmbTypeWork.Text;
                    string   Website      = txtWebsite.Text;
                    string   DOB          = Year();
                    string   LRelation    = cmbRelation.Text;
                    string   FName        = txtFName.Text;
                    string   HName        = txtHName.Text;
                    bool     Active       = Convert.ToBoolean(chkActive.CheckState);
                    string   Reason       = txtReason.Text;
                    string   Status       = cmbMaritalStatus.Text;
                    string   OutOf        = cmbOutof.Text;
                    DateTime EntryDate    = Convert.ToDateTime(dpEntryDate.Text);
                    string   FromCard     = txtFromCard.Text;
                    string   ToCard       = txtToCard.Text;
                    string   TempDOB      = Convert.ToDateTime(DOB).ToString("dd-MM-yyyy");;



                    DialogResult Result = MessageBox.Show("Are you sure??", "Confirmation", MessageBoxButtons.YesNo);
                    if (Result == DialogResult.Yes)
                    {
                        if (mode == 1)
                        {
                            usp_SEL_tblFamilyMemberTableAdapter.Insert1(FCardNo, Name, LRelation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, null, null, Status, OutOf, EntryDate, FromCard, ToCard, Convert.ToDateTime(TempDOB), txtNameU.Text, txtFNameU.Text, txtHusbandNameU.Text, DBLayer.GetUserID());
                            //   txtFCardNo.Enabled = true;
                            MessageBox.Show("Saved Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            EmptyFields();
                            txtName.Focus();
                            lbl.Text = Header;
                        }

                        else if (mode == 0)
                        {
                            if (chkActive.Checked)
                            {
                                usp_SEL_tblFamilyMemberTableAdapter.Update1(Convert.ToInt64(txtMemberID.Text), FCardNo, Name, LRelation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, null, null, Status, OutOf, EntryDate, FromCard, ToCard, Convert.ToDateTime(TempDOB).Date, txtNameU.Text, txtFNameU.Text, txtHusbandNameU.Text, DBLayer.GetUserID());
                                MessageBox.Show("Modified Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FillGrid(txtFCardNo.Text);
                                lbl.Text = Header;
                                Disable(true);
                            }
                            else
                            {
                                DateTime Action = Convert.ToDateTime(dpAction.Text);
                                usp_SEL_tblFamilyMemberTableAdapter.Update1(Convert.ToInt64(txtMemberID.Text), FCardNo, Name, LRelation, FName, HName, DOB, Bgroup, Gender, AgeGroup, Mobile, CNIC, CMIC, Academic, Technical, Professional, BName, Type, Designation, BAddress, BPhone, Email, Website, Fax, Active, Reason, Action, Status, OutOf, EntryDate, FromCard, ToCard, Convert.ToDateTime(TempDOB).Date, txtNameU.Text, txtFNameU.Text, txtHusbandNameU.Text, DBLayer.GetUserID());
                                MessageBox.Show("Record has been Modified", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FillGrid(FCardNo);
                                Disable(true);
                                lbl.Text           = Header;
                                btnFCardNo.Enabled = true;
                            }
                        }
                    }
                }


                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                label26.Hide();
                label28.Hide();
                //btnAllMembers.Show();
                txtFCardNo.Visible = true;
                btnClose.Visible   = true;
            }
        }