//*****************
        protected void drpRequestTypeList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int status = Convert.ToInt32(drpRequestTypeList.SelectedValue);
            var roleId = Convert.ToInt32(Session["roleID"]);

            if (UtilityFunction.IsMasouleDaftarUser(roleId))
            {
                GridBindForMasoulDaftar(roleId, status);
            }
            else
            {
                if (roleId == 1)
                {
                    GridBindForAdmin(roleId, status);
                    if (status == 1)
                    {
                        FillLinkAndStatusForClick(status);
                        //  FillLinkAndStatusForClickOffice(1);
                    }
                    else
                    {
                        FillLinkAndStatusForClick(status);
                    }
                }
                else
                {
                    GridBind(status);
                }
            }
        }
 protected void chkMeeting_CheckedChanged(object sender, EventArgs e)
 {
     if (chkMeeting.Checked == true)
     {
         if (drpCategory.SelectedIndex == 2)
         {
             chkMeeting.Text = "بدون استاد";
         }
         else
         {
             chkMeeting.Text = " تخصیص سالن کنفرانس جهت برگزاری جلسات";
         }
         RadComboBoxField.Visible = false;
         valField.Enabled         = false;
         drpCourse.Visible        = false;
         trProfCrs.Visible        = false;
         trDaneshkadeh.Visible    = false;
     }
     else
     {
         if (!UtilityFunction.IsMasouleDaftarUser(roleID))
         {
             RadComboBoxField.Visible = true;
             valField.Enabled         = true;
             drpCourse.Visible        = true;
             trProfCrs.Visible        = true;
             trDaneshkadeh.Visible    = true;
         }
     }
 }
        protected void grdListOfRequest_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grdListOfRequest.PageIndex = e.NewPageIndex;
            int status = Convert.ToInt32(drpRequestTypeList.SelectedValue);

            if (drpRequestTypeList.SelectedIndex == 1 || drpRequestTypeList.SelectedIndex == 2 || drpRequestTypeList.SelectedIndex == 4)
            {
                var dataControlField = (DataControlField)grdListOfRequest.Columns.Cast <DataControlField>().SingleOrDefault(fld => fld.HeaderText == "لغو درخواست");
                if (dataControlField != null)
                {
                    dataControlField.Visible = true;
                }
            }
            else
            {
                var dataControlField = (DataControlField)grdListOfRequest.Columns.Cast <DataControlField>().SingleOrDefault(fld => fld.HeaderText == "لغو درخواست");
                if (dataControlField != null)
                {
                    dataControlField.Visible = false;
                }
            }
            var rolId = -1;

            if (Session["roleID"] != null)
            {
                rolId = Convert.ToInt32(Session["roleID"]);
            }
            if (UtilityFunction.IsMasouleDaftarUser(rolId))
            {
                GridBindForMasoulDaftar(rolId, status);
            }
            else
            {
                if (rolId == 1)//admin
                {
                    GridBindForAdmin(rolId, status);
                }
                else
                {
                    GridBind(status);
                }
            }
        }
        private void MasoulDaftarView(int roleId)
        {
            if (UtilityFunction.IsMasouleDaftarUser(roleId))
            {
                //foreach (ListItem i in drpCategory.Items)
                //{
                //
                //}

                for (int i = 1; i < drpCategory.Items.Count; i++)
                {
                    drpCategory.Items[i].Enabled = false;
                }

                //       drpCategory.Items.FindByValue("0").Enabled = true;
                drpCategory.Items.FindByValue("3").Enabled = true;
                trDaneshkadeh.Visible = false;
                trProfCrs.Visible     = false;
            }
        }
        private void CreateRequest()
        {
            RequestFR req = new RequestFR();

            req.CatID    = Convert.ToInt32(drpCategory.SelectedValue);
            req.Subject  = "nosub";
            req.Note     = txtDescription.Text;
            req.Location = drpLocation.SelectedValue;
            req.Status   = (int)RequestStatus.sent;
            RC_User        user = new RC_User();
            RC_UserHandler us   = new RC_UserHandler();
            CourseHandler  corH = new CourseHandler();

            if (chkMeeting.Checked == true)
            {
                req.IssuerID   = Convert.ToInt32(Session[sessionNames.userID_Karbar].ToString());
                user.Name      = Session["UserName"].ToString();
                req.IssuerName = user.Name;
                if (drpCategory.SelectedIndex == 3)
                {
                    req.CourseName = "درخواست جلسه";
                }
                else
                {
                    req.CourseName = "درخواست کلاس بدون استاد";
                }
                Session["isMeeting"] = true;
                daneshID             = Convert.ToInt32(Session["DaneshId"]);
                req.DaneshID         = daneshID;
                req.Capacity         = Convert.ToInt32(txtCapacity.Text);
            }
            else
            {
                if (UtilityFunction.IsMasouleDaftarUser(roleID))
                {
                    req.IssuerID   = Convert.ToInt32(Session[sessionNames.userID_Karbar].ToString());
                    user.Name      = Session["UserName"].ToString();
                    req.IssuerName = user.Name;
                    if (drpCategory.SelectedIndex == 3)
                    {
                        req.CourseName = "درخواست جلسه";
                    }
                    else
                    {
                        req.CourseName = "درخواست کلاس بدون استاد";
                    }
                    Session["isMeeting"] = true;
                    daneshID             = Convert.ToInt32(Session["DaneshId"]);
                    req.DaneshID         = daneshID;
                    req.Capacity         = Convert.ToInt32(txtCapacity.Text);
                }
                else
                {
                    req.IssuerID = Convert.ToInt32(RadComboBoxField.SelectedValue.ToString());

                    user           = us.Get_Ostad_Details(req.IssuerID);
                    req.IssuerName = user.Name;
                    courselist     = corH.GetCourseListByUserID(req.IssuerID);
                    int coursedid = Convert.ToInt32(drpCourse.SelectedValue);
                    req.Capacity   = Convert.ToInt32(txtCapacity.Text);
                    req.CourseName = drpCourse.SelectedItem.ToString();
                    req.DaneshID   = courselist.Find(i => i.DID == coursedid).DaneshID;
                    req.CourseDID  = coursedid;
                }
            }
            req.Issue_time = DateTime.Now.ToPeString();

            if (chbRepeat.Checked == false)
            {
                if (CheckReqDate(pcal1.Text))
                {
                    RequestDateTime rdt = new RequestDateTime();
                    rdt.Date          = pcal1.Text;
                    rdt.StartTime     = RadTimePicker1.SelectedTime.Value.Ticks;
                    rdt.EndTime       = RadTimePicker2.SelectedTime.Value.Ticks;
                    req.DateTimeRange = new List <RequestDateTime>();
                    req.DateTimeRange.Add(rdt);
                }
                else
                {
                    string scrp = "تاریخ درخواست باید بعد از تاریخ امروز باشد.";
                    RadWindowManager1.RadAlert(scrp, 300, 100, "خطا", "");
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", scrp, true);
                    return;
                }
            }
            else
            {
                if (CheckReqDate(pcal1.Text) && CheckReqDate(pcal2.Text))
                {
                    req.DateTimeRange = FillRequestDateTime(pcal1.Text, pcal2.Text, RadTimePicker1.SelectedTime, RadTimePicker2.SelectedTime, chblWeekDates);
                }
                else
                {
                    string scrp = "تاریخ درخواست باید بعد از تاریخ امروز باشد.";//باید این پیام عوض شود.
                    RadWindowManager1.RadAlert(scrp, 300, 100, "خطا", "");
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", scrp, true);
                    return;
                }
            }

            optlist = new List <Option>();
            foreach (ListItem item in chblOptions.Items)
            {
                if (item.Selected)
                {
                    Option opt = new Option();
                    opt.ID       = Convert.ToInt32(item.Value);
                    opt.Name     = item.Text;
                    opt.IsActive = item.Selected;
                    optlist.Add(opt);
                }
            }
            RequestHandler rqh = new RequestHandler();
            DataTable      dt  = rqh.HasRequestBefore(req.IssuerID, req.DateTimeRange);

            if (dt.Rows.Count > 0)
            {
                if (dt.Select().ToList().Exists(row => row["MayConflict"].ToString() == "1"))
                {
                    string scrp = "تداخل در ساعت و تاریخ درخواست ، با ساعات درخواست های پیشین این استاد.";
                    RadWindowManager1.RadAlert(scrp, 300, 100, "خطا", "");

                    return;
                }
            }

            if (RequestHandler.IsNotSpecifiedDay(DayOfWeek.Friday, req.DateTimeRange))
            {
                string scrp = "در روز جمعه امکان برگزاری وجود ندارد";
                RadWindowManager1.RadAlert(scrp, 300, 100, "خطا", "");

                return;
            }
            try
            {
                int reqid  = rqh.AddNewRequest(req, optlist, Session[sessionNames.userID_Karbar].ToString());
                var comman = new CommonBusiness();
                comman.InsertIntoUserLog(userID, "", 11, 114, "ثبت درخواست کلاس ", reqid);



                string scrp          = "درخواست شما با شماره " + reqid.ToString() + " با موفقیت ثبت گردید";
                string address       = prevPage + "?id=" + generaterandomstr() + "@A" + "0" + "-" + generaterandomstr();
                string resdirectFunc = "function redirectToLast(){ window.location= '" + address + "' ; }";
                RadWindowManager1.RadAlert(scrp, 300, 100, "پیام سیستم", resdirectFunc);

                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", scrp, true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        private void LoadPanels(string userId, string UserRole, int daneshId, int IssuerId, int SectionId)
        {
            RequestHandler ReqHandler = new RequestHandler();
            mainViewModel  ReqsCount  = null;
            mainViewModel  ReqsCount1 = null;

            if (UtilityFunction.IsMasouleDorehKootahModat(Convert.ToInt32(UserRole)) > 0)
            {
                if (!(daneshId == 0 || daneshId == 5))
                {
                    dvWaitingForSend.Visible = true;
                    dvSent.Visible           = true;
                    dvApproved.Visible       = true;
                    dvDenied.Visible         = true;
                    ReqsCount  = ReqHandler.GetRequestCountByStatusAndDaneshId(daneshId);
                    ReqsCount1 = ReqHandler.GetRequestCountByStatusAndDaneshIdForDefence(daneshId);
                }
                if (daneshId == 5)
                {
                    dvWaitingForSend.Visible = true;
                    dvSent.Visible           = true;
                    dvApproved.Visible       = true;
                    dvDenied.Visible         = true;
                    dvWaitingForSend.Visible = false;
                    ReqsCount  = ReqHandler.GetRequestCountByStatusAndIssuerId(IssuerId);
                    ReqsCount1 = ReqHandler.GetRequestCountByStatusAndIssuerIdForDefence(IssuerId);
                }
                if (daneshId == 0)
                {
                    dvWaitingForSend.Visible = true;
                    dvSent.Visible           = true;
                    dvApproved.Visible       = true;
                    dvDenied.Visible         = true;
                    dvInformed.Visible       = true;
                    dvLost.Visible           = true;
                    ReqsCount  = ReqHandler.GetRequestCountByStatusForAdmin();
                    ReqsCount1 = ReqHandler.GetRequestCountByStatusForAdminForDefence();

                    //  ReqsCount = ReqHandler.GetRequestCountByStatus();
                }
            }
            if (UserRole == "26" || UserRole == "27" || UserRole == "28" || UserRole == "68" ||
                UserRole == "15" || UserRole == "16" || UserRole == "17" || UserRole == "67" ||
                UserRole == "66" || UserRole == "53" || UserRole == "52" || UserRole == "51")  //amoozesh
            {
                dvWaitingForSend.Visible = true;
                dvSent.Visible           = true;
                dvApproved.Visible       = true;
                dvDenied.Visible         = true;
                dvLost.Visible           = false;
                dvDenied2.Visible        = true;
                dvDenied3.Visible        = true;



                dvWaitingForSend1.Visible = true;
                dvSent1.Visible           = true;
                dvApproved1.Visible       = true;
                //dvDenied1.Visible = true;
                //dvLost1.Visible = false;
                //dvDenied21.Visible = true;
                //dvDenied31.Visible = true;

                //var rq = new RequestHandler();
                //var lostCount = rq.GetRequestListBystatusAnddaneshID(5, daneshId).Where(c => c.Status == 0).ToList().Count;
                ReqsCount  = ReqHandler.GetRequestCountByStatusAndDaneshId(daneshId);
                ReqsCount1 = ReqHandler.GetDefenceRequestCountByLocationForEducation(daneshId);

                //ReqsCount.LostCount = lostCount;
            }
            if (UserRole == "38" || UserRole == "37")//edari molasadra
            {
                dvSent.Visible     = true;
                dvApproved.Visible = true;
                dvDenied.Visible   = true;
                dvLost.Visible     = true;

                //ReqsCount = ReqHandler.GetRequestCountByLocation(1);
                ReqsCount  = ReqHandler.GetRequestCountByLocationForEdari(1);
                ReqsCount1 = ReqHandler.GetRequestCountByLocationForEdariForDefence(1);
            }

            if (UtilityFunction.IsMasouleDaftarUser(Convert.ToInt32(UserRole)))//Masoul daftar -bonyan -omoumi
            {
                // dvWaitingForSend.Visible = true;
                dvSent.Visible     = true;
                dvApproved.Visible = true;
                dvDenied.Visible   = true;
                //ReqsCount = ReqHandler.GetRequestCountByStatusAndDaneshId(daneshId);
                ReqsCount  = ReqHandler.GetRequestCountByStatusAndIssuerId(IssuerId);
                ReqsCount1 = ReqHandler.GetRequestCountByStatusAndIssuerIdForDefence(IssuerId);
            }
            //if (UserRole=="62" || UserRole == "32" || UserRole=="21")// M_daneshjoyi - moAven AMouzeshi
            //{
            //    // dvWaitingForSend.Visible = true;
            //    dvSent.Visible = true;
            //    dvApproved.Visible = true;
            //    dvDenied.Visible = true;
            //    //ReqsCount = ReqHandler.GetRequestCountByStatusAndDaneshId(daneshId);
            //    ReqsCount = ReqHandler.GetRequestCountByStatusAndIssuerId(IssuerId);

            //}


            if (UserRole == "39" || UserRole == "40")//edari pasdaran
            {
                dvSent.Visible      = true;
                dvApproved.Visible  = true;
                dvDenied.Visible    = true;
                dvSent1.Visible     = true;
                dvApproved1.Visible = true;

                //ReqsCount = ReqHandler.GetRequestCountByLocation(2);

                ReqsCount  = ReqHandler.GetRequestCountByLocationForEdari(2);
                ReqsCount1 = ReqHandler.GetDefenceRequestCountByLocationForEdari(2);
            }
            if (UserRole == "50")//moAven edari mali
            {
                dvSent.Visible     = true;
                dvApproved.Visible = true;
                dvDenied.Visible   = true;
                dvLost.Visible     = true;
                ReqsCount          = ReqHandler.GetRequestCountByStatus();
                ReqsCount1         = ReqHandler.GetRequestCountByStatusForDefence();
            }
            if (UserRole == "1")//admin
            {
                dvWaitingForSend.Visible = true;
                dvSent.Visible           = true;
                dvApproved.Visible       = true;
                dvDenied.Visible         = true;
                dvInformed.Visible       = true;
                dvLost.Visible           = true;
                //ReqsCount = ReqHandler.GetRequestCountByStatus();
                ReqsCount  = ReqHandler.GetRequestCountByStatusForAdmin();
                ReqsCount1 = ReqHandler.GetRequestCountByStatusForAdminForDefence();
            }
            //UserRole = "7";
            if (UserRole == "7")//fani
            {
                dvWaitingForSend1.Visible = true;
                //dvSent1.Visible = true;
                dvApproved1.Visible = true;

                ReqsCount1 = ReqHandler.GetDefenceRequestCountByLocationForTechnical();
            }
            lblWaitingForSend.Text  = ReqsCount?.WaitingForSendCount.ToString();
            lblSent.Text            = ReqsCount?.SentCount.ToString();
            lblApproved1.Text       = ReqsCount?.ApprovedCount.ToString();
            lblDenid1.Text          = ReqsCount?.DeniedCount.ToString();
            lblInformed.Text        = ReqsCount?.InformedCount.ToString();
            lblLost.Text            = ReqsCount?.LostCount.ToString();
            lblWaitingForSend1.Text = ReqsCount1?.WaitingForSendCount.ToString();
            //lblSent1.Text = ReqsCount1?.SentCount.ToString();
            if (UserRole != "7")
            {
                lblApproved11.Text = ReqsCount1?.ApprovedCount.ToString();
            }
            else
            {
                lblApproved11.Text = ReqsCount1?.SentCount.ToString();
            }

            lblDenid11.Text   = ReqsCount1?.DeniedCount.ToString();
            lblInformed1.Text = ReqsCount1?.InformedCount.ToString();
            lblLost1.Text     = ReqsCount1?.LostCount.ToString();
            RequestHandler rq = new RequestHandler();
            var            countDeniedByEdari     = 0;
            var            countDeniedByAmouzesh  = 0;
            var            countDeniedByEdari1    = 0;
            var            countDeniedByAmouzesh1 = 0;

            if (rq.GetRequestListBystatusAnddaneshID(5, daneshId) != null)
            {
                countDeniedByEdari    = rq.GetRequestListBystatusAnddaneshID(5, daneshId).Where(c => c.Status == 0).ToList().Count;
                countDeniedByAmouzesh = rq.GetRequestListBystatusAnddaneshID(5, daneshId).Where(c => c.Status == 1).ToList().Count;
            }

            if (rq.GetRequestListBystatusAnddaneshIDForDefence(5, daneshId) != null)
            {
                countDeniedByEdari1    = rq.GetRequestListBystatusAnddaneshIDForDefence(5, daneshId).Where(c => c.Status == 0).ToList().Count;
                countDeniedByAmouzesh1 = rq.GetRequestListBystatusAnddaneshIDForDefence(5, daneshId).Where(c => c.Status == 1).ToList().Count;
            }

            lblDenied3.Text  = countDeniedByAmouzesh.ToString();
            lblDenied2.Text  = countDeniedByEdari.ToString();
            lblDenied31.Text = countDeniedByAmouzesh1.ToString();
            lblDenied21.Text = countDeniedByEdari1.ToString();


            if (UserRole == 62.ToString() ||
                UserRole == 32.ToString() ||
                UserRole == 64.ToString() ||
                UserRole == 50.ToString())
            {
                dvWaitingForSend.Visible = false;
                dvSent.Visible           = false;
                dvApproved.Visible       = false;
                dvDenied.Visible         = false;
                dvInformed.Visible       = false;
                dvLost.Visible           = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userID   = Convert.ToInt32(Session[sessionNames.userID_Karbar]);
            daneshID = Convert.ToInt32(Session["DaneshId"]);
            int roleId;

            // if (userID == 1)
            //{
            //    drpRequestTypeList.Items.Clear();
            //    drpRequestTypeList.Items.Add("درخواستهای منتظر ارجاع");
            //    drpRequestTypeList.Items.Add("درخواستهای منتظر تایید");
            //    drpRequestTypeList.Items.Add("درخواستهای تایید شده");
            //    drpRequestTypeList.Items.Add("درخواستهای اطلاع رسانی شده");
            //    drpRequestTypeList.Items.Add("درخواستهای رد شده");
            //     drpRequestTypeList.Items.Add("درخواستهای از دست رفته");

            //}
            if (!IsPostBack)
            {
                string   mId    = Request.QueryString["id"].ToString();
                string[] id     = mId.ToString().Split(new char[] { '@' });
                string   menuId = "";
                for (int i = 0; i < id[1].Length; i++)
                {
                    string s = id[1].Substring(i + 1, 1);
                    if (s != "-")
                    {
                        menuId += s;
                    }
                    else
                    {
                        break;
                    }
                }
                Session[sessionNames.menuID] = menuId;
                AccessControl.MenuId         = menuId;
                AccessControl.UserId         = Session[sessionNames.userID_Karbar].ToString();
                if (Request.QueryString["status"] != null)
                {
                    string status = Request.QueryString["status"];
                    drpRequestTypeList.ClearSelection();
                    drpRequestTypeList.Items.FindByValue(status).Selected = true;
                    GridBind(Convert.ToInt32(status));
                }
                else
                {
                    roleId = Convert.ToInt32(Session["roleID"]);
                    if (UtilityFunction.IsMasouleDaftarUser(roleId))
                    {
                        if (Session["StausLinke"] != null)
                        {
                            drpRequestTypeList.ClearSelection();
                            drpRequestTypeList.Items.FindByValue(Session["StausLinke"] as string).Selected = true;
                            GridBindForMasoulDaftar(roleId, Convert.ToInt32(Session["StausLinke"]));
                        }
                        else
                        {
                            drpRequestTypeList.ClearSelection();
                            drpRequestTypeList.Items.FindByValue("1").Selected = true;
                            AvoidDrpRequestForMasoulDaftar();
                            GridBindForMasoulDaftar(roleId, 1);
                        }
                    }
                    else
                    {
                        if (Session["StausLinke"] != null)
                        {
                            drpRequestTypeList.ClearSelection();
                            drpRequestTypeList.Items.FindByValue(Session["StausLinke"] as string).Selected = true;

                            if (roleId == 1)
                            {
                                GridBindForAdmin(roleId, Convert.ToInt32(Session["StausLinke"]));
                            }
                            else
                            {
                                GridBind(Convert.ToInt32(Session["StausLinke"]));
                            }
                        }
                        else
                        {
                            if (roleId == 1)
                            {
                                GridBindForAdmin(roleId, 0);
                            }
                            else
                            {
                                GridBind(0);
                            }
                        }
                    }
                }
                userIDStr = Session[sessionNames.userID_Karbar].ToString();
            }
            var rolId = -1;

            if (Session["roleID"] != null)
            {
                rolId = Convert.ToInt32(Session["roleID"]);
            }
            if (rolId == 1)//admin
            {
                drpRequestTypeList.Items.FindByValue("5").Text    = "لیست درخواستهای از دست رفته";
                drpRequestTypeList.Items.FindByValue("7").Enabled = false;
            }
        }