Exemple #1
0
 public void DisplayMatchedTransactions(IList <TransactionSearchResult> transactions)
 {
     ViewState.Add("transactions", transactions);
     transactionSearchGridView.DataSource = transactions;
     transactionSearchGridView.DataBind();
 }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.Validate();


            int index = Convert.ToInt32(ViewState["EditedIndex"]);
            int id    = Convert.ToInt32(ViewState["EditedId"]);

            RepeaterItem item = repComments.Items[index];
            MyComment    my   = new MyComment();

            if (id != -1)
            {
                my = rep.GetEntityById(id) as MyComment;
            }

            for (int i = 0; i < item.Controls.Count; i++)
            {
                TextBox t = item.Controls[i] as TextBox;
                if (t != null)
                {
                    string propName = t.ToolTip;

                    switch (propName)
                    {
                    case "VacancyId":
                        if (my.VacancyId != Convert.ToInt32(t.Text))
                        {
                            my.VacancyId = Convert.ToInt32(t.Text);
                        }

                        break;

                    case "Date":
                        DateTime date = new DateTime();
                        DateTime.TryParse(t.Text, out date);
                        if (my.Date != date && date != new DateTime())
                        {
                            my.Date = date;
                        }
                        break;

                    case "Content":
                        if (my.Content != t.Text)
                        {
                            my.Content = t.Text;
                        }
                        break;

                    default:
                        break;
                    }

                    t.Style.Add("display", "none");
                }
                else
                {
                    DropDownList lst = item.Controls[i] as DropDownList;

                    if (lst != null)
                    {
                        int val = DBManager.DbManager.GetUserIdByEmail1(lst.SelectedValue);
                        if (my.UserId != val)
                        {
                            my.UserId = val;
                        }

                        lst.Style.Add("display", "none");
                    }
                }
            }

            rep.Save(my);

            ViewState.Add("EditedId", -1);
            ViewState.Add("EditedIndex", -1);

            btnSave.Style.Add("display", "none");
            btnCancel.Style.Add("display", "none");

            isEditing = false;

            UpdateData();
        }
Exemple #3
0
 protected void btnDisAppr_Click(object sender, EventArgs e)
 {
     ViewState.Add("StatusDisApp", 0);
     UpdateStatusCompany();
     BindGridview();
 }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //Get Settings
            if (Request.RequestType == "POST")
            {
            }
            else
            {
                //The method was a GET, therfore we must be paging.
                _currentPage    = Strings.ToInt(Request.Params["PageNum"], 1);
                _recordsPerPage = Strings.ToInt(Request.Params["RecordsPerPage"], 10);
                _offSet         = Strings.ToInt(Request.Params["OffSet"], 0);
            }

            if (PerformSearch)
            {
                //set up the search collection
                //determine what text needs to be removed from the title e.g. - National Cancer Institute
                SiteWideSearchConfig searchConfig = ModuleObjectFactory <SiteWideSearchConfig> .GetModuleObject(SnippetInfo.Data);

                if (searchConfig != null)
                {
                    SearchCollection = searchConfig.SearchCollection;
                }

                if (Keyword != null)
                {
                    //Store keyword in viewstate (This does not check if it is not there already)
                    if (ViewState[swKeyword] == null)
                    {
                        ViewState.Add(swKeyword, Keyword);
                    }
                    else
                    {
                        ViewState[swKeyword] = Keyword;
                    }

                    try
                    {
                        SiteWideSearchAPIResultCollection results = SiteWideSearchManager.Search(SearchCollection, Keyword, _recordsPerPage,
                                                                                                 (_currentPage - 1) * _recordsPerPage);

                        rptSearchResults.DataSource = results.SearchResults;
                        rptSearchResults.DataBind();

                        if (results.ResultCount == 0)
                        {
                            ResultsText = "No results found";
                            rptSearchResults.Visible = false;
                        }
                        else
                        {
                            int startRecord = 0;
                            int endRecord   = 0;
                            _resultsFound = true;
                            SimplePager.GetFirstItemLastItem(_currentPage, _recordsPerPage, (int)results.ResultCount, out startRecord, out endRecord);

                            //phNoResultsLabel.Visible = false;
                            rptSearchResults.Visible = true;
                            string resultsCount = String.Format("{0}-{1} of {2}", startRecord.ToString(), endRecord.ToString(), results.ResultCount.ToString());
                            ResultsText = "Results " + resultsCount;
                        }

                        spPager.RecordCount    = (int)results.ResultCount;
                        spPager.RecordsPerPage = _recordsPerPage;
                        spPager.CurrentPage    = _currentPage;
                        spPager.BaseUrl        = PrettyUrl + "?swKeywordQuery=" + Keyword;
                    }
                    catch (Exception ex)
                    {
                        //capture exactly which keyword caused the error
                        log.Error("Search with the following keyword returned an error: " + Keyword, ex);
                    }
                }
                else
                {
                    ResultsText = "No results found";
                    rptSearchResults.Visible = false;
                }
            }
            else
            {
                ResultsText = String.Empty;
            }
        }
Exemple #5
0
        protected void grdRequestList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int reqId = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "checkReq")
            {
                hdnfReqId.Value = reqId.ToString();

                //List<ResourceControl.Entity.Resource> resList = new List<ResourceControl.Entity.Resource>();
                ResourceHandler rsh = new ResourceHandler();

                RequestHandler requestHandler = new RequestHandler();
                var            requestDetails = requestHandler.GetRequestDetails(reqId);

                _resList = requestDetails.Status > 1 ? rsh.GetResourceListByStudentReqIDForAfterAccept(reqId) : rsh.ResourceSelectByReqStudentID(reqId);

                var resourceState = requestHandler.GetResourceStateForDefence(reqId);


                ViewState.Add("reqId", reqId);
                ViewState.Add("_resList", _resList);
                ViewState.Add("ResourceState", resourceState);

                grdResourceState.DataSource = resourceState;
                grdResourceState.DataBind();

                if (drpRequestTypeList.SelectedIndex == 0)
                {
                    drpCandidateResource.DataSource     = _resList;
                    drpCandidateResource.DataTextField  = "name";
                    drpCandidateResource.DataValueField = "ID";
                    drpCandidateResource.DataBind();
                    drpCandidateResource.Items.Insert(0, new ListItem {
                        Value = "0", Text = "انتخاب کنید..."
                    });

                    dvOperation.Visible = true;
                    //   dvOperation1.Visible = true;
                    dvSuggestResource.Visible = true;
                }
                else
                {
                    dvOperation.Visible = false;
                    //   dvOperation1.Visible = false;
                    dvSuggestResource.Visible = false;
                }

                if (drpRequestTypeList.SelectedIndex == 5)
                {
                    dvOperation.Visible = false;
                    //   dvOperation1.Visible = false;
                }

                grdDateTime.EditIndex = -1;
                RequestDateTimeHandler rqdateTimeH = new RequestDateTimeHandler();
                _dateTimeList          = rqdateTimeH.GetDateTimeListByRequestId(reqId);
                grdDateTime.DataSource = _dateTimeList.OrderBy(c => c.Date);
                grdDateTime.DataBind();



                lblRequestNumber.Text = requestDetails.ID.ToString();
                lblIssuerName.Text    = requestDetails.IssuerName.ToString();
                //    lblResh.Text = requestDetails.Nameresh.ToString();
                lblDanesh.Text = requestDetails.Namedanesh.ToString();



                string scrp = "function f(){$find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(this.Page, GetType(), ClientID, scrp, true);
            }

            if (e.CommandName == "deny")
            {
                hdnfDenyReqId.Value = reqId.ToString();

                string scrp = "function f(){$find(\"" + RadWindow2.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(this.Page, GetType(), ClientID, scrp, true);
            }

            if (e.CommandName == "edit")
            {
                Response.Redirect("UserEditRequest.aspx?id=" + generaterandomstr() + "@A" + "0" + "-" + generaterandomstr() + "&reqId=" + e.CommandArgument);
            }

            if (e.CommandName == "History")
            {
                CommonBusiness cmb   = new CommonBusiness();
                var            dtLog = cmb.GetUserAndStudentLogModifyId(int.Parse(e.CommandArgument.ToString()), 11);
                var            myLog = RequestHandler.ConvertDataTableToList <logDetail>(dtLog).OrderBy(O => O.LogDate.ToGregorian()).ThenBy(x => x.LogTime.TimeToTicks());
                lst_history.DataSource = myLog;
                lst_history.DataBind();

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
            }
            if (e.CommandName == "showInfo")
            {
                #region ShowInfo

                hdnfReqId.Value = reqId.ToString();
                RequestHandler rh         = new RequestHandler();
                GridViewRow    curruntRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
                imgStatus2.ImageUrl = ((Image)curruntRow.Cells[2].FindControl("imgStatus")).ImageUrl;
                var requestDetails = rh.GetRequestDetails(reqId);
                lblRequestId.Text     = requestDetails.ID.ToString();
                lblDarkhast.Text      = requestDetails.CourseName;
                lbldateOfRequest.Text = requestDetails.Issue_time;
                RequestDateTimeHandler rqdateTimeH = new RequestDateTimeHandler();
                _dateTimeList = rqdateTimeH.GetDateTimeListByRequestId(reqId);
                var dateTime = _dateTimeList.OrderBy(c => c.Date).FirstOrDefault(c => c.Date != null);
                if (dateTime != null)
                {
                    lblRequest.Text = dateTime.Date;
                }
                //var requestDateTime = requestDetails.DateTimeRange.FirstOrDefault(c => c.Date != null);
                //if (requestDateTime != null)
                //{
                //    var firstOrDefault = requestDetails.DateTimeRange.FirstOrDefault(c => c.StartTime != 0).Date;
                //    if (firstOrDefault != null)
                //        lblRequest.Text = firstOrDefault;
                //}



                var startTime = _dateTimeList.FirstOrDefault(c => c.StartTime != 0);
                if (startTime != null)
                {
                    lblTime1.Text = TimeSpan.FromTicks((long)startTime.StartTime).ToString().Substring(0, 5);
                }

                var endTime = _dateTimeList.FirstOrDefault(c => c.EndTime != 0);
                if (endTime != null)
                {
                    lblTime2.Text = TimeSpan.FromTicks((long)endTime.EndTime).ToString().Substring(0, 5);
                }

                switch (requestDetails.Status)
                {
                case 0:
                    lblStatue.Text = "درخواست استاد ثبت گردیده و در انتظار ارجاع هست";
                    break;

                case 1:
                    lblStatue.Text = "درخواست ارجاع داده شده است";
                    break;

                case 2:
                    lblStatue.Text = "درخواست شما مورد تایید واقع گردیده";
                    break;

                case 3:
                    lblStatue.Text = "درخواست شما مورد تایید واقع نگردیده";
                    break;

                case 4:
                    lblStatue.Text = "درخواست شما اطلاع رسانی گردیده است";
                    break;

                case 5:
                    lblStatue.Text = "درخواست شما از دست رفته است";
                    break;
                }
                //lblTozieh.Text = requestDetails.Note;
                //blCapecity.Text = requestDetails.Capacity.ToString();
                //lblLocation.Text = requestDetails.Location;
                //if (!string.IsNullOrEmpty(requestDetails.Answer_time))
                //{
                //    if (requestDetails.Status == 2)
                //    {
                //        lblheader.Text = "زمان پاسخ به درخواست:";

                //    }
                //    else
                //    {
                //        lblheader.Text = "زمان رد درخواست:";
                //        litDenyNot.Text = "علت رد درخواست:";
                //    }
                //    lblheader.Visible = true;
                //    lblDateOfResponse.Visible = true;
                //    lblDateOfResponse.Text = requestDetails.Answer_time;
                //    if (requestDetails.Status != 2)
                //    {
                //        litDenyNot.Visible = true;
                //        lblDenyNot.Visible = true;
                //        lblDenyNot.Text = requestDetails.Answernote;
                //    }
                //}
                //else
                //{
                //    lblheader.Visible = false;
                //    lblDateOfResponse.Visible = false;
                //    litDenyNot.Visible = false;
                //    lblDenyNot.Visible = false;
                //}
                var studentDefenceRequestList = rh.GetStudentDefenceRequest(requestDetails.IssuerID);

                var listOfDefenceRequest =
                    RequestHandler.ConvertDataTableToList <StudentDefenceRequestDTO>(studentDefenceRequestList);

                var inCirculationRequest =
                    listOfDefenceRequest.FirstOrDefault(
                        x => x.isDeleted != true && x.RequestDate.StringPersianDateToGerogorianDate() >= DateTime.Now);

                if (inCirculationRequest == null)
                {
                    inCirculationRequest = listOfDefenceRequest.OrderByDescending(x => x.ID).FirstOrDefault();
                }



                if (inCirculationRequest.IsUseOwnSystem)
                {
                    lblOwnSysytem.Text = "بله";
                }
                else
                {
                    lblOwnSysytem.Text = "خیر";
                }

                if (inCirculationRequest.IsEquippingResource)
                {
                    lblOnlineShow.Text = "بله";
                }
                else
                {
                    lblOnlineShow.Text = "خیر";
                }

                if (!string.IsNullOrEmpty(inCirculationRequest.OnlineTeacherRole.Trim()))
                {
                    lblOnlineDef.Text = "بله";
                }
                else
                {
                    lblOnlineDef.Text = "خیر";
                }
                if (inCirculationRequest.FlagDoingMeetingOnline)
                {
                    lblOnlineDoingMeeting.Text = "بله";
                }
                else
                {
                    lblOnlineDoingMeeting.Text = "خیر";
                }
                //var requestDateTimes = _dateTimeList.OrderBy(d => d.Date);
                //if (requestDateTimes.Count() > 1)
                //    tblRangeOfDate.Visible = true;
                //else
                //    tblRangeOfDate.Visible = false;
                //if (requestDateTimes.Any())
                //{
                //    tblRangeOfDate.Visible = true;
                //    grdOldDateTime.DataSource = requestDateTimes;
                //    grdOldDateTime.DataBind();
                //}
                //var cth = new CategoryHandler();
                //var categoryName = cth.GetCategoryList().FirstOrDefault(c => c.ID == requestDetails.CatID).Name;
                //lblPosition.Text = categoryName;
                //var opt = new OptionHandler();
                // var optlist = opt.GetOptionListByCatID(requestDetails.CatID);
                //var rsopt = new Req_Opt_JuncHandler();
                // var resOptJunlist = rsopt.GetReq_Opt_JuncListByReqID(requestDetails.ID);
                //var requestOption = new List<Option>();
                //foreach (Req_Opt_Junc optJunc in resOptJunlist)
                //{
                //    foreach (var option in optlist)
                //    {
                //        if (optJunc.Opt_id == option.ID)
                //            requestOption.Add(new Option { Name = option.Name });
                //    }
                //}
                ////grdFacilities.DataSource = requestOption;
                //grdFacilities.DataBind();
                string scrp = "function f(){$find(\"" + RadWindow3.ClientID +
                              "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(this.Page, GetType(), ClientID, scrp, true);


                #endregion
            }
        }
Exemple #6
0
        public void GetPurchaseRequestList()
        {
            DateTime ApprovedDate = DateTime.Parse("1/1/1800");

            if (txtSApproveDate.Text != "")
            {
                ApprovedDate = DateTime.Parse(txtSApproveDate.Text);
            }

            DateTime ApprovedDate2 = DateTime.Parse("1/1/9999");

            if (txtSApproveDate2.Text != "")
            {
                ApprovedDate2 = DateTime.Parse(txtSApproveDate2.Text);
            }

            DateTime RequestedDate = DateTime.Parse("1/1/1800");

            if (txtSRequestDate.Text != "")
            {
                RequestedDate = DateTime.Parse(txtSRequestDate.Text);
            }

            DateTime RequestedDate2 = DateTime.Parse("1/1/9999");

            if (txtSRequestDate2.Text != "")
            {
                RequestedDate2 = DateTime.Parse(txtSRequestDate2.Text);
            }


            Guid WorkUnit = new Guid("00000000-0000-0000-0000-000000000000");

            if (ddlSWorkUnit.SelectedValue != "")
            {
                WorkUnit = new Guid(ddlSWorkUnit.SelectedValue);
            }

            Guid ItemID = new Guid("00000000-0000-0000-0000-000000000000");

            if (ddlSItem.SelectedValue != "")
            {
                ItemID = new Guid(ddlSItem.SelectedValue);
            }

            Guid RequestType = new Guid("00000000-0000-0000-0000-000000000000");

            if (ddlSRequestType.SelectedValue != "")
            {
                RequestType = new Guid(ddlSRequestType.SelectedValue);
            }


            try
            {
                DataTable dt = pRequest.GePurchaseRequestList(WorkUnit, ItemID, RequestType, RequestedDate, RequestedDate2, ApprovedDate, ApprovedDate2);
                ViewState.Add("dtbl", dt);
                grvPurchaseRequest.DataSource = dt;
                grvPurchaseRequest.DataBind();
            }
            catch (Exception ex)
            {
                Messages1.SetMessage(ex.Message, Messages.MessageType.Error);
            }
        }
Exemple #7
0
 protected void tabElem_OnTabChanged(object sender, EventArgs e)
 {
     ViewState.Add("SelectedControl", tabElem.SelectedTab);
     DisplayControl(SelectedControl, true);
 }
Exemple #8
0
    public void SubmitAnswer(object sender, EventArgs e)
    {
        //check answer
        if (((AnswerA.Checked == true) && PossibleAnswer1.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerB.Checked == true) && PossibleAnswer2.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerC.Checked == true) && PossibleAnswer3.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerD.Checked == true) && PossibleAnswer4.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))))     //check for correct answer
        {
            correctAnswers++;
            ViewState.Add("correctAnswers", correctAnswers);
            string message = "Correct Answer";
            string script  = "window.onload = function(){ alert('" + message + "')};";
            ClientScript.RegisterStartupScript(this.GetType(), "Correct", script, true);
        }
        else
        {
            string message = "Wrong Answer";
            string script  = "window.onload = function(){ alert('" + message + "')};";
            ClientScript.RegisterStartupScript(this.GetType(), "Wrong", script, true);
        }

        if (UsedQuestionList.Count == 10)                                                                                       // Question limit for end of test
        {
            int testElapsedTime = ((Int32)DateTime.Now.Subtract(DateTime.Parse(Session["StartTime"].ToString())).TotalSeconds); //test time
            Timer1.Enabled = false;

            //start of evaluation
            //get pastknowledge
            UserPreferences userPreferences = new UserPreferences();
            string          pastKnowledge   = userPreferences.getUsersPastKnowledge(User.Identity.Name);
            //get VAK type
            string usersVakType = userPreferences.getUsersVakType(User.Identity.Name);
            //get theory time
            TimesManager timesManager = new TimesManager();
            Int64        theoryTime   = timesManager.getTheoryTime(User.Identity.Name); //mporei na epistrepsei arnhtikh timh
            timesManager.registerTestTime(User.Identity.Name, (Int64)testElapsedTime);  //also record the test time

            registerScore(User.Identity.Name, correctAnswers);                          // katagrafh swstwn apanthsewn sth bash



            int boredomPoints = 0;

            boredomPoints = boredomPoints + correctAnswers; //Each correct answer contributes 1 point

            if (pastKnowledge == "Low")                     // Low=3 , Medium=2 , High=1
            {
                boredomPoints = boredomPoints + 3;
            }
            else if (pastKnowledge == "Medium")
            {
                boredomPoints = boredomPoints + 2;
            }
            else if (pastKnowledge == "High")
            {
                boredomPoints = boredomPoints + 1;
            }

            if (testElapsedTime < 120) // Low=3 , Medium=2 , High=1    Time is in seconds
            {
                boredomPoints = boredomPoints + 3;
            }
            else if (testElapsedTime < 180)
            {
                boredomPoints = boredomPoints + 2;
            }
            else if (testElapsedTime >= 180)
            {
                boredomPoints = boredomPoints + 1;
            }

            //Check theory time. Theory time evaluation is not the same for each category
            if (usersVakType == "Visual")
            {
                if (theoryTime < 2400) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 4000)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 4000)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }
            else if (usersVakType == "Auditory")
            {
                if (theoryTime < 2000) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 3600)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 3600)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }
            else if (usersVakType == "Kinesthetic")
            {
                if (theoryTime < 1200) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 2000)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 2000)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }

            Boolean boredom;
            if (boredomPoints <= 10) // Less than 10 points means user could be bored.
            {
                boredom = true;
            }
            else
            {
                boredom = false;
            }

            if (boredom == true) //elegxos gia boredom
            {
                string message = "END of test. It took you " + testElapsedTime.ToString() + " seconds. But it looks like you might be bored! Play this Tic-Tac-Toe game for a bit and then come back.";
                string script  = "window.onload = function(){ alert('" + message + "');location.href='Triliza.aspx'};";
                ClientScript.RegisterStartupScript(this.GetType(), "End of Test", script, true);
                //Response.Redirect("~/Triliza.aspx");
            }
            else
            {
                string message = "END of test. It took you " + testElapsedTime.ToString() + " seconds";
                string script  = "window.onload = function(){ alert('" + message + "')};";
                ClientScript.RegisterStartupScript(this.GetType(), "End of Test", script, true);
            }
        }
        else
        {
            setNextQuestion();
        }
    }
Exemple #9
0
        public override void DataBind()
        {
            isDatabinded = true;
            EnsureChildControls();
            base.DataBind();


            if (usePagedDataSource)
            {
                repSource.DataSource = this.DataSource.DefaultView;
            }

            ApplySort();

            if (allowPaging)
            {
                if (usePagedDataSource)
                {
                    repSource.PageSize    = this.PageSize;
                    repSource.AllowPaging = true;
                    int newPage = CurrentPage - 1;

                    if (newPage >= repSource.PageCount)
                    {
                        newPage     = repSource.PageCount - 1;
                        CurrentPage = newPage + 1;
                    }

                    if (newPage < 0)
                    {
                        newPage     = 0;
                        CurrentPage = newPage + 1;
                    }

                    repSource.CurrentPageIndex = newPage;
                }
                else
                {
                }
                ViewState.Add(this.ClientID + "_ViewPage", CurrentPage);
            }
            if (usePagedDataSource)
            {
                innerRepeater.DataSource = repSource;
            }
            else
            {
                innerRepeater.DataSource = DataSource.DefaultView;
            }
            innerRepeater.DataBind();

            if ((usePagedDataSource && repSource.Count == 0) || (!usePagedDataSource && DataSource.DefaultView.Count == 0))
            {
                lc.Visible            = true;
                innerRepeater.Visible = false;
            }
            else
            {
                lc.Visible            = false;
                innerRepeater.Visible = true;
            }

            if (rb != null)
            {
                rb.SetPageNums();
            }
        }
        /// <summary>
        /// Ensures configuration is valid to proceed
        /// </summary>
        /// <returns></returns>
        public virtual ConfigStatus ValidatePrerequisite()
        {
            if (!this.IsPostBack)
            {
                // DataBind() must be called to bind attributes that are set as "<%# #>"in .aspx
                // But only during initial page load, otherwise it would reset bindings in other controls like SPGridView
                DataBind();
                ViewState.Add("ClaimsProviderName", ClaimsProviderName);
                ViewState.Add("PersistedObjectName", PersistedObjectName);
                ViewState.Add("PersistedObjectID", PersistedObjectID);
            }
            else
            {
                ClaimsProviderName  = ViewState["ClaimsProviderName"].ToString();
                PersistedObjectName = ViewState["PersistedObjectName"].ToString();
                PersistedObjectID   = ViewState["PersistedObjectID"].ToString();
            }

            Status = ConfigStatus.AllGood;
            if (String.IsNullOrEmpty(ClaimsProviderName))
            {
                Status |= ConfigStatus.ClaimsProviderNamePropNotSet;
            }
            if (String.IsNullOrEmpty(PersistedObjectName))
            {
                Status |= ConfigStatus.PersistedObjectNamePropNotSet;
            }
            if (String.IsNullOrEmpty(PersistedObjectID))
            {
                Status |= ConfigStatus.PersistedObjectIDPropNotSet;
            }
            if (Status != ConfigStatus.AllGood)
            {
                ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
                // Should not go further if those requirements are not met
                return(Status);
            }

            if (CurrentTrustedLoginProvider == null)
            {
                CurrentTrustedLoginProvider = LDAPCP.GetSPTrustAssociatedWithCP(this.ClaimsProviderName);
                if (CurrentTrustedLoginProvider == null)
                {
                    Status |= ConfigStatus.NoSPTrustAssociation;
                    return(Status);
                }
            }

            if (PersistedObject == null)
            {
                Status |= ConfigStatus.PersistedObjectNotFound;
            }

            if (Status != ConfigStatus.AllGood)
            {
                ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
                // Should not go further if those requirements are not met
                return(Status);
            }

            PersistedObject.CheckAndCleanConfiguration(CurrentTrustedLoginProvider.Name);
            PersistedObject.ClaimTypes.SPTrust = CurrentTrustedLoginProvider;
            if (IdentityCTConfig == null && Status == ConfigStatus.AllGood)
            {
                IdentityCTConfig = this.IdentityCTConfig = PersistedObject.ClaimTypes.FirstOrDefault(x => String.Equals(CurrentTrustedLoginProvider.IdentityClaimTypeInformation.MappedClaimType, x.ClaimType, StringComparison.InvariantCultureIgnoreCase) && !x.UseMainClaimTypeOfDirectoryObject);
                if (IdentityCTConfig == null)
                {
                    Status |= ConfigStatus.NoIdentityClaimType;
                }
            }
            if (PersistedObjectVersion != PersistedObject.Version)
            {
                Status |= ConfigStatus.PersistedObjectStale;
            }

            if (Status != ConfigStatus.AllGood)
            {
                ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
            }
            return(Status);
        }
        protected void btnOk_Click(object sender, EventArgs e)
        {
            //this is a little difficult :|
            //get value of botton that user clicks on it
            string confirmValues = Request.Form["confirm_value"];

            //Do nothing wen user click on cancel btn in alert message
            if (confirmValues == "Yes")
            {
                //is edit means that we are in edit view
                //to change value we must in save view
                //save view means we want to change value, save a new records or edit them
                isEdit = (bool)ViewState["isEdit"];

                if (isEdit)                          //if we are in edit view and the user click on edit botton and want to edit records
                {
                    isEdit = false;                  //because when page is loading we are not in edit view again and goto save view
                    ViewState.Add("isEdit", isEdit); //to save value after loading

                    //to edit text boxes
                    txtMashmulTarikh.ReadOnly = false;
                    txtMashmulNumber.ReadOnly = false;

                    //Change botton name
                    btnOk.Text = "ثبت";
                }
                else//if we are not in edit view do...
                {
                    //msd= (MilitaryStatusDTO)ViewState["msd"];
                    alreadyExist = (bool)ViewState["alreadyExist"];

                    try
                    {
                        if (alreadyExist)//if data is already exist in data base we should edit them
                        {
                            msd.stCode        = (string)ViewState["stCode"];
                            msd.family        = (string)ViewState["family"];
                            msd.mashmulNumber = txtMashmulNumber.Text;
                            msd.mashmulTarikh = txtMashmulTarikh.Text;
                            msd.mashmulStatus = drpStatus.SelectedItem.Value.ToString();

                            MSB.updateMashmulNumber(msd);
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت اطلاعات با موفقيت انجام شد.')", true);
                            txtMashmulTarikh.ReadOnly = true;
                            btnOk.Text = "ويرايش";
                            ViewState.Add("isEdit", true);
                        }
                        else//else we should to save new values in data base
                        {
                            string confirmValue = Request.Form["confirm_value"];//we can delete this line :|
                            if (confirmValue == "Yes")
                            {
                                msd.stCode        = (string)ViewState["stCode"];
                                msd.family        = (string)ViewState["family"];
                                msd.mashmulNumber = txtMashmulNumber.Text;
                                msd.mashmulTarikh = txtMashmulTarikh.Text;
                                msd.mashmulStatus = drpStatus.SelectedItem.Value.ToString();

                                MSB.insertMashmulNumber(msd);
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت اطلاعات با موفقيت انجام شد.')", true);

                                txtMashmulNumber.Text = dt.Rows[index]["شماره مشمولی"].ToString();
                                txtMashmulTarikh.Text = dt.Rows[index]["تاریخ مشمولی"].ToString();
                                alreadyExist          = isAlreadyExist();
                                ViewState.Add("alreadyExist", alreadyExist);
                                showEditField();
                            }
                        }
                    }
                    catch (Exception)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت اطلاعات با خطا مواجه شده است.')", true);
                    }
                    BindGrid();
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool hasAccess = SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement);

            if (!hasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["RoleID"]);

            if (!Page.IsPostBack)
            {
                // get the role and show the description
                RoleEntity role = SecurityGuiHelper.GetRole(_roleID);
                if (!role.IsNew)
                {
                    _roleDescription = role.RoleDescription;
                }

                // store in viewstate.
                ViewState.Add("sRoleDescription", _roleDescription);

                // Get all sections, which do have a forum.
                DataView sections = SectionGuiHelper.GetAllSectionsWStatisticsAsDataView(true);

                cbxSections.DataSource     = sections;
                cbxSections.DataTextField  = "SectionName";
                cbxSections.DataValueField = "SectionID";
                cbxSections.DataBind();

                if (cbxSections.Items.Count > 0)
                {
                    cbxSections.Items[0].Selected = true;
                }

                FillForumList();

                // get the forum action rights
                ActionRightCollection actionRights = SecurityGuiHelper.GetAllActionRightsApplybleToAForum();

                cblForumRights.DataSource     = actionRights;
                cblForumRights.DataTextField  = "ActionRightDescription";
                cblForumRights.DataValueField = "ActionRightID";
                cblForumRights.DataBind();

                // Reflect action rights for current selected forum for this role
                ReflectCurrentActionRights();
            }
            else
            {
                // read role description from viewstate
                _roleDescription = ViewState["sRoleDescription"].ToString();
                _forumID         = HnDGeneralUtils.TryConvertToInt(cbxForums.SelectedItem.Value);
            }
        }
Exemple #13
0
        private void BindGrid(int status, bool isneeddatasource)
        {
            DataTable reqList = null;

            if (status == 12 || status == 20)
            {
                int roleId   = Convert.ToInt32(Session["roleId"]);
                int daneshId = business.GetDaneshKadeIdByRoleId(roleId);
                if (daneshId == 0)
                {
                    reqList = business.GetListOFRequestByCurrentStatus(status);
                }
                else
                {
                    reqList = business.GetListOFRequestByCurrentStatusDaneshId(status, daneshId);
                }
            }
            else
            {
                reqList = business.GetListOFRequestByCurrentStatus(status);
            }
            ViewState.Add("status", status);
            grd_CheckOutList.DataSource = reqList;

            if (!isneeddatasource)
            {
                grd_CheckOutList.DataBind();
            }
            GridFilterMenu menu = grd_CheckOutList.FilterMenu;

            if (menu.Items.Count > 3)
            {
                int im = 0;
                while (im < menu.Items.Count)
                {
                    if (menu.Items[im].Text == "NoFilter" || menu.Items[im].Text == "Contains" || menu.Items[im].Text == "EqualTo")
                    {
                        im++;
                    }
                    else
                    {
                        menu.Items.RemoveAt(im);
                    }
                }
                foreach (RadMenuItem item in menu.Items)
                {    //change the text for the "StartsWith" menu item
                    if (item.Text == "NoFilter")
                    {
                        item.Text = "حذف فیلتر";
                        //item.Remove();
                    }
                    if (item.Text == "Contains")
                    {
                        item.Text = "شامل";
                        //item.Remove();
                    }
                    if (item.Text == "EqualTo")
                    {
                        item.Text = "مساوی با";
                        //item.Remove();
                    }
                }
            }
        }
Exemple #14
0
 public void DisplayMatchedCreditNotesTransactions(IList <CreditNoteSearchResult> creditNoteSearchResults)
 {
     ViewState.Add("creditNotesTransactions", creditNoteSearchResults);
     creditSearchGridView.DataSource = creditNoteSearchResults;
     creditSearchGridView.DataBind();
 }
    protected void SectionSelection_SelectedIndexChanged(object sender, EventArgs e)
    {
        ViewState.Add("Section", SectionSelection.SelectedIndex);

        System.Diagnostics.Debug.WriteLine(ViewState["Section"]);
    }
Exemple #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            lb_xxxUseCase_BC_Level1xxx.BorderStyle = BorderStyle.None;
            lb_xxxUseCase_BC_Level2xxx.BorderStyle = BorderStyle.None;
            lb_xxxUseCase_BC_Level3xxx.BorderStyle = BorderStyle.None;


            //'if (GeneralClass.UserName() == "dh" || GeneralClass.UserName() == "mubin"){
            //'    hlEdit.Visible = true;
            //'}

            LoadUseCase_BC_Level1();

            ViewState.Add("Language", CultureInfo.CurrentUICulture.Name);
            //ViewState.Add("PageTitle", Page.Title);

            if (Request.QueryString["Level3_ID"] != null)
            {
                ViewState.Add("Level3_ID", Request.QueryString["Level3_ID"]);
                SetSelectValueLevel3(ViewState["Level3_ID"].ToString());
                LoadOnlyLevel3(ViewState["Level3_ID"].ToString());
                Timer1.Enabled = false;
                //lb_xxxUseCase_BC_Level2xxx.Visible = true;
                //lb_xxxUseCase_BC_Level3xxx.Visible = true;
                lb_xxxUseCase_BC_Level2xxx.BorderStyle = BorderStyle.NotSet;
                lb_xxxUseCase_BC_Level3xxx.BorderStyle = BorderStyle.NotSet;
            }
            else
            {
                //phStart.Visible = true;
                //SetStartText();
                Timer1.Enabled = false;

                //Set selected level 1  13=Financial
                lb_xxxUseCase_BC_Level2xxx.Items.Clear();
                lb_xxxUseCase_BC_Level3xxx.Items.Clear();
                LoadUseCase_BC_Level2("13");
                ResetLogoGrid();
                LoadOnlyLevel2("13");
                //lb_xxxUseCase_BC_Level2xxx.Visible = true;
                lb_xxxUseCase_BC_Level2xxx.BorderStyle   = BorderStyle.NotSet;
                lb_xxxUseCase_BC_Level3xxx.BorderStyle   = BorderStyle.NotSet;
                lb_xxxUseCase_BC_Level1xxx.SelectedValue = "13";
            }
        }
        else
        {
            if (CultureInfo.CurrentUICulture.Name != ViewState["Language"].ToString())
            {
                SetSelectedValue(lb_xxxUseCase_BC_Level1xxx.SelectedValue, lb_xxxUseCase_BC_Level2xxx.SelectedValue,
                                 lb_xxxUseCase_BC_Level3xxx.SelectedValue, lb_xxxUseCase_BC_Level1xxx.SelectedIndex,
                                 lb_xxxUseCase_BC_Level2xxx.SelectedIndex, lb_xxxUseCase_BC_Level3xxx.SelectedIndex);
                SetStartText();
                ViewState["Language"] = CultureInfo.CurrentUICulture.Name;
            }

            //Page.Title = ViewState["PageTitle"].ToString();
        }
    }
        private void Page_Load(object sender, System.EventArgs e)
        {
            string Language = "en-US";

            if (Request.UserLanguages.Length != 0)
            {
                Language = Request.UserLanguages[0];
            }

            CurrentUserCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Language);

            if (ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"] != null)
            {
                ConnectionString = ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"];
            }
            else if (Application["ConnectionString"] != null)
            {
                ConnectionString = Application["ConnectionString"].ToString().Trim();
            }

            if (!Page.IsPostBack)
            {
                // Any sort preferences?
                CurrentSortEnum sortColumn = CurrentSortEnum.SortBy_Sup_StrName;
                if (Request.Params["SortBy"] != String.Empty)
                {
                    try {
                        sortColumn = (CurrentSortEnum)Enum.Parse(typeof(CurrentSortEnum), "SortBy_" + Request.Params["SortBy"]);
                    }

                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }

                SortOrderEnum sortOrder = SortOrderEnum.Ascending;
                if (Request.Params["SortOrder"] != String.Empty)
                {
                    try {
                        sortOrder = (SortOrderEnum)Enum.Parse(typeof(SortOrderEnum), Request.Params["SortOrder"]);
                    }

                    catch {
                        // Ignore the parameter and do nothing here
                    }
                }

                if (ViewState["WebFormList_tblSupplier_CurrentSort"] == null)
                {
                    ViewState.Add("WebFormList_tblSupplier_CurrentSort", sortColumn);
                }
                else
                {
                    ViewState["WebFormList_tblSupplier_CurrentSort"] = sortColumn;
                }

                if (ViewState["sortOrder"] == null)
                {
                    ViewState.Add("sortOrder", sortOrder);
                }
                else
                {
                    ViewState["sortOrder"] = sortOrder;
                }
            }

            repeater_tblSupplier_SelectDisplay.EnableViewState = true;

            RefreshList();
        }
    private void BindGrid(string orderBy)
    {
        //TableSchema.Table schema = DataService.GetTableSchema(tableName, providerName);
        if (Schema != null && Schema.PrimaryKey != null)
        {
            SetTableName(Schema);
            Query query = new Query(Schema);

            string sortColumn = null;
            if (!String.IsNullOrEmpty(orderBy))
            {
                sortColumn = orderBy;
            }
            else if (ViewState[ORDER_BY] != null)
            {
                sortColumn = (string)ViewState[ORDER_BY];
            }

            int colIndex = -1;

            if (!String.IsNullOrEmpty(sortColumn))
            {
                ViewState.Add(ORDER_BY, sortColumn);
                TableSchema.TableColumn col = Schema.GetColumn(sortColumn);
                if (col == null)
                {
                    for (int i = 0; i < Schema.Columns.Count; i++)
                    {
                        TableSchema.TableColumn fkCol = Schema.Columns[i];
                        if (fkCol.IsForeignKey && !String.IsNullOrEmpty(fkCol.ForeignKeyTableName))
                        {
                            TableSchema.Table fkTbl = DataService.GetSchema(fkCol.ForeignKeyTableName, ProviderName, TableType.Table);
                            if (fkTbl != null)
                            {
                                col      = fkTbl.Columns[1];
                                colIndex = i;
                                break;
                            }
                        }
                    }
                }
                if (col != null && col.MaxLength < 2048)
                {
                    if (ViewState[SORT_DIRECTION] == null || ((string)ViewState[SORT_DIRECTION]) == SqlFragment.ASC)
                    {
                        if (colIndex > -1)
                        {
                            query.OrderBy = OrderBy.Asc(col, SqlFragment.JOIN_PREFIX + colIndex);
                        }
                        else
                        {
                            query.OrderBy = OrderBy.Asc(col);
                        }
                        ViewState[SORT_DIRECTION] = SqlFragment.ASC;
                    }
                    else
                    {
                        if (colIndex > -1)
                        {
                            query.OrderBy = OrderBy.Desc(col, SqlFragment.JOIN_PREFIX + colIndex);
                        }
                        else
                        {
                            query.OrderBy = OrderBy.Desc(col);
                        }
                        ViewState[SORT_DIRECTION] = SqlFragment.DESC;
                    }
                }
            }


            DataTable dt = query.ExecuteJoinedDataSet().Tables[0];
            grid.DataSource          = dt;
            grid.AutoGenerateColumns = false;
            grid.Columns.Clear();

            HyperLinkField link = new HyperLinkField();
            link.Text = "Edit";
            link.DataNavigateUrlFields       = new string[] { Schema.PrimaryKey.ColumnName };
            link.DataNavigateUrlFormatString = HttpContext.Current.Request.CurrentExecutionFilePath + "?id={0}";
            grid.Columns.Insert(0, link);

            for (int i = 0; i < Schema.Columns.Count; i++)
            {
                BoundField field = new BoundField();
                field.DataField      = dt.Columns[i].ColumnName;
                field.SortExpression = dt.Columns[i].ColumnName;
                //field.SortExpression = Utility.QualifyColumnName(Schema.Name, dt.Columns[i].ColumnName, Schema.ProviderType);
                field.HtmlEncode = false;
                if (Schema.Columns[i].IsForeignKey)
                {
                    TableSchema.Table schema;
                    if (Schema.Columns[i].ForeignKeyTableName == null)
                    {
                        schema = DataService.GetForeignKeyTable(Schema.Columns[i], Schema);
                    }
                    else
                    {
                        schema = DataService.GetSchema(Schema.Columns[i].ForeignKeyTableName, ProviderName, TableType.Table);
                    }
                    if (schema != null)
                    {
                        field.HeaderText = schema.DisplayName;
                    }
                }
                else
                {
                    field.HeaderText = Schema.Columns[i].DisplayName;
                }

                field.HeaderText = CleanColumnName(field.HeaderText);

                if (!Utility.IsAuditField(dt.Columns[i].ColumnName))
                {
                    grid.Columns.Add(field);
                }
            }

            grid.DataBind();
        }
    }
Exemple #19
0
 protected void btnDelete_Click(object sender, ImageClickEventArgs e)
 {
     ViewState.Add("isEdit", null);
 }
 public void Clear()
 {
     ViewState.Add("CreditLimitExceededReport", null);
     ReportGridView.DataSource = null;
     ReportGridView.DataBind();
 }
Exemple #21
0
 protected void lnkBackHidden_Click(object sender, EventArgs e)
 {
     ViewState.Add("SelectedControl", null);
     DisplayControl(SelectedControlEnum.Listing, true);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user_server"] != null)
            {
                HttpCookie local = Request.Cookies["user_server"];


                Users_DAL user = new Users_DAL();

                foreach (var item in user.select_All())
                {
                    if (item.Email == local.Values["user_email"])
                    {
                        Label13.Text = "Hi" + " " + item.First_Name;
                    }
                }
            }
            else
            {
                Response.Redirect("/User_Pages/User_Main_Page.aspx");
            }

            if (Page.IsPostBack)
            {
                ViewState.Add("Bulding_Max_area", Bulding_Max_area.Text);
                ViewState.Add("Bulding_Min_area", Bulding_Min_area.Text);
                ViewState.Add("Room_Max_Number", Room_Max_Number.Text);
                ViewState.Add("Room_Min_Number", Room_Min_Number.Text);
                ViewState.Add("Total_Max_Cost", Total_Max_Cost.Text);
                ViewState.Add("Total_Min_Cost", Total_Min_Cost.Text);
                // ViewState.Add("Purpose", Purpose.SelectedValue);
                // ViewState.Add("Purpose", TextBox1.Text);

                //TextBox1.Text = Purpose.SelectedItem.Value;

                ViewState.Add("Land_Max_area", Land_Max_area.Text);
                ViewState.Add("Land_Min_area", Land_Min_area.Text);
                ViewState.Add("Total_Max_Cost_Land", Total_Max_Cost_Land.Text);
                ViewState.Add("Total_Min_Cost_Land", Total_Min_Cost_Land.Text);
            }

            if (!Page.IsPostBack)
            {
                //Purpose_Apartment_DAL Purpose_item_building = new Purpose_Apartment_DAL();
                //foreach (var item in Purpose_item_building.select_All())
                //{



                //}



                //{

                //   ListItem listitem = new ListItem(item.Name, item.ID.ToString());
                //   Purpose.Items.Add(listitem);
                //}
                Type_property.Items.Add("Building");
                Type_property.Items.Add("Lands");
                MultiView1.ActiveViewIndex = 0;
            }
        }
        private void loadProduct(int productID)
        {
            ProductBL productBL = new ProductBL();
            Product   product   = productBL.GetProduct(productID, string.Empty, false, string.Empty);

            lblProductID.Value        = product.ProductID.ToString();
            txtCode.Text              = product.Code;
            txtSupplierCode.Text      = product.SupplierCode;
            txtName.Text              = product.Name;
            cmbBrand.SelectedValue    = cmbBrand.Items.FindByValue(product.Brand.BrandID.ToString()).Value;
            txtDescription.Text       = product.Description;
            txtPrice.Text             = string.Format("{0:N2}", product.Price);
            txtWebPrice.Text          = string.Format("{0:N2}", product.WebPrice);
            txtInsertDate.Text        = product.InsertDate.ToString();
            txtUpdateDate.Text        = product.UpdateDate.ToString();
            cmbVat.SelectedValue      = cmbVat.Items.FindByValue(product.VatID.ToString()).Value;
            cmbSupplier.SelectedValue = cmbSupplier.Items.FindByValue(product.SupplierID.ToString()).Value;
            chkApproved.Checked       = product.IsApproved;
            chkActive.Checked         = product.IsActive;
            chkLocked.Checked         = product.IsLocked;
            chkInStock.Checked        = product.IsInStock;
            txtEan.Text           = product.Ean;
            txtSpecification.Text = product.Specification;
            Page.Title            = product.Name + " | Admin panel";
            ViewState.Add("pageTitle", Page.Title);

            if (product.Promotion != null)
            {
                cmbPromotions.SelectedValue = cmbPromotions.Items.FindByValue(product.Promotion.PromotionID.ToString()).Value;
                txtPromotionPrice.Text      = product.Promotion.Price.ToString();
            }

            if (product.Categories != null)
            {
                cmbCategory.SelectedValue = cmbCategory.Items.FindByValue(product.Categories[0].CategoryID.ToString()).Value;
                createControls();
                int i = 0;
                if (product.Attributes != null)
                {
                    int attributeID = -1;
                    foreach (object control in pnlAttributes.Controls)
                    {
                        if (control is Literal)
                        {
                            int.TryParse(((Literal)control).Text, out attributeID);
                        }
                        if (control is customControls.AttributeControl)
                        {
                            int index;
                            if ((index = hasAttribute(product.Attributes, attributeID)) > -1)
                            {
                                ((customControls.AttributeControl)control).AttributeValueID = product.Attributes[index].AttributeValueID;
                            }
                            else
                            {
                                ((customControls.AttributeControl)control).AttributeValue = "NP";
                            }
                        }
                    }
                }
            }

            if (product.Images != null)
            {
                ViewState.Add("images", product.Images);
                loadImages();

                string imageUrl = product.Images[0].Substring(0, product.Images[0].IndexOf(".jpg"));
                imgProduct.ImageUrl = createImageUrl(imageUrl, "");
                imgHome.ImageUrl    = createImageUrl(imageUrl, "home");
                imgLarge.ImageUrl   = createImageUrl(imageUrl, "large");
                imgThumb.ImageUrl   = createImageUrl(imageUrl, "thumb");
            }

            /*rptImages.DataSource = product.Images;
             * rptImages.DataBind();*/
        }
Exemple #24
0
        private void cmdChangePassword_Click(object sender, EventArgs e)
        {
            //1. Check New Password and Confirm are the same
            if (txtPassword.Text != txtConfirmPassword.Text)
            {
                resetMessages.Visible = true;
                var failed = Localization.GetString("PasswordMismatch");
                LogFailure(failed);
                lblHelp.Text = failed;
                return;
            }

            if (UserController.ValidatePassword(txtPassword.Text) == false)
            {
                resetMessages.Visible = true;
                var failed = Localization.GetString("PasswordResetFailed");
                LogFailure(failed);
                lblHelp.Text = failed;
                return;
            }

            //Check New Password is not same as username or banned
            var settings = new MembershipPasswordSettings(User.PortalID);

            if (settings.EnableBannedList)
            {
                var m = new MembershipPasswordController();
                if (m.FoundBannedPassword(txtPassword.Text) || txtUsername.Text == txtPassword.Text)
                {
                    resetMessages.Visible = true;
                    var failed = Localization.GetString("PasswordResetFailed");
                    LogFailure(failed);
                    lblHelp.Text = failed;
                    return;
                }
            }

            string username = txtUsername.Text;

            if (PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", PortalId, false))
            {
                var testUser = UserController.GetUserByEmail(PortalId, username); // one additonal call to db to see if an account with that email actually exists
                if (testUser != null)
                {
                    username = testUser.Username; //we need the username of the account in order to change the password in the next step
                }
            }

            if (UserController.ChangePasswordByToken(PortalSettings.PortalId, username, txtPassword.Text, ResetToken) == false)
            {
                resetMessages.Visible = true;
                var failed = Localization.GetString("PasswordResetFailed", LocalResourceFile);
                LogFailure(failed);
                lblHelp.Text = failed;
            }
            else
            {
                //check user has a valid profile
                var user        = UserController.GetUserByName(PortalSettings.PortalId, username);
                var validStatus = UserController.ValidateUser(user, PortalSettings.PortalId, false);
                if (validStatus == UserValidStatus.UPDATEPROFILE)
                {
                    LogSuccess();
                    ViewState.Add("PageNo", 3);
                    Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Login"));
                }
                else
                {
                    //Log user in to site
                    LogSuccess();
                    var loginStatus = UserLoginStatus.LOGIN_FAILURE;
                    UserController.UserLogin(PortalSettings.PortalId, username, txtPassword.Text, "", "", "", ref loginStatus, false);
                    RedirectAfterLogin();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ShowMessage(false);
                // Obtiene la sesión de usuario activa.
                userEntity = (UserEntity)Session[SessionConstants.User];

                if (userEntity != null)
                {
                    LabelWelcome.Text = GetLocalResourceObject("LabelWelcomeResource1.Text").ToString() + " <b>" + userEntity.UserName.ToUpper(CultureInfo.InvariantCulture) + "</b>";

                    if (!Page.IsPostBack)
                    {
                        // Crea el arbol de categorias para administrar las categorias de la tienda.
                        tree = new CategoriesTree();
                        // Añade el árbol de categorias a la sesión.
                        Session.Add(SessionConstants.TreeService, tree);
                        // Fuerza al objeto Context.Handler para que coincida con el tipo de página.
                        sourcepage = (ListServices)Context.Handler;

                        // Muestra el valor de la propiedad.
                        if (sourcepage.IdService != null)
                        {
                            // Obtiene el ID del servicio.
                            idService = Convert.ToInt32(sourcepage.IdService, CultureInfo.InvariantCulture);
                            // Añade el ID del servicio al ViewState.
                            ViewState.Add(IDService, idService);
                            // Carga y muestra los datos del servicio.
                            LoadService(idService);
                        }
                        else
                        {
                            // Crea un nuevo servicio.
                            serviceEntity = new ServiceEntity();
                            // El servicio está asociado con la tienda.
                            serviceEntity.IdStore = UserEntity.Store.Id;
                            // Formatea los datos a ser mostrados.
                            ShowServiceDate(true);
                            // Carga las categorias de la tienda.
                            LoadCategories();
                        }
                    }
                    else
                    {
                        // Obtiene el árbol de categorias de la sesión.
                        tree = (CategoriesTree)Session[SessionConstants.TreeService];

                        if (ViewState[IDService] != null)
                        {
                            // Obtiene el ID del servicio del ViewState.
                            idService = Convert.ToInt32(ViewState[IDService], CultureInfo.InvariantCulture);
                            // Carga los datos del servicio y de la tienda.
                            serviceEntity = GetServiceEntity(idService);
                        }
                        else
                        {
                            // Carga los datos de la tienda, crea un nuevo servicio y asigna el ID de la tienda al servicio.
                            serviceEntity         = new ServiceEntity();
                            serviceEntity.IdStore = UserEntity.Store.Id;
                        }
                    }
                }
                else
                {
                    // Si el usuario no esta logeado redirecciona a la página de log.
                    Server.Transfer(PagesConstants.LogOnPage);
                }
            }
            catch (InvalidCastException error)
            {
                Debug.WriteLine(error.Message);

                Server.Transfer(PagesConstants.Homepage);
            }
        }
Exemple #26
0
        protected void uploadFile_Click(object sender, EventArgs e)
        {
            // Save temp file
            if (translationFile.PostedFile != null)
            {
                string tempFileName;
                if (translationFile.PostedFile.FileName.ToLower().Contains(".zip"))
                {
                    tempFileName = IOHelper.MapPath(SystemDirectories.Data + "/" + "translationFile_" + Guid.NewGuid().ToString() + ".zip");
                }
                else
                {
                    tempFileName = IOHelper.MapPath(SystemDirectories.Data + "/" + "translationFile_" + Guid.NewGuid().ToString() + ".xml");
                }

                translationFile.PostedFile.SaveAs(tempFileName);

                // xml or zip file
                if (new FileInfo(tempFileName).Extension.ToLower() == ".zip")
                {
                    // Zip Directory
                    string tempPath = IOHelper.MapPath(SystemDirectories.Data + "/" + "translationFiles_" + Guid.NewGuid().ToString());

                    // Add the path to the zipfile to viewstate
                    ViewState.Add("zipFile", tempPath);

                    // Unpack the zip file

                    cms.businesslogic.utilities.Zip.UnPack(tempFileName, tempPath, true);

                    // Test the number of xml files
                    try
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (FileInfo translationFileXml in new DirectoryInfo(ViewState["zipFile"].ToString()).GetFiles("*.xml"))
                        {
                            try
                            {
                                foreach (Task translation in ImportTranslatationFile(translationFileXml.FullName))
                                {
                                    sb.Append("<li>" + translation.Node.Text + " <a target=\"_blank\" href=\"preview.aspx?id=" + translation.Id + "\">" + ui.Text("preview") + "</a></li>");
                                }
                            }
                            catch (Exception ee)
                            {
                                sb.Append("<li style=\"color: red;\">" + ee.ToString() + "</li>");
                            }
                        }

                        feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
                        feedback.Text = "<h3>" + ui.Text("translation", "MultipleTranslationDone") + "</h3><p>" + ui.Text("translation", "translationDoneHelp") + "</p><ul>" + sb.ToString() + "</ul>";
                    }
                    catch (Exception ex)
                    {
                        feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.error;
                        feedback.Text = "<h3>" + ui.Text("translation", "translationFailed") + "</h3><p>" + ex.ToString() + "</>";
                    }
                }
                else
                {
                    StringBuilder sb = new StringBuilder();
                    List <Task>   l  = ImportTranslatationFile(tempFileName);

                    if (l.Count == 1)
                    {
                        feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
                        feedback.Text = "<h3>" + ui.Text("translation", "translationDone") + "</h3><p>" + ui.Text("translation", "translationDoneHelp") + "</p><p><a target=\"_blank\" href=\"preview.aspx?id=" + l[0].Id + "\">" + ui.Text("preview") + "</a></p>";
                    }

                    else
                    {
                        foreach (Task t in l)
                        {
                            sb.Append("<li>" + t.Node.Text + " <a target=\"_blank\" href=\"preview.aspx?id=" + t.Id + "\">" + ui.Text("preview") + "</a></li>");
                        }

                        feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
                        feedback.Text = "<h3>" + ui.Text("translation", "MultipleTranslationDone") + "</h3><p>" + ui.Text("translation", "translationDoneHelp") + "</p><ul>" + sb.ToString() + "</ul>";
                    }
                }

                // clean up
                File.Delete(tempFileName);
            }
        }
Exemple #27
0
        protected void repUsers_ItemCommand1(object source, RepeaterCommandEventArgs e)
        {
            #region Delete
            if (e.CommandName == "Delete")
            {
                int id = Convert.ToInt32(e.CommandArgument);
                rep.Delete(id);
                UpdateData();
            }
            #endregion

            #region Edit
            if (e.CommandName == "Edit")
            {
                int       id = Convert.ToInt32(e.CommandArgument);
                MyComment my;
                try
                {
                    my = rep.GetEntityById(id) as MyComment;
                }
                catch (InvalidOperationException e1)
                {
                    my = new MyComment();
                }

                for (int i = 0; i < e.Item.Controls.Count; i++)
                {
                    TextBox t = e.Item.Controls[i] as TextBox;
                    if (t != null)
                    {
                        t.Style.Add("display", "block");
                        t.Text = GetPropertyValue(my, t.ToolTip).ToString();
                    }
                    else
                    {
                        DropDownList lst = e.Item.Controls[i] as DropDownList;

                        if (lst != null)
                        {
                            lst.Style.Add("display", "block");
                            List <MyUserDataGrid> users = repUsers.GetAll();
                            lst.DataSource = users.Select(c => c.Email);
                            lst.DataBind();

                            string name = DBManager.DbManager.GetUserEmailById(my.UserId);

                            lst.SelectedValue = (name == null) ? lst.Items[0].Value : name;
                        }
                    }
                }

                int index = -1;
                for (int i = 0; i < repComments.Items.Count; i++)
                {
                    if (repComments.Items[i] == e.Item)
                    {
                        index = i;
                    }
                }

                ViewState.Add("EditedId", id);
                ViewState.Add("EditedIndex", index);

                btnSave.Style.Add("display", "inline");
                btnCancel.Style.Add("display", "inline");

                isEditing = true;
            }
            #endregion

            #region Add

            if (e.CommandName == "Add")
            {
                List <MyComment> comments = rep.GetAll();
                MyComment        my       = new MyComment();
                comments.Add(my);

                repComments.DataSource = comments;
                repComments.DataBind();

                RepeaterItem item = repComments.Items.OfType <RepeaterItem>().ElementAt(repComments.Items.Count - 1);

                for (int i = 0; i < item.Controls.Count; i++)
                {
                    TextBox t = item.Controls[i] as TextBox;
                    if (t != null)
                    {
                        t.Style.Add("display", "block");
                        object obj = GetPropertyValue(my, t.ToolTip);

                        t.Text = (obj == null) ? "" : obj.ToString();
                    }
                    else
                    {
                        DropDownList lst = item.Controls[i] as DropDownList;

                        if (lst != null)
                        {
                            lst.Style.Add("display", "block");
                            List <MyUserDataGrid> users  = repUsers.GetAll();
                            List <string>         emails = users.Select(c => c.Email).ToList();
                            lst.DataSource = emails;
                            lst.DataBind();
                        }
                    }
                }

                int index = -1;
                for (int i = 0; i < repComments.Items.Count; i++)
                {
                    if (repComments.Items[i] == item)
                    {
                        index = i;
                    }
                }

                ViewState.Add("EditedId", -1);
                ViewState.Add("EditedIndex", index);

                btnSave.Style.Add("display", "inline");
                btnCancel.Style.Add("display", "inline");

                isEditing = true;
            }

            #endregion
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        GenerateOptionFigureTypes(false);
        Bcode.Type = BarcodeLib.Barcode.BarcodeType.CODE39;
        Bcode.ShowStartStopChar = false;
        Bcode.BarWidth          = 1;
        Bcode.BarHeight         = 50;
        Bcode.LeftMargin        = 5;
        Bcode.RightMargin       = 5;
        Bcode.TopMargin         = 5;
        Bcode.BottomMargin      = 5;
        Bcode.Data = TestCodeData;

        using (Bitmap bitMap = Bcode.drawBarcode())
        {
            using (MemoryStream ms = new MemoryStream())
            {
                bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();
                //barcode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
            }
        }


        Questions = new DataBase.Questions(TestCodeData);

        // Objectives = new DataBase.ObjectivesObj(TestCode);

        if (ViewState["Questionaire"] == null)
        {
            ViewState["Questionaire"] = "none";
        }


        if (ViewState["QuestObjectives"] == null)
        {
            ViewState["QuestObjectives"] = new object[] { };
        }


        if (ViewState["Section"] == null)
        {
            ViewState.Add("Section", 0);
        }


        CurrentNumber = Convert.ToInt32(ViewState["QNumber"]);


        if (IsPostBack)
        {
            if (ViewState["ObjectivesCount"] == null)
            {
                ViewState.Add("ObjectivesCount", 1);
            }

            CurrentNumber = Convert.ToInt32(ViewState["QNumber"]);

            if (Convert.ToInt32(ViewState["Section"]) == 0)
            {
                SectionNumber = 1;
            }
            else
            {
                SectionNumber = 2;
            }

            System.Diagnostics.Debug.WriteLine(ViewState["Section"]);
        }

        else
        {
            if (ViewState["QNumber"] == null)
            {
                ViewState["QNumber"] = 1;

                CurrentNumber = Convert.ToInt32(ViewState["QNumber"]);
            }

            if (Convert.ToInt32(ViewState["Section"]) == 0)
            {
                SectionNumber = 1;
            }
            else
            {
                SectionNumber = 2;
            }


            LoadData(CurrentNumber, SectionNumber);
        }
    }
 protected void btnEdit_Click(object sender, ImageClickEventArgs e)
 {
     ViewState.Add("isEdit", true);
 }
Exemple #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Response.ExpiresAbsolute = DateTime.Now;
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoServerCaching();
            Response.Cache.SetValidUntilExpires(true);
            Response.Cache.SetNoStore();
            Response.Cache.SetExpires(DateTime.Parse(DateTime.Now.ToString()));
            Response.Expires      = -1441;
            Response.CacheControl = "no-cache";
            Response.DisableKernelCache();

            // establish initial and default values
            //_PgNbr = 0;
            _PgRights = 0;
            _PgSize   = 20;
            string logFilePath = System.Configuration.ConfigurationManager.AppSettings["AppLogFilePath"].ToString();

            _SiteURL  = System.Configuration.ConfigurationManager.AppSettings["SitePrefix"];
            _BuildNbr = System.Configuration.ConfigurationManager.AppSettings["BuildNbr"];
            _AppVers  = System.Configuration.ConfigurationManager.AppSettings["AppVersion"].ToString() + " (" + System.Configuration.ConfigurationManager.AppSettings["AppVersionDate"].ToString() + ")";
            string UserName = Request.ServerVariables["LOGON_USER"];

            _user = new CurrentUser(UserName, logFilePath, "");             // SessionHelper.GetCurrentUser(Request.ServerVariables["LOGON_USER"]);
            if (_user == null || !_user.IsValid)
            {
                Logging.WriteToLog("Login failed for " + UserName + ".");
                HttpContext.Current.Response.Redirect("NoAcc/NoAccess.aspx", true);
            }
            _Browser = new CurrBrowserNoSess(System.Web.HttpContext.Current.Request);

            _UserID       = Convert.ToInt32(_user.UserID);
            _LocationCode = _user.LocationCode;
            _MixCode      = "";
            int CanForecast = 0;

            this.lblBuildNbr.Text    = _BuildNbr.ToString();
            this.lblVersion.Text     = System.Configuration.ConfigurationManager.AppSettings["AppVersion"].ToString();
            this.lblVersionDate.Text = System.Configuration.ConfigurationManager.AppSettings["AppVersionDate"].ToString();

            // check for specific rights to forecast consolidation tool
            if (!_user.IsInRole("wurthcdvw") && !_user.IsInRole("datmngtview") && !_user.IsInRole("wurthcdedt") && !_user.IsInRole("wurthcdadm") && !_user.IsAdmin == true)
            {
                //Session["NoAccessMsg"] = "You do not have access to forecasting.";
                Response.Redirect("../NoAcc/NoAccess.aspx", true);
            }
            this._CanEdit = true;
            if (_user.IsInRole("wurthcdadm") || _user.IsAdmin == true)
            {
                this._IsAdmin  = 1;
                this._PgRights = 5;
            }
            else
            {
                if (_user.IsInRole("wurthcdvw") || _user.IsInRole("datmngtview"))
                {
                    this._CanEdit = false;
                    _PgRights     = 1;
                }
            }

            if (!this.IsPostBack)
            {
                try
                {
                    string Loc = _LocationCode;
                    //System.Globalization.CultureInfo ci =
                    //System.Threading.Thread.CurrentThread.CurrentCulture;
                    //DayOfWeek fdow = ci.DateTimeFormat.FirstDayOfWeek;
                    //DayOfWeek today = DateTime.Now.DayOfWeek;
                    //DateTime sow = DateTime.Now.AddDays(-(today - fdow)).Date;
                    ViewState.Add("LocationCode", _LocationCode);
                    ViewState.Add("PgRights", _PgRights.ToString());
                    // calculate dates for 13 weeks for header
                    //var monday1 = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek + 5); //1 8 15 22 29 36 43 50 57 64 71 78 85
                }
                catch (Exception ex)
                {
                    this._ErrMsg = "Initial data Load encountered an error: " + ex.Message;
                }
            }
            else
            {
                // postback
                _LocationCode = ViewState["LocationCode"].ToString();
                _PgRights     = Convert.ToInt32(ViewState["PgRights"]);
            }

            string jsScript = "";

            jsScript = "<script type=\"text/javascript\">var jigEmpID=" + _user.UserID.ToString() + ";var jsgBrowserType='" + _Browser.BrowserType.ToString() + "';var jsgAr=" + _PgRights.ToString() + ";var jgA=" + _IsAdmin.ToString() + ";var jsgLoc='" + _LocationCode + "';var jigFV=" + CanForecast.ToString() + ";var jsgError ='" + this._ErrMsg + "';</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyTargetVariables", jsScript);
        }