Exemplo n.º 1
0
        //Functions--------------------------------------------------------
        //-----------------------------------------------------------------



        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;
        }
Exemplo n.º 2
0
        private void Extra(string FCardNo)
        {
            Community.DBLayer DBLayer = new Community.DBLayer();
            try
            {
                SqlConnection conn = new SqlConnection(Community.DBLayer.con_String);

                conn.Open();

                SqlCommand cmd = new SqlCommand("Select *,tblFamily.Sign,tblFamily.Active,tblFamily.FCardNo,tblFamily.FamilyLeader FROM tblHelp INNER  JOIN tblFamiy ON tblHelp.FCardNo = tblFamily.FCardNo WHERE tblHelp.FCardNo = '" + FCardNo + "'", conn);


                DataTable dt = new DataTable();

                cmd.CommandType = CommandType.Text;

                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;

                da.Fill(dt);

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("AN unknown error occured \n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            lbl.Text = Header + ">>Deleting Card";
            Community.DBLayer DBLayer = new Community.DBLayer();
            bool DELETE = DBLayer.CHK_B4_DELETE(txtFCardNo.Text);

            if (DELETE)
            {
                MessageBox.Show("Cannot be Deleted! 'Already in use'", "Unable to Delete", MessageBoxButtons.OK);
                lbl.Text = Header;
            }
            else
            {
                DialogResult result = MessageBox.Show("Are You Sure You Want to Delete", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        string FCardNo = txtFCardNo.Text;
                        usp_SEL_FAMILYTableAdapter.Delete1(FCardNo);
                        usp_SEL_FAMILYTableAdapter.Fill(comDataSet.usp_SEL_FAMILY);
                        MessageBox.Show("Deleted Succesfully!", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lbl.Text = Header;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    lbl.Text = Header;
                }
            }
        }
Exemplo n.º 4
0
        //private void btnPrint_Click(object sender, EventArgs e)
        //{
        //    int id = Convert.ToInt32(txtSerialNo.Text);
        //    SqlConnection con = new SqlConnection(Community.DBLayer.con_String);
        //    con.Open();
        //    SqlCommand cmd = new SqlCommand("Select * from tblHallBooking WHERE SerialNo =" + id, con);

        //    DataTable dt = new DataTable();

        //    SqlDataAdapter da = new SqlDataAdapter();
        //    da.SelectCommand = cmd;

        //    da.Fill(dt);
        //    Reports.Hall_Booking.frmViewer frm = new MCKJ.Reports.Hall_Booking.frmViewer();
        //    Reports.Hall_Booking.rptHallBooking rpt = new MCKJ.Reports.Hall_Booking.rptHallBooking();

        //    frm.crystalReportViewer1.ReportSource = rpt;
        //    rpt.SetDataSource(dt);
        //    rpt.SetParameterValue("SerialNo", id.ToString("00000"));
        //    rpt.SetParameterValue("SerialNo", id.ToString("00000"), rpt.Subreports[0].Name.ToString());



        //    frm.Show();
        //    con.Close();
        //}

        private void txtFCardNo_Leave(object sender, EventArgs e)
        {
            try
            {
                if (txtFCardNo.Text != "")
                {
                    int    fcardno = Convert.ToInt32(txtFCardNo.Text);
                    int    x       = 5 - txtFCardNo.Text.Length;
                    string zeros   = "";
                    for (int i = 0; i < x; i++)
                    {
                        zeros += "0";
                    }
                    txtFCardNo.Text = zeros + txtFCardNo.Text;
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Only numbers are allowed!", "Only Numbers");
            }
            string y = txtFCardNo.Text;

            Community.DBLayer DBLayer = new Community.DBLayer();
            bool result = DBLayer.CheckFamily(txtFCardNo.Text);

            for (int x = 0; x < dgvHallBooking.Rows.Count - 1; x++)
            {
                dgvHallBooking.Rows[x].Cells[0].Value = null;
            }
            if (txtFCardNo.Text != "")
            {
                if (result)
                {
                    Fill(txtFCardNo.Text);
                    txtFName.Text = FName;
                    txtHead.Text  = Head;
                    txtOrakh.Text = Orakh;


                    if (txtFCardNo.Text == "")
                    {
                        txtFCardNo.Text = y;
                    }
                }
                else
                {
                    MessageBox.Show("Family CardNo doesnot exist! Please enter a Valid CardNo.", "Invalid CardNo.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    txtHead.Text = "";
                }
            }
            usp_SEL_tblFamilyMemberTableAdapter.Fill(comDataSet.usp_SEL_tblFamilyMember, txtFCardNo.Text);
        }
Exemplo n.º 5
0
        private void GetReportByStatus()
        {
            if (cmbSearch.Text.Length <= 0)
            {
                MessageBox.Show("Please select status.");
                return;
            }
            Community.DBLayer DBLayer = new Community.DBLayer();
            try
            {
                SqlConnection conn = new SqlConnection(Community.DBLayer.con_String);

                conn.Open();

                SqlCommand cmd = new SqlCommand("usp_SEL_Family", conn);

                DataTable dt = new DataTable();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "usp_SEL_FAMILY_ByStatus";
                SqlDataAdapter da = new SqlDataAdapter();
                if (cmbSearch.Text != "Both")
                {
                    cmd.Parameters.AddWithValue("@status", (cmbSearch.Text == "Active" ? true : false));
                }

                da.SelectCommand = cmd;

                da.Fill(dt);

                MCKJ.Reports.Family_Card.frmViewer     frm = new MCKJ.Reports.Family_Card.frmViewer();
                MCKJ.Reports.Family_Card.rptFamilyCard rpt = new MCKJ.Reports.Family_Card.rptFamilyCard();

                frm.crystalReportViewer1.ReportSource = rpt;


                rpt.SetDataSource(dt);
                rpt.SetParameterValue("Filter", "Family Cards");
                frm.Show();

                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 6
0
        private void txtName_Leave(object sender, EventArgs e)
        {
            Community.DBLayer DBLayer = new Community.DBLayer();
            string            ID      = txtFCardNo.Text;
            string            Name    = txtName.Text;
            bool result = DBLayer.TRANSFER(ID, Name);

            if (txtName.Text == "" || txtFCardNo.Text == "00000")
            {
                // MessageBox.Show("Please fill the field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (result)
                {
                    try
                    {
                        string        valuee = txtName.SelectedValue.ToString();
                        SqlConnection con    = new SqlConnection(DBLayer.CON_string);
                        SqlCommand    cmd    = new SqlCommand("Select FatherName,HusbandName,Gender,LeaderRelation,DOB,AgeGroup FROM tblFamilyMember WHERE FamilyMemberID = " + valuee, con);
                        con.Open();
                        cmd.CommandType = CommandType.Text;

                        SqlDataReader reader = cmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            reader.Read();
                            txtFName.Text    = reader.GetValue(0).ToString();
                            cmbGender.Text   = reader.GetValue(2).ToString();
                            cmbRelation.Text = reader.GetValue(3).ToString();
                            cmbAgeGroup.Text = reader.GetValue(5).ToString();
                            DOB            = reader.GetValue(4).ToString();
                            txtGFName.Text = reader.GetValue(1).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Member Not Found!!!", "Unable to Search", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 7
0
        private void txtFCardNo_Leave(object sender, EventArgs e)
        {
            //if (txtFCardNo.Text.Length != 5)
            //{
            //    txtFCardNo.Text = txtFCardNo.Text.PadLeft(5, '0');
            //}
            try
            {
                if (txtFCardNo.Text != "")
                {
                    int    fcardno = Convert.ToInt32(txtFCardNo.Text);
                    int    x       = 5 - txtFCardNo.Text.Length;
                    string zeros   = "";
                    for (int i = 0; i < x; i++)
                    {
                        zeros += "0";
                    }
                    txtFCardNo.Text = zeros + txtFCardNo.Text;
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Only numbers are allowed!", "Only Numbers");
            }
            string y = txtFCardNo.Text;

            Community.DBLayer DBLayer = new Community.DBLayer();
            bool result = DBLayer.CheckFamily(txtFCardNo.Text);

            if (txtFCardNo.Text != "")
            {
                if (result)
                {
                    usp_SEL_FAMILYTableAdapter.Leader(comDataSet.usp_SEL_FAMILY, txtFCardNo.Text);
                    txtFName.Text = FName(txtFCardNo.Text, txtHead.Text);
                    if (txtFCardNo.Text == "")
                    {
                        txtFCardNo.Text = y;
                    }
                }
                else
                {
                    MessageBox.Show("Family CardNo doesnot exist! Please enter a Valid CardNo.", "Invalid CardNo.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    txtHead.Text = "";
                }
            }
        }
Exemplo n.º 8
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            Community.DBLayer dbLayer = new Community.DBLayer();
            try
            {
                DateTime startdate = Convert.ToDateTime(dtpFrom.Text);
                string   time      = startdate.TimeOfDay.ToString();
                DateTime enddate   = Convert.ToDateTime(dtpTo.Text);
                enddate = enddate.AddDays(1);



                SqlConnection con = new SqlConnection(Community.DBLayer.con_String);
                con.Open();
                SqlCommand cmd = new SqlCommand("Select tblSecurity.UserName,LoginTime,LogoffTime FROM tblLoging INNER JOIN tblSecurity ON tblLoging.UserID = tblSecurity.UserID WHERE LoginTime >='" + startdate + "' AND LoginTime <= '" + enddate + "'", con);

                DataTable dt = new DataTable();

                cmd.CommandType = CommandType.Text;

                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;

                da.Fill(dt);

                MCKJ.Reports.Loging.frmViewer frm = new frmViewer();
                MCKJ.Reports.Loging.rptLoging rpt = new rptLoging();

                rpt.SetDataSource(dt);
                frm.crystalReportViewer1.ReportSource = rpt;
                frm.Show();
                con.Close();
            }
            catch (FormatException)
            {
                MessageBox.Show("Only Numbers are allowed!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        private void FillFamilyGrid(string spName)
        {
            Community.DBLayer dblayer = new Community.DBLayer();
            SqlCommand        cmd     = new SqlCommand();
            SqlConnection     conn    = new SqlConnection(dblayer.CON_string);

            cmd.Connection  = conn;
            cmd.CommandText = spName;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@FCardNo", txtFCardNo.Text));

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            da.Fill(dt);

            if (DGFamily.DataSource != null)
            {
                DGFamily.DataSource = null;
            }
            DGFamily.DataSource = dt;

            int rows = DGFamily.Rows.Count;

            for (int count = 0; count < rows; count++)
            {
                string SNo = Convert.ToDecimal(count + 1).ToString("000");
                DGFamily.Rows[count].Cells[1].Value = SNo;
                DGFamily.RefreshEdit();
            }

            if (DGFamily.RowCount == 0)
            {
                DGFamily.Enabled = false;
            }
            else
            {
                DGFamily.Enabled = true;
            }
        }
Exemplo n.º 10
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder query  = new StringBuilder();
                StringBuilder filter = new StringBuilder();

                query.Append(@"SELECT     tblHelp.ID, tblHelp.FCardNo, tblHelp.HeadofFamily, tblHelp.FName, tblHelp.Orakh, tblHelp.ReceiveDate, tblHelp.Status, tblHelp.Amount, 
                      tblHelp.CompleteDate, tblHelp.SerialNo, tblHelp.Remarks, tblAids.Aid, tblFamilyMember.MemberName, tblHelp.AidFrom
FROM         tblHelp INNER JOIN
                      tblAids ON tblHelp.HelpType = tblAids.ID INNER JOIN
                      tblFamilyMember ON tblHelp.Name = tblFamilyMember.FamilyMemberID ");
                bool isWhereIncluded = false;
                if (chkByAidType.Checked)
                {
                    query.Append("where HelpType =" + cmbAidType.SelectedValue);
                    isWhereIncluded = true;
                    filter.Append("Aid Type=" + cmbAidType.Text + ",");
                }
                if (chkByFamilyCard.Checked)
                {
                    if (!isWhereIncluded)
                    {
                        query.Append(" where "); isWhereIncluded = true;
                    }
                    else
                    {
                        query.Append(" AND ");
                    }
                    query.Append(" tblHelp.FCardNo='" + txtFamilyCardNo.Text.PadLeft(5, '0') + "'");
                    filter.Append("Family Card=" + txtFamilyCardNo.Text.PadLeft(5, '0') + ",");
                }
                if (chkByOrakh.Checked)
                {
                    if (!isWhereIncluded)
                    {
                        query.Append(" where "); isWhereIncluded = true;
                    }
                    else
                    {
                        query.Append(" AND ");
                    }
                    query.Append(" tblHelp.Orakh='" + cmbOrakh.Text + "'");
                    filter.Append("Orakh=" + cmbOrakh.Text + ",");
                }
                if (chkByStatus.Checked)
                {
                    if (!isWhereIncluded)
                    {
                        query.Append(" where "); isWhereIncluded = true;
                    }
                    else
                    {
                        query.Append(" AND ");
                    }
                    query.Append(" tblHelp.Status='" + cmbStatus.Text + "'");
                    filter.Append("Status=" + cmbStatus.Text + ",");
                }
                if (chkAidFrom.Checked)
                {
                    query.Append("where AidFrom ='" + cmbAidFrom.Text + "'");
                    isWhereIncluded = true;
                    filter.Append("Aid From=" + cmbAidFrom.Text + ",");
                }
                query.Append(" ORDER BY tblHelp.FCardNo Asc");
                Community.DBLayer DBLayer = new Community.DBLayer();
                DataTable         dt      = DBLayer.GetDataByQuery(query.ToString());
                MCKJ.ComDataSet   dsCom   = new ComDataSet();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr    = dsCom.tblHelp.NewRow();
                    int     index = dsCom.tblHelp.Rows.Count - 1;
                    for (int j = 0; j < dsCom.tblHelp.Columns.Count; j++)
                    {
                        dr[dsCom.tblHelp.Columns[j].ColumnName] = dt.Rows[i][dsCom.tblHelp.Columns[j].ColumnName];
                    }
                    dsCom.tblHelp.Rows.Add(dr);
                }

                MCKJ.Reports.FamilyAid.rptFamilyAid rptAidRpt = new rptFamilyAid();
                MCKJ.Reports.FamilyAid.frmViewer    frmViewer = new frmViewer();
                rptAidRpt.SetDataSource(dsCom);
                frmViewer.crystalReportViewer1.ReportSource = rptAidRpt;
                string filterSettings = filter.ToString();
                rptAidRpt.SetParameterValue("Filter", "");
                if (filterSettings.Length > 0)
                {
                    rptAidRpt.SetParameterValue("Filter", filterSettings.Substring(0, filterSettings.Length - 1));
                }

                frmViewer.Show();


                //if (chkByAidType.Checked == false && chkByFamilyCard.Checked == false && chkByOrakh.Checked == false && chkByStatus.Checked == false)
                //{

                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 11
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            textBox1_Leave(sender, e);
            string Status      = "";
            string RenewalYear = "";
            string FCardNo     = textBox1.Text;
            string Head        = "";
            string Orakh       = "";
            string FName       = "";

            Community.DBLayer DBLayer = new Community.DBLayer();
            try
            {
                SqlConnection conn = new SqlConnection(Community.DBLayer.con_String);

                conn.Open();

                SqlCommand cmd = new SqlCommand("SELECT tblHelp.ID, tblHelp.FCardNo, tblHelp.HeadofFamily, tblHelp.FName, tblHelp.Orakh, tblHelp.ReceiveDate, tblHelp.Status, tblHelp.Amount,tblHelp.CompleteDate, tblHelp.SerialNo, tblHelp.Remarks, tblAids.Aid, tblFamilyMember.MemberName FROM tblHelp INNER JOIN tblAids ON tblHelp.HelpType = tblAids.ID INNER JOIN tblFamilyMember ON tblHelp.Name = tblFamilyMember.FamilyMemberID WHERE tblHelp.FCardNo = '" + FCardNo + "'", conn);


                DataTable dt = new DataTable();

                cmd.CommandType = CommandType.Text;

                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;
                SqlCommand Command1 = new SqlCommand("Select tblFamily.Active,tblFamily.FCardNo,tblFamily.FamilyLeader,tblFamily.Sign FROM tblFamily WHERE tblFamily.FCardNo = '" + FCardNo + "'", conn);
                Command1.CommandType = CommandType.Text;
                SqlDataReader cReader;

                cReader = Command1.ExecuteReader();

                cReader.Read();
                if (cReader.HasRows)
                {
                    bool chk = false;
                    if (cReader.GetValue(0) != DBNull.Value)
                    {
                        chk = Convert.ToBoolean(cReader.GetValue(0));
                        if (chk == true)
                        {
                            Status = "Active";
                        }
                        else
                        {
                            Status = "Inactive";
                        }
                    }
                    else
                    {
                        Status = "";
                    }
                    if (cReader.GetValue(2) != DBNull.Value)
                    {
                        Head = cReader.GetValue(2).ToString();
                    }
                    else
                    {
                        Head = "";
                    }
                    if (cReader.GetValue(3) != DBNull.Value)
                    {
                        Orakh = cReader.GetValue(3).ToString();
                    }
                    else
                    {
                        Orakh = "";
                    }
                }
                else
                {
                    Status = "Inactive";
                    Orakh  = "";
                    Head   = "";
                }
                cReader.Close();


                SqlCommand Command2 = new SqlCommand("Select RenewalYear FROM tblRenewal WHERE tblRenewal.FCardNo = '" + FCardNo + "' ORDER By ID desc", conn);
                Command2.CommandType = CommandType.Text;
                SqlDataReader cReader1;

                cReader1 = Command2.ExecuteReader();

                cReader1.Read();
                if (cReader1.HasRows)
                {
                    bool chk = false;
                    if (cReader1.GetValue(0) != DBNull.Value)
                    {
                        RenewalYear = cReader1.GetValue(0).ToString();
                    }
                    else
                    {
                        RenewalYear = "";
                    }
                }
                else
                {
                    RenewalYear = "";
                }
                cReader1.Close();

                SqlCommand Command3 = new SqlCommand("Select FatherName FROM tblFamilyMember WHERE tblFamilyMember.FCardNo = '" + FCardNo + "' AND MemberName = '" + Head + "'", conn);
                Command3.CommandType = CommandType.Text;
                SqlDataReader cReader2;

                cReader2 = Command3.ExecuteReader();

                cReader2.Read();
                if (cReader2.HasRows)
                {
                    bool chk = false;
                    if (cReader2.GetValue(0) != DBNull.Value)
                    {
                        FName = cReader2.GetValue(0).ToString();
                    }
                    else
                    {
                        FName = "";
                    }
                }
                else
                {
                    FName = "";
                }
                cReader2.Close();


                da.Fill(dt);


                MCKJ.Reports.Family_Card.frmViewer frm = new frmViewer();
                MCKJ.Reports.Family_Card.rptStatus rpt = new rptStatus();

                frm.crystalReportViewer1.ReportSource = rpt;


                rpt.SetDataSource(dt);

                rpt.SetParameterValue(0, RenewalYear);
                rpt.SetParameterValue(1, Status);
                rpt.SetParameterValue(2, FCardNo);
                rpt.SetParameterValue(3, Head);
                rpt.SetParameterValue(4, Orakh);
                rpt.SetParameterValue(5, FName);

                frm.Show();

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("AN unknown error occured \n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            //string FCardNo = textBox1.Text;
            //Community.DBLayer DBLayer = new Community.DBLayer();
            //try
            //{
            //    SqlConnection conn = new SqlConnection(Community.DBLayer.con_String);

            //    conn.Open();

            //    SqlCommand cmd = new SqlCommand("Select *,tblFamily.Sign,tblFamily.Active,tblFamily.FCardNo,tblFamily.FamilyLeader FROM tblHelp INNER  JOIN tblFamiy ON tblHelp.FCardNo = tblFamily.FCardNo WHERE tblHelp.FCardNo = '"+ FCardNo + "'", conn);


            //    DataTable dt = new DataTable();

            //    cmd.CommandType = CommandType.Text;

            //    SqlDataAdapter da = new SqlDataAdapter();

            //    da.SelectCommand = cmd;

            //    da.Fill(dt);


            //    MCKJ.Reports.Members.frmViewer frm = new MCKJ.Reports.Members.frmViewer();
            //    MCKJ.Reports.Members.rptMembers rpt = new MCKJ.Reports.Members.rptMembers();

            //    frm.crystalReportViewer1.ReportSource = rpt;


            //    rpt.SetDataSource(dt);

            //    rpt.SetParameterValue("Filter", "Male Members");

            //    frm.Show();

            //    conn.Close();

            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("AN unknown error occured \n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //}
        }
Exemplo n.º 12
0
        private void Print_NIC()
        {
            try
            {
                string[] Query = { "", "", "", "" };
                if (txtCMIC1.Text == "" && txtCMIC2.Text == "" && txtCMIC3.Text == "" && txtCMIC4.Text == "")
                {
                    MessageBox.Show("Please enter atleast One Community ID Card Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (txtCMIC1.Text != "")
                    {
                        Query[0] = "RIGHT(tblNIC.NIC,5) = '" + txtCMIC1.Text + "'";
                    }
                    if (txtCMIC2.Text != "    -   -")
                    {
                        Query[1] = "RIGHT(tblNIC.NIC,5) = '" + txtCMIC2.Text + "'";
                    }
                    if (txtCMIC3.Text != "    -   -")
                    {
                        Query[2] = "RIGHT(tblNIC.NIC,5) = '" + txtCMIC3.Text + "'";
                    }
                    if (txtCMIC4.Text != "    -   -")
                    {
                        Query[3] = "RIGHT(tblNIC.NIC,5) = '" + txtCMIC4.Text + "'";
                    }


                    string QUERY = "";
                    for (int x = 0; x < 4; x++)
                    {
                        if (QUERY == "")
                        {
                            if (Query[x] != "")
                            {
                                QUERY += Query[x] + " ";
                            }
                        }
                        else
                        {
                            if (Query[x] != "")
                            {
                                QUERY += " OR " + Query[x];
                            }
                        }
                    }
                    int len = QUERY.Length;

                    Community.DBLayer dblayer = new Community.DBLayer();
                    SqlConnection     con     = new SqlConnection(Community.DBLayer.con_String);
                    string            query   = richTextBox1.Text;
                    query = query.Replace("NIC = @NIC", QUERY);
                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.CommandType = CommandType.Text;

                    DataTable dt = new DataTable();

                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        con.Close();
                        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();
                        MCKJ.Reports.Members.rptNIC_back rptBack = new MCKJ.Reports.Members.rptNIC_back();
                        rpt.SetDataSource(dt);
                        rptBack.SetDataSource(dt);
                        frm.crystalReportViewer1.ReportSource = rpt;
                        frm._nicbackbuttonvisible             = true;
                        frm._rptNICback  = rptBack;
                        frm._rptNICfront = rpt;
                        frm.Show();
                    }
                    else
                    {
                        MessageBox.Show("No record to preview please enter other ID Card No.s", "No record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 13
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;
            }
        }
Exemplo n.º 14
0
        private void btnAllMembers_Click(object sender, EventArgs e)
        {
            Community.DBLayer dblayer = new Community.DBLayer();
            btnNonActiveMembers.Enabled = true;
            btnActiveMembers.Enabled    = true;
            string x = txtFCardNo.Text;

            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)
                {
                    btnView.Enabled = true;
                    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;
                    }

                    FillGrid_All(txtFCardNo.Text);
                    //FillFamilyGrid("usp_SEL_tblAllFamilyMembers");
                    if (DGFamily.RowCount == 0)
                    {
                        DGFamily.Enabled = false;
                    }
                    else
                    {
                        DGFamily.Enabled = true;
                    }
                    //btnDelete.Enabled = true;
                    if (txtFCardNo.Text == "")
                    {
                        txtFCardNo.Text = x;
                    }
                }
                else
                {
                    MessageBox.Show("Family CardNo doesnot exist! Please try Again.", "Invalid CardNo.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    btnDelete.Enabled = false;
                    btnAdd.Enabled    = false;
                    btnEdit.Enabled   = false;
                    DGFamily.Enabled  = false;
                    btnView.Enabled   = false;
                }
            }
        }
Exemplo n.º 15
0
        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
            {
                if (Chk == 0)
                {
                    bool result = dblayer.CheckFamily(txtFCardNo.Text);
                    if (result)
                    {
                        usp_SEL_FAMILYTableAdapter.Leader(comDataSet.usp_SEL_FAMILY, txtFCardNo.Text);

                        FillGrid(txtFCardNo.Text);
                        //FillGrid(txtFCardNo.Text);
                        btnView.Enabled = true;
                        //User_Right();
                        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;
                        }

                        Chk = 0;
                        if (DGFamily.RowCount == 0)
                        {
                            DGFamily.Enabled  = false;
                            btnEdit.Enabled   = false;
                            btnDelete.Enabled = false;
                            btnView.Enabled   = false;
                        }
                        else
                        {
                            DGFamily.Enabled = true;
                        }

                        if (txtFCardNo.Text == "")
                        {
                            txtFCardNo.Text = x;
                        }
                        this.AcceptButton = btnAdd;
                    }
                    else
                    {
                        MessageBox.Show("Family CardNo doesnot exist! Please enter a Valid CardNo.", "Invalid CardNo.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        btnDelete.Enabled    = false;
                        btnAdd.Enabled       = false;
                        btnEdit.Enabled      = false;
                        DGFamily.Enabled     = false;
                        btnView.Enabled      = false;
                        txtOrakh.Text        = "";
                        txtFamilyLeader.Text = "";
                    }
                }
            }
        }