Esempio n. 1
0
        private void setK2WorkCount()
        {
            string _ConnectionString = "";
            string logonName         = SharedRules.LogonName();

            string currentUserID = SharedRules.FindUserID(logonName, this.Page);

            if (string.IsNullOrEmpty(currentUserID))
            {
                currentUserID = Request.QueryString["USERID"] != null
                    ? Request.QueryString["USERID"].ToString()
                    : "5050108";
            }

            DataTable dtDb = Extension.GetDataTable("SiteSetting");
            {
                if (!dtDb.DataTableIsNullOrEmpty())
                {
                    _ConnectionString = dtDb.Rows[0]["Value"].ToString();
                }
            }
            DataClassesDataAccessDataContext db = new DataClassesDataAccessDataContext(_ConnectionString);
            List <TRNDocument> listDocument     = db.TRNDocuments.Where(x => x.WaitingFor.Contains(currentUserID)).ToList();
            string             counter          = (listDocument.Count() > 999 ? 999 : listDocument.Count()).ToString();

            lbl_WorklistCounter.Text = counter;
        }
        protected void InitialData()
        {
            DataClassesDataAccessDataContext db = new DataClassesDataAccessDataContext(Extension.GetDBConnectionString());

            vs_isDocSetCreated = false;
            vs_isAttach        = false;
            vs_isITAdmin       = false;

            string spGroup = "Admin_ITEdoc";

            if (!string.IsNullOrEmpty(spGroup))
            {
                List <string> userList = SharedRules.GetAllUserInGroup(spGroup);
                DataTable     dtEmp    = Extension.GetEmployeeData(this.Page).Copy();
                if (!dtEmp.DataTableIsNullOrEmpty())
                {
                    foreach (string user in userList)
                    {
                        if (vs_CurrentUserID == SharedRules.FindUserID(user, this.Page))
                        {
                            vs_isITAdmin = true;
                            break;
                        }
                    }
                }
            }

            // Initial Login user as an Approver
            hdn_ApproverID.Value = vs_CurrentUserID;
            if (!string.IsNullOrWhiteSpace(hdn_ApproverID.Value))
            {
                var emp = Extension.GetSpecificEmployeeFromTemp(Page, vs_CurrentUserID);
                var dep = emp.RESULT.First();
                lbl_Approver.Text = string.Format("{0}{1} {2}", emp.PREFIX_TH, emp.FIRSTNAME_TH, emp.LASTNAME_TH);
            }
            //if not Admin_ITEDoc
            if (!vs_isITAdmin)
            {
                lkb_SearchApprover.Enabled = false;
            }

            vs_DocTypeTable = SharedRules.GetList("MstDocumentType", @"<View><Query><Where><And><Eq><FieldRef Name='IsActive' /><Value Type='Boolean'>1</Value></Eq><Eq><FieldRef Name='Level' /><Value Type='Number'>0</Value></Eq></And></Where></Query></View>");

            gv_DelegateByDocType.DataSource = new List <string>();
            gv_DelegateByDocType.DataBind();
            BindingDelegateGV();
        }
        private void LoadDataEmpToCache(string sFilterKeyword)
        {
            DataTable dtEmp = Extension.GetEmployeeData(this.Page).Copy();

            if (vs_popUpTarget == "Approver")
            {
                //Merge Table
                DataClassesDataAccessDataContext db        = new DataClassesDataAccessDataContext(Extension.GetDBConnectionString());
                List <TRNEmployeeExtension>      listEmpEx = db.TRNEmployeeExtensions.ToList();
                if (listEmpEx.Count > 0)
                {
                    var listEmp = Extension.DataTableToList <TRNEmployeeExtension>(dtEmp);
                    if (listEmp.Count > 0)
                    {
                        foreach (var item in listEmpEx)
                        {
                            listEmp.Add(item);
                        }
                        listEmp = listEmp.OrderBy(x => x.EMPLOYEEID).ToList();
                        dtEmp   = Extension.ListToDataTable <TRNEmployeeExtension>(listEmp);
                    }
                }
            }

            if (!string.IsNullOrEmpty(sFilterKeyword))
            {
                DataView dvFilter = dtEmp.Copy().DefaultView;
                dvFilter.RowFilter = string.Format(@"
				DEPARTMENT_NAME_TH LIKE '%{0}%'
				OR SUBDEPARTMENT_NAME_TH LIKE '%{0}%'
				OR POSTION_NAME_TH LIKE '%{0}%'
				OR EmployeeID LIKE '%{0}%' 
				OR FIRSTNAME_TH LIKE '%{0}%' 
				OR LASTNAME_TH LIKE '%{0}%' 
				OR PREFIX_TH LIKE '%{0}%' 
				OR FIRSTNAME_EN LIKE '%{0}%' 
				OR LASTNAME_EN LIKE '%{0}%' 
				OR PREFIX_EN LIKE '%{0}%' 
				OR Email LIKE '%{0}%'
                OR EmployeeName_TH LIKE '%{0}%'
                OR EmployeeName_EN LIKE '%{0}%'", sFilterKeyword);
                dtEmp = dvFilter.ToTable();
            }
            gv_searchEmpReqTable.DataSource = dtEmp;
            gv_searchEmpReqTable.DataBind();
        }
        protected void BindingDelegateGV()
        {
            DataClassesDataAccessDataContext db = new DataClassesDataAccessDataContext(Extension.GetDBConnectionString());
            List <v_TRNDelegateDetail>       listDelegateView = db.v_TRNDelegateDetails.ToList();

            if (!string.IsNullOrEmpty(hdn_DelegateToID.Value))
            {
                listDelegateView = listDelegateView.Where(x => x.ApproverID == hdn_ApproverID.Value).ToList();
            }
            if (!string.IsNullOrEmpty(hdn_DelegateToID.Value))
            {
                listDelegateView = listDelegateView.Where(x => x.DelegateToID == hdn_DelegateToID.Value).ToList();
            }
            if (!string.IsNullOrEmpty(txt_DateFrom.Text) && string.IsNullOrEmpty(txt_DateTo.Text))
            {
                DateTime dFilteredDateFrom = DateTime.ParseExact(string.Format("{0} 00:00:01", txt_DateFrom.Text), "dd/MM/yyyy HH:mm:ss", ctli);
                listDelegateView = listDelegateView.Where(x => (x.DateFrom >= dFilteredDateFrom) || (x.DateTo >= dFilteredDateFrom)).ToList();
            }
            else if (string.IsNullOrEmpty(txt_DateFrom.Text) && !string.IsNullOrEmpty(txt_DateTo.Text))
            {
                DateTime dFilteredDateTo = DateTime.ParseExact(string.Format("{0} 23:59:59", txt_DateTo.Text), "dd/MM/yyyy HH:mm:ss", ctli);
                listDelegateView = listDelegateView.Where(x => (x.DateTo <= dFilteredDateTo) || (x.DateFrom <= dFilteredDateTo)).ToList();
            }
            else if (!string.IsNullOrEmpty(txt_DateFrom.Text) && !string.IsNullOrEmpty(txt_DateTo.Text))
            {
                DateTime dFilteredDateFrom = DateTime.ParseExact(string.Format("{0} 00:00:01", txt_DateFrom.Text), "dd/MM/yyyy HH:mm:ss", ctli);
                DateTime dFilteredDateTo   = DateTime.ParseExact(string.Format("{0} 23:59:59", txt_DateTo.Text), "dd/MM/yyyy HH:mm:ss", ctli);
                listDelegateView = listDelegateView.Where(x => (x.DateTo >= dFilteredDateFrom) || (x.DateFrom <= dFilteredDateTo)).ToList();
            }
            listDelegateView     = listDelegateView.OrderByDescending(x => x.ModifiedDate).ToList();
            vs_dt_PendingDocType = Extension.ListToDataTable <v_TRNDelegateDetail>(listDelegateView.Where(x => x.IsByDocType == true).ToList());

            gv_DelegateByDocType.DataSource = vs_dt_PendingDocType;
            gv_DelegateByDocType.DataBind();

            vs_dt_PendingDocNo            = Extension.ListToDataTable <v_TRNDelegateDetail>(listDelegateView.Where(x => x.IsByDocType == false).ToList());
            gv_DelegateByDocNo.DataSource = vs_dt_PendingDocNo;
            gv_DelegateByDocNo.DataBind();

            //Filter by txt_search
            if (!string.IsNullOrWhiteSpace(txt_search.Text))
            {
                Extension.SearchGridview(gv_DelegateByDocNo, txt_search.Text, this.Page);
                Extension.SearchGridview(gv_DelegateByDocType, txt_search.Text, this.Page);
            }
        }
        //protected void chk_ByDocType_CheckedChanged(object sender, EventArgs e)
        //{
        //    CheckBox checkBox = (CheckBox)sender;
        //    CheckBox checkHead = (CheckBox)gv_DelegateByDocType.HeaderRow.FindControl("chk_HeadByDocType");
        //    if (!checkBox.Checked)
        //    {
        //        checkHead.Checked = false;
        //        vs_SelectedItems--;
        //        btn_Submit.OnClientClick = "return confirm('ไม่มีประเภทเอกสารที่ถูกเลือก');";
        //    }
        //    else
        //    {
        //        vs_SelectedItems++;
        //        btn_Submit.OnClientClick = string.Format("return confirm('ต้องการให้สิทธิ์ {0} ประเภทเอกสารใช่หรือไม่?');", vs_SelectedItems);
        //        if (vs_SelectedItems == gv_DelegateByDocType.Rows.Count)
        //        {
        //            checkHead.Checked = true;
        //            btn_Submit.OnClientClick = string.Format("return confirm('ต้องการให้สิทธิ์ทุกประเภทเอกสารใช่หรือไม่?');", vs_SelectedItems);
        //        }
        //    }
        //}

        //protected void chk_HeadByDocType_CheckedChanged(object sender, EventArgs e)
        //{
        //    CheckBox headBox = (CheckBox)sender;
        //    vs_SelectedItems = 0;

        //    foreach (GridViewRow row in gv_DelegateByDocType.Rows)
        //    {
        //        CheckBox chk = (CheckBox)row.FindControl("chk_ByDocType");
        //        if (chk != null)
        //        {
        //            if (headBox.Checked)
        //            {
        //                vs_SelectedItems++;
        //            }
        //            chk.Checked = headBox.Checked;
        //        }
        //    }

        //    if (headBox.Checked)
        //    {
        //        btn_Submit.OnClientClick = string.Format("return confirm('ต้องการให้สิทธิ์ทุกประเภทเอกสารใช่หรือไม่?');", vs_SelectedItems);
        //    }
        //    else
        //    {
        //        btn_Submit.OnClientClick = "return confirm('ไม่มีประเภทเอกสารที่ถูกเลือก');";
        //    }
        //}

        protected void gv_DelegateByDocType_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.backgroundColor='#bdcde4';";
                e.Row.Attributes["onmouseout"]  = "this.style.backgroundColor='white';";

                DataClassesDataAccessDataContext db = new DataClassesDataAccessDataContext(Extension.GetDBConnectionString());

                #region | Document Type |
                Label lblDocType  = (Label)e.Row.FindControl("lbl_DocType");
                var   objLDocType = DataBinder.Eval(e.Row.DataItem, "DocType");
                if (lblDocType != null)
                {
                    if (objLDocType != null && objLDocType != DBNull.Value)
                    {
                        //DataTable dtDocumentType = SharedRules.GetList("MstDocumentType", "<View><Query><Where><And><Eq><FieldRef Name='DocTypeCode' /><Value Type='text'>" + objLDocType.ToString() + "</Value></Eq><Eq><FieldRef Name='IsActive' /><Value Type='Boolean'>1</Value></Eq></And></Where><RowLimit>100000</RowLimit></Query></View>");
                        DataTable dtDocumentType = Extension.GetDataTable("MstDocumentType");
                        if (!dtDocumentType.DataTableIsNullOrEmpty())
                        {
                            DataView dv = dtDocumentType.AsDataView();
                            dv.RowFilter = string.Format("Value = '{0}'", objLDocType.ToString());;
                            DataTable oResult = dv.ToTable();

                            //var oResult = dtDocumentType.AsEnumerable().Where(r => r.Field<string>("DocTypeCode").ToString() == objLDocType.ToString()).Select().ToList();
                            //dtDocumentType = Extension.ListToDataTable(oResult);
                            if (!oResult.DataTableIsNullOrEmpty())
                            {
                                lblDocType.Text = oResult.Rows[0]["DocTypeName"].ToString();
                            }
                        }
                    }
                }
                #endregion

                #region | Delegate TO |
                var lbl_DelegateTo = (Label)e.Row.FindControl("lbl_DelegateTo");
                var objDelegateTo  = DataBinder.Eval(e.Row.DataItem, "DelegateToID");
                if (lbl_DelegateTo != null && objDelegateTo != null && objDelegateTo != DBNull.Value)
                {
                    var delTo = Extension.GetSpecificEmployeeFromTemp(Page, objDelegateTo.ToString());
                    lbl_DelegateTo.Text = string.Format("{0} {1}", delTo.FIRSTNAME_TH, delTo.LASTNAME_TH);
                }
                #endregion


                #region | Date From |
                Label lblDateFrom = (Label)e.Row.FindControl("lbl_FromDate");
                var   objDateFrom = DataBinder.Eval(e.Row.DataItem, "DateFrom");
                if (lblDateFrom != null && objDateFrom != null && objDateFrom != DBNull.Value)
                {
                    string date = ((DateTime)objDateFrom).ToString("dd/MM/yyyy");
                    lblDateFrom.Text = date;
                }
                #endregion
                #region | Date To |
                Label lblDateTo = (Label)e.Row.FindControl("lbl_ToDate");
                var   objDateTo = DataBinder.Eval(e.Row.DataItem, "DateTo");
                if (lblDateTo != null && objDateTo != null && objDateTo != DBNull.Value)
                {
                    string date = ((DateTime)objDateTo).ToString("dd/MM/yyyy");
                    lblDateTo.Text = date;
                }
                #endregion

                #region | Attachment |

                var objDelegateID = DataBinder.Eval(e.Row.DataItem, "DelegateID");
                List <TRNAttachFileDelegate> listAttach = db.TRNAttachFileDelegates.Where(x => x.DelegateID == Convert.ToInt32(objDelegateID.ToString())).ToList();
                if (listAttach.Count > 0)
                {
                    HyperLink hpl_AttachDoc = (HyperLink)e.Row.FindControl("hpl_AttachDoc");
                    var       objAttachDoc  = listAttach[0].AttachFile;
                    var       objAttachPath = listAttach[0].AttachFilePath;
                    if (hpl_AttachDoc != null)
                    {
                        if (!string.IsNullOrEmpty(objAttachDoc) && !string.IsNullOrEmpty(objAttachPath))
                        {
                            hpl_AttachDoc.Text        = objAttachDoc.ToString();
                            hpl_AttachDoc.NavigateUrl = objAttachPath.ToString();
                        }
                    }
                }
                #endregion

                #region | ModiFied Date |
                Label lbl_ModifiedDate = (Label)e.Row.FindControl("lbl_ModifiedDate");
                var   objModifiedDate  = DataBinder.Eval(e.Row.DataItem, "ModifiedDate");
                if (lbl_ModifiedDate != null && objModifiedDate != DBNull.Value && objModifiedDate != null)
                {
                    lbl_ModifiedDate.Text = DateTime.Parse(objModifiedDate.ToString()).ToString("dd/MM/yyyy");
                }
                #endregion
                #region | ModiFied By |
                Label lbl_ModifiedBy = (Label)e.Row.FindControl("lbl_ModifiedBy");
                var   objModifiedBy  = DataBinder.Eval(e.Row.DataItem, "ModifiedBy");
                if (lbl_ModifiedBy != null)
                {
                    var empMod = Extension.GetSpecificEmployeeFromTemp(Page, objModifiedBy.ToString());
                    lbl_ModifiedBy.Text = string.Format("{0} {1}", empMod.FIRSTNAME_TH, empMod.LASTNAME_TH);
                }
                #endregion

                #region | Status |
                Label lblStatus = (Label)e.Row.FindControl("lbl_Status");
                var   objStatus = DataBinder.Eval(e.Row.DataItem, "IsActive");
                if (lblStatus != null)
                {
                    if (objStatus != DBNull.Value && objStatus != null)
                    {
                        if (objDateTo != null && objDateFrom != DBNull.Value && objDateFrom != null)
                        {
                            DateTime dateFrom = DateTime.Parse(objDateFrom.ToString());
                            DateTime dateTo   = objDateTo == DBNull.Value ? DateTime.MaxValue : DateTime.Parse(objDateTo.ToString());
                            if (DateTime.Now >= dateFrom && DateTime.Now <= dateTo)
                            {
                                lblStatus.Text = "Active";
                            }
                            else
                            {
                                lblStatus.Text = "Inactive";
                            }
                        }
                    }
                }
                #endregion
            }
        }
        protected void gv_DelegateByDocNo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.backgroundColor='#bdcde4';";
                e.Row.Attributes["onmouseout"]  = "this.style.backgroundColor='white';";
                DataClassesDataAccessDataContext db = new DataClassesDataAccessDataContext(Extension.GetDBConnectionString());
                var         sDocID      = DataBinder.Eval(e.Row.DataItem, "DocID");
                TRNDocument objDocument = null;
                if (sDocID != DBNull.Value && sDocID != null)
                {
                    objDocument = db.TRNDocuments.Where(x => x.DocID == Convert.ToInt32(sDocID.ToString())).First();
                    #region | DocNo |
                    Label lblDocNo = (Label)e.Row.FindControl("lbl_DocNo");
                    if (lblDocNo != null)
                    {
                        lblDocNo.Text = objDocument.DocNo;
                    }
                    #endregion
                    #region | Title |
                    Label lblTitle = (Label)e.Row.FindControl("lbl_Title");
                    if (lblTitle != null)
                    {
                        lblTitle.Text = objDocument.Title;
                    }
                    #endregion
                    #region | Category |
                    Label lblCategory = (Label)e.Row.FindControl("lbl_Category");
                    if (lblCategory != null)
                    {
                        var       objCategory = objDocument.Category;
                        DataTable dt          = Extension.GetDataTable("MstCategory");
                        if (!dt.DataTableIsNullOrEmpty())
                        {
                            DataView dv = dt.AsDataView();
                            dv.RowFilter = string.Format("Value = '{0}'", objCategory.ToString());
                            dt           = dv.ToTable();
                            if (!dt.DataTableIsNullOrEmpty())
                            {
                                lblCategory.Text = dt.Rows[0]["CategoryName"].ToString();
                            }
                        }
                        else
                        {
                            throw new Exception("MSTCategory has no DataRow");
                        }
                    }
                    #endregion
                    #region | Document Type |

                    Label lblDocType  = (Label)e.Row.FindControl("lbl_DocType");
                    var   objLDocType = DataBinder.Eval(e.Row.DataItem, "DocType");
                    if (lblDocType != null)
                    {
                        if (objLDocType != null && objLDocType != DBNull.Value)
                        {
                            DataTable dtDocumentType = Extension.GetDataTable("MstDocumentType");
                            if (!dtDocumentType.DataTableIsNullOrEmpty())
                            {
                                DataView dv = dtDocumentType.AsDataView();
                                dv.RowFilter = string.Format("Value = '{0}'", objLDocType.ToString());;
                                DataTable oResult = dv.ToTable();

                                if (!oResult.DataTableIsNullOrEmpty())
                                {
                                    lblDocType.Text = oResult.Rows[0]["DocTypeName"].ToString();
                                }
                            }
                        }
                    }
                    #endregion
                    #region | Create Date |
                    Label lblCreateDate = (Label)e.Row.FindControl("lbl_CreateDate");
                    if (lblCreateDate != null)
                    {
                        DateTime createdDate = DateTime.Parse(objDocument.CreatedDate.ToString());
                        lblCreateDate.Text = createdDate.ToString("dd/MM/yyyy");
                    }

                    #endregion
                    #region | Requestor |
                    Label lblRequestor = (Label)e.Row.FindControl("lbl_Requestor");
                    if (lblRequestor != null)
                    {
                        var emp = Extension.GetSpecificEmployeeFromTemp(this.Page, objDocument.RequestorID.ToString());
                        if (emp != null)
                        {
                            string name = string.Format("{0}{1} {2}", emp.PREFIX_TH, emp.FIRSTNAME_TH, emp.LASTNAME_TH);
                            lblRequestor.Text = name;
                        }
                    }
                    #endregion
                    #region | Amount |
                    Label lblAmount = (Label)e.Row.FindControl("lbl_Amount");
                    if (lblAmount != null)
                    {
                        lblAmount.Text = Extension.SetDecimalFormat(objDocument.Amount.ToString());
                    }
                    #endregion
                }
                #region | Delegate TO |
                var lbl_DelegateTo = (Label)e.Row.FindControl("lbl_DelegateTo");
                var objDelegateTo  = DataBinder.Eval(e.Row.DataItem, "DelegateToID");
                if (lbl_DelegateTo != null && objDelegateTo != null && objDelegateTo != DBNull.Value)
                {
                    var delTo = Extension.GetSpecificEmployeeFromTemp(Page, objDelegateTo.ToString());
                    lbl_DelegateTo.Text = string.Format("{0} {1}", delTo.FIRSTNAME_TH, delTo.LASTNAME_TH);
                }
                #endregion

                #region | DateFrom |
                Label lbl_DateFrom = (Label)e.Row.FindControl("lbl_DateFrom");
                var   objDateFrom  = DataBinder.Eval(e.Row.DataItem, "DateFrom");
                if (lbl_DateFrom != null && objDateFrom != DBNull.Value && objDateFrom != null)
                {
                    lbl_DateFrom.Text = DateTime.Parse(objDateFrom.ToString()).ToString("dd/MM/yyyy");
                }
                #endregion

                #region | DateTo |
                Label lbl_DateTo = (Label)e.Row.FindControl("lbl_DateTo");
                var   objDateTo  = DataBinder.Eval(e.Row.DataItem, "DateTo");
                if (lbl_DateTo != null && objDateTo != DBNull.Value && objDateTo != null)
                {
                    lbl_DateTo.Text = DateTime.Parse(objDateTo.ToString()).ToString("dd/MM/yyyy");
                }
                #endregion

                #region | Attachment |

                var objDelegateID = DataBinder.Eval(e.Row.DataItem, "DelegateID");
                List <TRNAttachFileDelegate> listAttach = db.TRNAttachFileDelegates.Where(x => x.DelegateID == Convert.ToInt32(objDelegateID.ToString())).ToList();
                if (listAttach.Count > 0)
                {
                    HyperLink hpl_AttachDoc = (HyperLink)e.Row.FindControl("hpl_AttachDoc");
                    var       objAttachDoc  = listAttach[0].AttachFile;
                    var       objAttachPath = listAttach[0].AttachFilePath;
                    if (hpl_AttachDoc != null)
                    {
                        if (!string.IsNullOrEmpty(objAttachDoc) && !string.IsNullOrEmpty(objAttachPath))
                        {
                            hpl_AttachDoc.Text        = objAttachDoc.ToString();
                            hpl_AttachDoc.NavigateUrl = objAttachPath.ToString();
                        }
                    }
                }
                #endregion

                #region | ModiFied Date |
                Label lbl_ModifiedDate = (Label)e.Row.FindControl("lbl_ModifiedDate");
                var   objModifiedDate  = DataBinder.Eval(e.Row.DataItem, "ModifiedDate");
                if (lbl_ModifiedDate != null && objModifiedDate != DBNull.Value && objModifiedDate != null)
                {
                    lbl_ModifiedDate.Text = DateTime.Parse(objModifiedDate.ToString()).ToString("dd/MM/yyyy");
                }
                #endregion
                #region | ModiFied By |
                Label lbl_ModifiedBy = (Label)e.Row.FindControl("lbl_ModifiedBy");
                var   objModifiedBy  = DataBinder.Eval(e.Row.DataItem, "ModifiedBy");
                if (lbl_ModifiedBy != null && objDateTo != DBNull.Value && objDateTo != null)
                {
                    var empMod = Extension.GetSpecificEmployeeFromTemp(Page, objModifiedBy.ToString());
                    lbl_ModifiedBy.Text = string.Format("{0} {1}", empMod.FIRSTNAME_TH, empMod.LASTNAME_TH);
                }
                #endregion
                #region | Status |
                Label lblStatus = (Label)e.Row.FindControl("lbl_Status");
                var   objStatus = DataBinder.Eval(e.Row.DataItem, "IsActive");
                if (lblStatus != null)
                {
                    if (objStatus != DBNull.Value && objStatus != null)
                    {
                        if (objDateTo != null && objDateFrom != DBNull.Value && objDateFrom != null)
                        {
                            DateTime dateFrom = DateTime.Parse(objDateFrom.ToString());
                            DateTime dateTo   = objDateTo == DBNull.Value ? DateTime.MaxValue : DateTime.Parse(objDateTo.ToString());
                            if (DateTime.Now >= dateFrom && DateTime.Now <= dateTo)
                            {
                                lblStatus.Text = "Active";
                            }
                            else
                            {
                                lblStatus.Text = "Inactive";
                            }
                        }
                    }
                }
                #endregion
            }
        }