Example #1
0
        public void fillgridService()
        {
            try
            {
                int intClientID = int.Parse(lblCliId1.Text);
                BLServices blpr = new BLServices();
                SqlDataReader dr = blpr.getServicePrice1(intClientID);
                System.Data.DataTable dt = new System.Data.DataTable();

                if (dr.HasRows)
                {
                    lblServices.Text = "";
                    dt.Load(dr);
                    GVServices.DataSource = dt;
                    GVServices.DataBind();
                    if (ddlCliNm.SelectedItem.Text == "--Select--")
                    {
                        GVServices.DataSource = null;
                        GVServices.DataBind();
                        lblServices.Visible = true;
                        lblServices.Text = "Services are not available for the selected Client";
                    }
                }
                else
                {
                    GVServices.DataSource = null;
                    GVServices.DataBind();
                    lblServices.Visible = true;
                    lblServices.Text = "Services are not available for the selected Client";
                }

                dr.Close();
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if ((HttpContext.Current.Session["LoginId"]) == null)
                {
                    Response.Redirect("~/Login.aspx");
                }
                if (!Page.IsPostBack)
                {

                    Session["strFileName"] = null;
                    Session["strFilePath"] = null;
                    Session["chars"] = null;
                    Session["filenew"] = null;
                    //cbpdf.Visible = false;
                    #region------------fill DDLClient------------
                    BLProject blvc = new BLProject();
                    SqlDataReader dr = blvc.getClientNameForProject1();
                    ddlCliNm.Items.Clear();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                            ddlCliNm.Items.Add(dr.GetString(0));
                        ddlCliNm.Items.Insert(0, new ListItem("--Select--", "-1"));
                        dr.Close();
                    }
                    #endregion

                    #region----------Fill DDLTypeofWork--------------
                    BLProject bltow = new BLProject();
                    SqlDataReader dr1 = bltow.getTypeOfWorkForProject1();
                    ddlTypWrk.Items.Clear();
                    if (dr1.HasRows)
                    {
                        while (dr1.Read())
                            ddlTypWrk.Items.Add(dr1.GetString(1));
                        ddlTypWrk.Items.Insert(0, new ListItem("--Select--", "-1"));
                        dr1.Close();
                    }
                    #endregion

                    ddlStatus.Items.Insert(0, new ListItem("--Select--", "-1"));
                    #region-----------All fillgrid function call--------------
                    fillgridClerk();
                    fillgridPapers();
                    fillgridEmployees();
                    fillgridDocBoy();
                    #endregion

                    #region------------------Show values to date textboxces-----------------
                    txtDate.Text = DateTime.Now.Date.ToShortDateString();
                    txtSoftCopySent.Text = DateTime.Now.Date.ToShortDateString();
                    txtPendingDocRcd.Text = DateTime.Now.Date.ToShortDateString();
                    txtHardCopySent.Text = DateTime.Now.Date.ToShortDateString();
                    //txtPendingDocRcsp.Text = DateTime.Now.Date.ToShortDateString();
                    txtSearchInitiated.Text = DateTime.Now.Date.ToShortDateString();
                    //txtFinalReportSent.Text = DateTime.Now.Date.ToShortDateString();
                    txtSearchReceived.Text = DateTime.Now.Date.ToShortDateString();
                    txtReceiptSearch.Text = DateTime.Now.Date.ToShortDateString();
                    txtStrDtEmp.Text = DateTime.Now.Date.ToShortDateString();
                    txtEndDtEmp.Text = DateTime.Now.Date.ToShortDateString();
                    txtStrStarDtClerk.Text = DateTime.Now.Date.ToShortDateString();
                    txtStrEndDtClerk.Text = DateTime.Now.Date.ToShortDateString();
                    #endregion

                    if (Request.QueryString["ProjectId"] != null)
                    {
                        //dpdwnlstFileNames.Visible = true;
                        lblProjectId.Text = Request.QueryString["ProjectId"].ToString();
                        int intProjectId = int.Parse(lblProjectId.Text);
                        BLProject blc = new BLProject();
                        //btnOpenAddWrk.Enabled = true;
                        //btnDelAddWrk.Enabled = true;
                        //btnEmailAddWrk.Enabled = true;

                        // Code to show selected Documents
                        int gvdocid;
                        //intProjectId = int.Parse(Session["ProjectId"].ToString());
                        SqlDataReader dr3 = blc.showSelectedDoc1(intProjectId);
                        System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("docid");
                        if (dr3.HasRows)
                        {
                            while (dr3.Read())
                            {
                                int doc = dr3.GetInt32(0);
                                dt.Rows.Add(doc);
                            }
                            dr3.Close();
                        }

                        foreach (GridViewRow gvrow in GVPapers.Rows)
                        {

                            if (gvrow.RowType == DataControlRowType.DataRow)
                            {
                                System.Web.UI.WebControls.Label lblDocumentID = (gvrow.Cells[0].FindControl("lblDocumentId") as System.Web.UI.WebControls.Label);
                                gvdocid = int.Parse(lblDocumentID.Text);
                                System.Web.UI.WebControls.CheckBox chksel = (gvrow.Cells[0].FindControl("ChkBxSelDoc") as System.Web.UI.WebControls.CheckBox);
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    int doc = int.Parse(dt.Rows[i].Field<string>(0));
                                    if (doc == gvdocid)
                                    {
                                        chksel.Checked = true;
                                    }
                                }
                            }
                        }

                        //Code to show selected Employees
                        int gvempid;
                        // intProjectId = int.Parse(Session["ProjectId"].ToString());
                        SqlDataReader dr4 = blc.showSelectedEmployees1(intProjectId);
                        System.Data.DataTable dt1 = new System.Data.DataTable();
                        dt1.Columns.Add("empid");
                        if (dr4.HasRows)
                        {
                            while (dr4.Read())
                            {
                                int emp = dr4.GetInt32(0);
                                dt1.Rows.Add(emp);
                            }
                            dr4.Close();
                        }

                        foreach (GridViewRow gvrow in GVEmployees.Rows)
                        {

                            if (gvrow.RowType == DataControlRowType.DataRow)
                            {
                                System.Web.UI.WebControls.Label lblEmployeeID = (gvrow.Cells[0].FindControl("lblEmployeeID") as System.Web.UI.WebControls.Label);
                                gvempid = Convert.ToInt32(lblEmployeeID.Text);
                                System.Web.UI.WebControls.CheckBox chksel = (gvrow.Cells[0].FindControl("ChkBxSelEmp") as System.Web.UI.WebControls.CheckBox);
                                for (int i = 0; i < dt1.Rows.Count; i++)
                                {
                                    int emp = int.Parse(dt1.Rows[i].Field<string>(0));
                                    if (emp == gvempid)
                                    {
                                        chksel.Checked = true;
                                    }
                                }
                            }
                        }

                        //Code To show Selected Document Boys
                        int gvdocboyid;
                        // intProjectId = int.Parse(Session["ProjectId"].ToString());
                        SqlDataReader dr5 = blc.showSelectedDocBoys1(intProjectId);
                        System.Data.DataTable dt2 = new System.Data.DataTable();
                        dt2.Columns.Add("docboyid");
                        if (dr5.HasRows)
                        {

                            while (dr5.Read())
                            {
                                int doc = dr5.GetInt32(0);
                                dt2.Rows.Add(doc);
                            }
                            dr5.Close();
                        }

                        foreach (GridViewRow gvrow in GVDocBoy.Rows)
                        {

                            if (gvrow.RowType == DataControlRowType.DataRow)
                            {
                                System.Web.UI.WebControls.Label lblDocumentBoyID = (gvrow.Cells[0].FindControl("lblDocumentBoyID") as System.Web.UI.WebControls.Label);
                                gvdocboyid = int.Parse(lblDocumentBoyID.Text);
                                System.Web.UI.WebControls.CheckBox chksel = (gvrow.Cells[0].FindControl("ChkBxSelDocBoy") as System.Web.UI.WebControls.CheckBox);
                                for (int i = 0; i < dt2.Rows.Count; i++)
                                {
                                    int docboy = int.Parse(dt2.Rows[i].Field<string>(0));
                                    if (docboy == gvdocboyid)
                                    {
                                        chksel.Checked = true;
                                    }
                                }
                            }
                        }

                        //Code to show selected clerk
                        int gvclerkid;
                        //intProjectId = int.Parse(Session["ProjectId"].ToString());
                        SqlDataReader dr6 = blc.showSelectedClerk1(intProjectId);
                        System.Data.DataTable dt3 = new System.Data.DataTable();
                        dt3.Columns.Add("clerkid");
                        if (dr6.HasRows)
                        {
                            while (dr6.Read())
                            {
                                int clerk = dr6.GetInt32(0);
                                dt3.Rows.Add(clerk);
                            }
                        }
                        dr6.Close();
                        foreach (GridViewRow gvrow in GVClerk.Rows)
                        {

                            if (gvrow.RowType == DataControlRowType.DataRow)
                            {
                                System.Web.UI.WebControls.Label lblClerkID = (gvrow.Cells[0].FindControl("lblClerkID") as System.Web.UI.WebControls.Label);
                                gvclerkid = int.Parse(lblClerkID.Text);
                                System.Web.UI.WebControls.CheckBox chksel = (gvrow.Cells[0].FindControl("ChkBxSelClerk") as System.Web.UI.WebControls.CheckBox);
                                for (int i = 0; i < dt3.Rows.Count; i++)
                                {
                                    int clerk = int.Parse(dt3.Rows[i].Field<string>(0));
                                    if (clerk == gvclerkid)
                                    {
                                        chksel.Checked = true;
                                    }
                                }
                            }
                        }

                        SqlDataReader dr2 = blc.getProjectDetailsForUpdate1(intProjectId);
                        if (dr2.HasRows)
                        {
                            while (dr2.Read())
                            {
                                Button1.Enabled = false;
                                //btnSaveWordFile.Enabled = true;
                                ddlCliNm.Enabled = false;
                                ddlTypWrk.Enabled = false;
                                //ddlStatus.Visible = false;
                                txtDate.Text = dr2.GetDateTime(1).ToShortDateString();
                                ddlCliNm.SelectedValue = dr2.GetString(3);

                                //code for fill grid of service
                                BLServices blaee = new BLServices();
                                string strClientName1 = Convert.ToString(ddlCliNm.SelectedItem.Text);
                                SqlDataReader dr8 = blaee.getClientIDforService1(strClientName1);
                                if (dr8.HasRows)
                                {
                                    while (dr8.Read())
                                        lblCliId1.Text = dr8.GetInt32(0).ToString();
                                }
                                dr8.Close();

                                int intClientID = int.Parse(lblCliId1.Text);
                                BLServices blpr = new BLServices();
                                SqlDataReader dr9 = blpr.getServicePrice1(intClientID);
                                System.Data.DataTable dt5 = new System.Data.DataTable();
                                if (dr9.HasRows)
                                {
                                    dt5.Load(dr9);
                                    GVServices.DataSource = dt5;
                                    GVServices.DataBind();
                                }
                                dr9.Close();

                                //Code to show selected Services
                                int gvserviceid;
                                // intProjectId = int.Parse(Session["ProjectId"].ToString());
                                SqlDataReader drService = blc.showSelectedServices1(intProjectId);
                                System.Data.DataTable dtService = new System.Data.DataTable(); dtService.Columns.Add("serviceid");
                                if (drService.HasRows)
                                {
                                    while (drService.Read())
                                    {
                                        int service = drService.GetInt32(0);
                                        dtService.Rows.Add(service);
                                    }
                                }
                                drService.Close();

                                foreach (GridViewRow gvrow in GVServices.Rows)
                                {

                                    if (gvrow.RowType == DataControlRowType.DataRow)
                                    {
                                        System.Web.UI.WebControls.Label lblSeviceID = (gvrow.Cells[0].FindControl("lblServiceID") as System.Web.UI.WebControls.Label);
                                        gvserviceid = int.Parse(lblSeviceID.Text);
                                        System.Web.UI.WebControls.CheckBox chksel = (gvrow.Cells[0].FindControl("ChkBxSelService") as System.Web.UI.WebControls.CheckBox);
                                        for (int i = 0; i < dtService.Rows.Count; i++)
                                        {
                                            int service = int.Parse(dtService.Rows[i].Field<string>(0));
                                            if (service == gvserviceid)
                                            {
                                                chksel.Checked = true;
                                            }
                                        }
                                    }
                                }

                                lblTypWrkID.Text = dr2.GetInt32(4).ToString();
                                ddlTypWrk.SelectedValue = dr2.GetString(5);
                                txtCasNm.Text = dr2.GetString(6);

                                bool intExternalWork = dr2.GetBoolean(7);
                                if (intExternalWork == true)
                                    chkBxDsReqExtWrk.Checked = true;
                                else
                                    chkBxDsReqExtWrk.Checked = false;

                                bool intNeedSearch = dr2.GetBoolean(8);
                                if (intNeedSearch == true)
                                    chkBxDsReqSrch.Checked = true;
                                else
                                    chkBxDsReqSrch.Checked = false;

                                txtRemarks.Text = dr2.GetString(9);
                                txtPrice.Text = dr2.GetDecimal(10).ToString();
                                txtOtherCharge.Text = dr2.GetDecimal(11).ToString();
                                txtTotAmt.Text = dr2.GetDecimal(12).ToString();
                                txtStatus.Text = dr2.GetString(13);
                                ddlStatus.SelectedValue = dr2.GetString(13);
                                bool intIsDeleted = dr2.GetBoolean(14);
                                if (intIsDeleted == true)
                                    rbYesIsDel.Checked = true;
                                else
                                    rbNoIsDel.Checked = true;

                                int intApprove = dr2.GetInt32(15);
                                if (intApprove == 1)
                                    ChkBxApprovProject.Checked = true;
                                else
                                    ChkBxApprovProject.Checked = false;

                                txtServiceTax.Text = dr2.GetDecimal(16).ToString();
                                txtRefNo.Text = dr2.GetString(17);
                                if (dr2["LoanNo"] != DBNull.Value)
                                {
                                    txtLoanAcNoAddWrk.Text = dr2.GetString(18);
                                }
                                else
                                {
                                    txtLoanAcNoAddWrk.Text = "";
                                }

                                if (dr2["PropertyAddress"] != DBNull.Value)
                                {
                                    txtPropertyDetails.Text = dr2.GetString(19);
                                }
                                else
                                {
                                    txtPropertyDetails.Text = "";
                                }
                                if (dr2["dt_softcopysent"] != DBNull.Value)
                                {
                                    txtSoftCopySent.Text = dr2.GetDateTime(20).ToShortDateString();
                                }
                                else
                                {
                                    txtSoftCopySent.Text = DateTime.Now.Date.ToShortDateString();
                                }

                                DateTime dt_MISclient = Convert.ToDateTime("1990-01-01 00:00:00.000");

                                if (dr2["dt_search_initiated"] != DBNull.Value)
                                {
                                    txtSearchInitiated.Text = dr2.GetDateTime(22).ToShortDateString();
                                }
                                else
                                {
                                    txtSearchInitiated.Text = DateTime.Now.Date.ToShortDateString();
                                }
                                if (dr2["dt_search_received"] != DBNull.Value)
                                {
                                    txtSearchReceived.Text = dr2.GetDateTime(23).ToShortDateString();
                                }
                                else
                                {
                                    txtSearchReceived.Text = DateTime.Now.Date.ToShortDateString();
                                }
                                if (dr2["dt_search_received_receipt"] != DBNull.Value)
                                {
                                    txtReceiptSearch.Text = dr2.GetDateTime(24).ToShortDateString();
                                }
                                else
                                {
                                    txtReceiptSearch.Text = DateTime.Now.Date.ToShortDateString();
                                }
                                if (dr2["dt_hardcopysent"] != DBNull.Value)
                                {
                                    txtHardCopySent.Text = dr2.GetDateTime(25).ToShortDateString();
                                }
                                else
                                {
                                    txtHardCopySent.Text = DateTime.Now.Date.ToShortDateString();
                                }
                                if (dr2["dt_pendingdocumentsrec"] != DBNull.Value)
                                {
                                    txtPendingDocRcd.Text = dr2.GetDateTime(26).ToShortDateString();
                                }
                                else
                                {
                                    txtPendingDocRcd.Text = DateTime.Now.Date.ToShortDateString();
                                }
                                //if (dr2["dt_pendingdocumentsresp"] != DBNull.Value)
                                //{
                                //    txtPendingDocRcsp.Text = dr2.GetDateTime(27).ToShortDateString();
                                //}
                                //else
                                //{
                                //    txtPendingDocRcsp.Text = DateTime.Now.Date.ToShortDateString();
                                //}
                                //if (dr2["dt_finalreportsent"] != DBNull.Value)
                                //{
                                //    txtFinalReportSent.Text = dr2.GetDateTime(28).ToShortDateString();
                                //}
                                //else
                                //{
                                //    txtPendingDocRcsp.Text = DateTime.Now.Date.ToShortDateString();
                                //}

                                if (dr2["branch"] != DBNull.Value)
                                {
                                    txtBranchAddWrk.Text = dr2.GetString(31);
                                }
                                else
                                {
                                    txtBranchAddWrk.Text = "";
                                }
                                //if (dr2["loanamt"] != DBNull.Value)
                                //{
                                //    txtLoanAmtAddWrk.Text = dr2.GetDecimal(32).ToString();
                                //}
                                //else
                                //{
                                //    txtLoanAmtAddWrk.Text = "";
                                //}
                                if (dr2["worddoc"] != DBNull.Value)
                                {
                                    Byte[] strworddoc = (byte[])dr2["worddoc"];
                                    str = System.Text.Encoding.Default.GetString(strworddoc);
                                    Session["strFilePath"] = str;
                                }
                                else
                                {
                                    Session["strFilePath"] = null;
                                }

                                if (dr2["filename"] != DBNull.Value)
                                {
                                    //string filename = dr2.GetString(30);
                                    //string[] values = filename.Split(',');
                                    //for (int i = 0; i < values.Length; i++)
                                    //{
                                    //    values[i] = values[i].Trim();
                                    //    filename = values[i];
                                    //    dpdwnlstFileNames.Items.Add(filename);
                                    //}
                                    //Session["strFileName"] = dr2.GetString(30);
                                }
                                else
                                {
                                    Session["strFileName"] = null;
                                }
                                //TRy
                                if (dr2["EmailID"] != DBNull.Value)
                                {
                                    //txtEmail.Text = dr2.GetString(33);
                                }

                            }
                            dr2.Close();
                        }
                    }
                }
                else
                {
                    //Span1.InnerHtml = "";

                    lblResult.Text = "";
                    lblCatchError.Text = "";
                    lbltesting.Text = "";
                    lblMessageFile.Text = "";
                    lblDelMsg.Text = "";
                    //CEDate.SelectedDate = DateTime.ParseExact(txtDate.Text, CEDate.Format, null);
                    CalendarExtender9.SelectedDate = DateTime.ParseExact(txtStrDtEmp.Text, CalendarExtender9.Format, null);
                    CalendarExtender10.SelectedDate = DateTime.ParseExact(txtEndDtEmp.Text, CalendarExtender10.Format, null);
                    CalendarExtender11.SelectedDate = DateTime.ParseExact(txtStrStarDtClerk.Text, CalendarExtender11.Format, null);
                    CalendarExtender12.SelectedDate = DateTime.ParseExact(txtStrEndDtClerk.Text, CalendarExtender12.Format, null);

                    CalendarExtender1.SelectedDate = DateTime.ParseExact(txtSoftCopySent.Text, CalendarExtender1.Format, null);
                    CalendarExtender2.SelectedDate = DateTime.ParseExact(txtPendingDocRcd.Text, CalendarExtender2.Format, null);
                    CalendarExtender3.SelectedDate = DateTime.ParseExact(txtHardCopySent.Text, CalendarExtender3.Format, null);
                    //CalendarExtender5.SelectedDate = DateTime.ParseExact(txtPendingDocRcsp.Text, CalendarExtender5.Format, null);
                    CalendarExtender4.SelectedDate = DateTime.ParseExact(txtSearchInitiated.Text, CalendarExtender4.Format, null);
                    //CalendarExtender6.SelectedDate = DateTime.ParseExact(txtFinalReportSent.Text, CalendarExtender6.Format, null);
                    CalendarExtender7.SelectedDate = DateTime.ParseExact(txtSearchReceived.Text, CalendarExtender7.Format, null);
                    CalendarExtender8.SelectedDate = DateTime.ParseExact(txtReceiptSearch.Text, CalendarExtender8.Format, null);

                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }