Example #1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            String strSqlQueryForIllnessId = "select max([dbo].[tbl_illness].[Illness_Id]) from [dbo].[tbl_illness]";

            SqlCommand cmdQueryForIllnessId = new SqlCommand(strSqlQueryForIllnessId, connRNDB);

            cmdQueryForIllnessId.CommandType = CommandType.Text;

            if (connRNDB.State == ConnectionState.Open)
            {
                connRNDB.Close();
                connRNDB.Open();
            }
            else if (connRNDB.State == ConnectionState.Closed)
            {
                connRNDB.Open();
            }
            Object objIllnessId = cmdQueryForIllnessId.ExecuteScalar();

            if (connRNDB.State == ConnectionState.Open)
            {
                connRNDB.Close();
            }

            if (objIllnessId == null)
            {
                frmIllnessCreationPage frmIllnessCreation = new frmIllnessCreationPage();

                frmIllnessCreation.nIllnessId          = 1;
                frmIllnessCreation.nLoggedInUserId     = nLoggedInUserId;
                frmIllnessCreation.strCaseNo           = strCaseIdIllness;
                frmIllnessCreation.strIndividualNo     = strIndividualId;
                frmIllnessCreation.MembershipStartDate = MembershipStartDate;

                frmIllnessCreation.ShowDialog(this);
            }
            else
            {
                frmIllnessCreationPage frmIllnessCreation = new frmIllnessCreationPage();

                int nNewIllnessId = Int32.Parse(objIllnessId.ToString());
                nNewIllnessId++;

                frmIllnessCreation.nIllnessId          = nNewIllnessId;
                frmIllnessCreation.nLoggedInUserId     = nLoggedInUserId;
                frmIllnessCreation.strCaseNo           = strCaseIdIllness;
                frmIllnessCreation.strIndividualNo     = strIndividualId;
                frmIllnessCreation.MembershipStartDate = MembershipStartDate;

                frmIllnessCreation.ShowDialog(this);
            }
        }
Example #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int?nIllnessIdSelected   = null;
            int nNumberOfRowSelected = 0;
            int nRowSelected         = 0;

            //for (int i = 0; i < gvIllness.Rows.Count; i++)
            //{
            //    if (gvIllness["Selected", i].Selected)
            //    {
            //        nNumberOfRowSelected++;
            //        nIllnessIdSelected = Int32.Parse(gvIllness["Illness_Id", i].Value.ToString());
            //        nRowSelected = i;
            //    }
            //}

            foreach (DataGridViewRow row in gvIllness.Rows)
            {
                DataGridViewCheckBoxCell chkSelectedCell = row.Cells["Selected"] as DataGridViewCheckBoxCell;

                if (Boolean.Parse(chkSelectedCell.Value.ToString()) == true)
                {
                    nNumberOfRowSelected++;
                    nIllnessIdSelected = Int32.Parse(row.Cells["Illness_Id"].Value.ToString());
                    nRowSelected       = row.Index;
                }
            }

            if (nNumberOfRowSelected == 1)
            {
                frmIllnessCreationPage frm = new frmIllnessCreationPage();
                frm.mode            = IllnessMode.Edit;
                frm.nLoggedInUserId = nLoggedInUserId;
                frm.strIndividualNo = gvIllness["Individual_Id", nRowSelected].Value.ToString();
                frm.nIllnessId      = nIllnessIdSelected;

                frm.ShowDialog();
            }
            else if (nNumberOfRowSelected > 1)
            {
                MessageBox.Show("You have selected more than one Illness.", "Alert");
                return;
            }
            else if (nNumberOfRowSelected == 0)
            {
                MessageBox.Show("Please selected one of Illness.", "Alert");
                return;
            }
        }