Exemple #1
0
        private void BindData()
        {
            RequestFR req = new RequestFR();
            //reqid = Convert.ToInt32(Session["reqID"]);
            RequestHandler rq = new RequestHandler();

            req = rq.GetRequestDetails(reqid);
            lblRequestID.Text = req.ID.ToString();
            Category ct = new CategoryHandler().GetCategoryDetails(req.CatID);

            lblCategory.Text = ct.Name;
            // lblCourseName.Text = req.CourseName;
            lblLocation.Text    = req.Location;
            lblDescription.Text = req.Note;
            OptionHandler opt1     = new OptionHandler();
            List <Option> optlist1 = opt1.GetOptionListByReqID(req.ID);

            foreach (var item in optlist1)
            {
                chblOptions.Items.Add(item.Name);
                chblOptions.Items.FindByText(item.Name).Selected = true;
            }
            //lblSessionStart.Text = req.Sessionstart_time.ToString();
            //lblSessionEnd.Text = req.Sessionend_time.ToString();
            //pcal1.Text = req.Sessiondate;
            ResourceHandler rs      = new ResourceHandler();
            List <Resource> reslist = rs.GetResourceListByReqID(req.ID);

            grdResourceList.DataSource = reslist;
            grdResourceList.DataBind();
            ViewState.Add("req", req);
        }
Exemple #2
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.GetResourceListByReqIDForAfterAccept(reqId) : rsh.GetResourceListByReqID(reqId);

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

                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();
                lblCourseName.Text    = requestDetails.CourseName.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();

                lst_history.DataSource = cmb.GetUserLogByModifyId(int.Parse(e.CommandArgument.ToString()), 11);
                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;
                lblCapecity.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 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
            }
        }
        protected void grdListOfRequest_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int reqId = Convert.ToInt32(e.CommandArgument);

            ViewState.Add("reqId", reqId);
            if (e.CommandName == "edit")
            {
                hdnfReqId.Value = reqId.ToString();

                List <ResourceControl.Entity.Resource> resList = new List <ResourceControl.Entity.Resource>();
                ResourceHandler rsh = new ResourceHandler();
                _resList = rsh.GetResourceListByReqID(reqId);
                ViewState.Add("reqId", reqId);
                ViewState.Add("_resList", _resList);

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

                    dvSuggestResource.Visible = true;
                }
                else
                {
                    dvSuggestResource.Visible = false;
                }

                if (drpRequestTypeList.SelectedIndex == 5)
                {
                    drpCandidateResource.ClearSelection();
                    dvOperation.Visible = false;
                }

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

                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 == "info")
            {
                RequestHandler reqHandler = new RequestHandler();
                int            counter    = reqHandler.InformUserOfRequestByReqId(reqId, Session[sessionNames.userID_Karbar].ToString());
                string         msg        = null;
                if (counter > 0)
                {
                    msg = "درخواست شماره " + reqId + " با موفقیت اطلاع رسانی شد.";
                }
                else
                {
                    msg = "خطا در اطلاع رسانی درخواست ، لطفا دوباره تلاش کنید.";
                }
                RadWindowManager1.RadAlert(msg, 300, 100, "پیام سیستم", "refresgGrid");
            }

            //  if (e.CommandName == "edit")
            //   {
            //    Response.Redirect("StudentEditRequest.aspx?id=" + generaterandomstr() + "@A" + "0" + "-" + generaterandomstr() + "&reqId=" + e.CommandArgument);
            //StudentEditRequest
            //   }
            if (e.CommandName == "delete")
            {
                RequestHandler rh = new RequestHandler();
                rh.DeleteRequest(reqId);
                //log
                var commanBusiness = new CommonBusiness();
                userID = Convert.ToInt32(Session[sessionNames.userID_Karbar]);
                //124=حذف درخواست کلاس توسط آموزش
                commanBusiness.InsertIntoUserLog(userID, "", 11, 124, "حذف درخواست کلاس توسط آموزش", reqId);
                GridBind(Convert.ToInt32(drpRequestTypeList.SelectedValue));
            }
            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 1:
                    lblStatue.Text = "درخواست ارجاع داده شده است";
                    break;

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

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

                case 4:
                    lblStatue.Text = "درخواست شمااطلاع رسانی شده است";
                    break;
                }
                lblTozieh.Text   = requestDetails.Note;
                lblCapecity.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 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();
                }

                if (drpRequestTypeList.SelectedItem.Value == 2.ToString() ||
                    drpRequestTypeList.SelectedItem.Value == 4.ToString())
                {
                    tdRangeOfDate.Visible = false;
                    tdGrdResult.Visible   = true;

                    _dateTimeList        = rqdateTimeH.GetDateTimeListByRequestId(reqId);
                    grdResult.DataSource = _dateTimeList.OrderBy(c => c.Date);
                    grdResult.DataBind();
                }
                else
                {
                    tdRangeOfDate.Visible = true;
                    tdGrdResult.Visible   = false;
                }

                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
            }
            if (e.CommandName == "History")
            {
                CommonBusiness cmb = new CommonBusiness();

                lst_history.DataSource = cmb.GetUserLogByModifyId(int.Parse(e.CommandArgument.ToString()), 11);
                lst_history.DataBind();

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
            }
        }