Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text != "")
            {
                //usp_SEL_TSF_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_SEL_TSF_tblFamilyMember, txtFCardNo.Text, txtName.Text);
                //MemberID = Convert.ToInt32(comDataSet.usp_SEL_TSF_tblFamilyMember.Rows[0].ItemArray[0].ToString());
                MemberID = Convert.ToInt32(usp_SEL_TSF_tblFamilyMemberTableAdapter.ScalarQuery(txtFCardNo.Text, txtName.Text));
            }

            bool CHK = DBLayer.CHK_RegNo_Death(txtRegNo.Text);

            try
            {
                string   RegNo       = txtRegNo.Text;
                string   Name        = txtName.Text;
                string   FName       = txtFName.Text;
                string   GFName      = txtGFName.Text;
                string   FCardNo     = txtFCardNo.Text;
                string   Orakh       = txtOrakh.Text;
                string   Nukh        = txtNukh.Text;
                string   Gender      = cmbGender.Text;
                string   AgeGroup    = cmbAgeGroup.Text;
                string   Relation    = cmbRelation.Text;
                DateTime DOD         = Convert.ToDateTime(dtpDOD.Text);
                DateTime EntryDate   = Convert.ToDateTime(dtpEntryDate.Text);
                string   Reason      = txtReasonOfDeath.Text;
                string   Address     = txtAddress.Text;
                string   Age         = txtAge.Text;
                string   Place       = cmbPlace.Text;
                string   AppName     = txtApplicantName.Text;
                string   AppCNIC     = txtApplicantCNIC.Text;
                string   AppRelation = cmbApplicantRelation.Text;
                DateTime DTime       = Convert.ToDateTime(dtpDtime.Text);
                string   DRCNumber   = txtDRCN.Text;
                bool     isPrinted   = chkIsPrinted.Checked;

                if (CheckField())
                {
                    if (mode == 1)
                    {
                        if (CHK)
                        {
                            MessageBox.Show("Registration Number Already Exists!!!", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            usp_SEL_DeathTableAdapter.InsertDeath(RegNo, FCardNo, Name, FName, GFName, Nukh, Orakh, Gender, DOD, Relation, AgeGroup, Reason, Address, EntryDate, Age, Place, DTime, MemberID, AppName, AppCNIC, AppRelation, DRCNumber, false);
                            Gayab(true);
                            mode = 0;
                            usp_SEL_tblFamilyMemberTableAdapter.Update_Death(FCardNo, false, "Death", DOD, MemberID);
                            MessageBox.Show("Succesfully Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            usp_SEL_DeathTableAdapter.Fill(this.comDataSet.usp_SEL_Death);
                        }
                    }
                    else if (mode == 0)
                    {
                        usp_SEL_DeathTableAdapter.UpdateDeath(id, RegNo, FCardNo, Name, FName, GFName, Nukh, Orakh, Gender, DOD, Relation, AgeGroup, Reason, Address, EntryDate, Age, Place, DTime, MemberID, AppName, AppCNIC, AppRelation, DRCNumber, isPrinted);
                        Gayab(true);
                        mode = 0;
                        btnReset.Show();
                        usp_SEL_DeathTableAdapter.Fill(this.comDataSet.usp_SEL_Death);
                        usp_SEL_tblFamilyMemberTableAdapter.Update_Death(FCardNo, false, "Death", EntryDate, MemberID);
                        MessageBox.Show("Succesfully Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                AcceptButton = btnNew;
                txtFilter.Focus();
                lbl.Text = Header;
            }
            catch (FormatException)
            {
                MessageBox.Show("Please insert valid values in respective fields!!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }