示例#1
0
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            //   lblCommitmentValidate.Visible = false;
            if (!Page.IsValid)
            {
                return;               //اینجا باید رد الرت باشه
            }
            // sadegh saryazdi
            //DateTime dateTime = new DateTime(2020, 04, 20);//اول اردیبهشت 1399
            //if (DateTime.Now > dateTime&&!CheckRequest()) return;//بررسی سه دفاع
            //این شرط را داخل در جاییی که شرط ها بررسی می‌شوند بگذار

            var userId = Session[sessionNames.userID_StudentOstad].ToString();
            StudentDefenceRequest request = new StudentDefenceRequest();
            var defInfo = _requestHandler.GetDefenceInformation(userId);

            if (userId == "99900999")
            {
                request = new StudentDefenceRequest
                {
                    CategoryId             = 2,
                    Subject                = "ارزیابی عملکرد تلفیقی فرایند بیولوژیکی و فیزیکوشیم",
                    Location               = "2",
                    Status                 = 0,
                    IssuerId               = 99900999,
                    IssuerName             = "محمد سرگزی",
                    Capacity               = 1,
                    DefenceSubject         = "ارزیابی عملکرد تلفیقی فرایند بیولوژیکی و فیزیکوشیم",
                    DaneshId               = 3,
                    CourseName             = "ارزیابی عملکرد تلفیقی فرایند بیولوژیکی و فیزیکوشیم",
                    RequestDate            = txtDate.Text,
                    RequestStartTime       = txtTime.SelectedTime.Value.Ticks,
                    OnlineTeacherRole      = ckbAprroveOnline.Checked ? drpRoleTeacher.SelectedValue : string.Empty,
                    OnlineFirstTeacherName = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Text : string.Empty,
                    OnlineFirstTeacherId   = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Value.Substring(3) : string.Empty,

                    //sadeghsaryazdi

                    FlagDoingMeetingOnline = chkDoingOnlineDefence.Checked ? true : false,

                    // = ckbAprroveOnline.Checked ? drpRoleTeacher.SelectedItem.Text : string.Empty,
                    UseOwnPc = rdbOwnSystem.Checked,
                    UserId   = Session[sessionNames.userID_StudentOstad].ToString(),
                    Gender   = "1"
                };

                request.AcceptPropDate = "1397/11/27";
            }
            else
            {
                request = new StudentDefenceRequest
                {
                    CategoryId             = (int)Category.InPersonClass,
                    Subject                = StudentDefenceRequest.StaticStudentRequest().Subject,
                    Location               = ((int)Location.Raam).ToString(),
                    Status                 = (int)RequestStatus.submitted,
                    IssuerId               = Convert.ToInt32(Session[sessionNames.userID_StudentOstad].ToString()),
                    IssuerName             = defInfo.StudentFullName,
                    Capacity               = StudentDefenceRequest.StaticStudentRequest().Capacity,
                    DefenceSubject         = defInfo.DefenceSubject,
                    DaneshId               = Convert.ToInt32(defInfo.CollegeId),
                    CourseName             = defInfo.DefenceSubject,
                    RequestDate            = txtDate.Text,
                    RequestStartTime       = txtTime.SelectedTime.Value.Ticks,
                    OnlineTeacherRole      = ckbAprroveOnline.Checked ? drpRoleTeacher.SelectedValue : string.Empty,
                    OnlineFirstTeacherName = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Text : string.Empty,
                    OnlineFirstTeacherId   = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Value.Substring(3) : string.Empty,

                    //sadeghsaryazdi

                    FlagDoingMeetingOnline = chkDoingOnlineDefence.Checked ? true : false,

                    // = ckbAprroveOnline.Checked ? drpRoleTeacher.SelectedItem.Text : string.Empty,
                    UseOwnPc = rdbOwnSystem.Checked,
                    UserId   = Session[sessionNames.userID_StudentOstad].ToString(),
                    Gender   = defInfo.studentGender
                };
                request.AcceptPropDate = defInfo.GroupAcceptDate;
            }
            if (rcbOnlineTeacher.Items.Count > 1)
            {
                request.OnlineSecondTeacherName = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[1].Checked
                    ? rcbOnlineTeacher.Items[1].Text
                    : string.Empty;
                request.OnlineSecondTeacherId = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[1].Checked
                    ? rcbOnlineTeacher.Items[1].Value.Substring(3)
                    : string.Empty;
            }
            request.RequestEndTime = request.RequestStartTime + _requestHandler.GetDefenceInMeetingLength(Convert.ToInt32(defInfo.CollegeId));

            var reqId = 0;

            request.IsRequestEducation = false;
            var message = _requestHandler.CreateStudentRequestV2(out reqId, request);

            if (message.Contains("ok"))
            {
                defInfo.RequestDate = request.RequestDate;
                defInfo.StartTime   = request.RequestStartTime;
                defInfo.EndTime     = request.RequestEndTime;

                string scrp = message.Substring(2);
                //PrevPage = ViewState["PrevPage"].ToString();
                //var uri = Request.UrlReferrer.ToString();
                // _prevPage = uri.Replace("StudentAddRequest.aspx", "StudentReview.aspx");
                //var requestRawUrl = Request.RawUrl;
                CommonBusiness CommonBusiness = new CommonBusiness();
                CommonBusiness.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToString("HH:mm"), 11, 40, "ثبت درخواست رزرو جلسه دفاع توسط دانشجو", reqId);

                string address       = "../Forms/StudentReview.aspx";
                string resdirectFunc = "function redirectToLast(){ window.location= '" + address + "' ; }";
                RadWindowManager1.RadAlert(scrp, 500, 100, "پیام سیستم", resdirectFunc);
                //DateTime dateTimeEnd = RequestHandler.WorkingDays24h(DateTime.Now);
                DateTime dateTimeEnd = RequestHandler.WorkingDays12h(DateTime.Now);
                SendSmsContactBuisnes.SendSmsOsForOstadsDefence(userId, request.IssuerName,
                                                                request.RequestDate, dateTimeEnd.Date.ToPeString(), txtTime.SelectedTime.Value.ToString().Substring(0, 5), dateTimeEnd.Hour + ":" + dateTimeEnd.Minute);
            }
            else
            {
                RadWindowManager1.RadAlert(message, 500, 100, "خطا", "");
            }
        }
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            string message;

            if (!Page.IsValid)
            {
                return;               //اینجا باید رد الرت باشه
            }
            var userId                    = Convert.ToInt32(Session[sessionNames.userID_StudentOstad].ToString());
            var defenceInformation        = _requestHandler.GetDefenceInformation(userId.ToString());
            var studentDefenceRequestList = _requestHandler.GetStudentDefenceRequest(userId);

            var listOfDefenceRequest = RequestHandler.ConvertDataTableToList <StudentDefenceRequestDTO>(studentDefenceRequestList);
            var inCirculationRequest =
                listOfDefenceRequest.FirstOrDefault(
                    x => x.isDeleted != true && x.RequestDate.StringPersianDateToGerogorianDate() >= DateTime.Now) ??
                listOfDefenceRequest.OrderByDescending(x => x.ID).FirstOrDefault();

            if (txtTime.SelectedTime == null)
            {
                return;
            }
            var request = new StudentDefenceRequest
            {
                IssuerId               = Convert.ToInt32(Session[sessionNames.userID_StudentOstad].ToString()),
                RequestDate            = txtDate.Text,
                RequestStartTime       = txtTime.SelectedTime.Value.Ticks,
                OnlineTeacherRole      = ckbAprroveOnline.Checked ? drpRoleTeacher.SelectedValue : string.Empty,
                OnlineFirstTeacherName = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Text : string.Empty,
                OnlineFirstTeacherId   = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[0].Checked ? rcbOnlineTeacher.Items[0].Value.Substring(3) : string.Empty,
                UseOwnPc               = rdbOwnSystem.Checked,
                UserId   = Session[sessionNames.userID_StudentOstad].ToString(),
                Gender   = defenceInformation.studentGender,
                DaneshId = Convert.ToInt32(inCirculationRequest.CollegeId)
            };

            if (rcbOnlineTeacher.Items.Count > 1)
            {
                request.OnlineSecondTeacherName = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[1].Checked
                    ? rcbOnlineTeacher.Items[1].Text
                    : string.Empty;
                request.OnlineSecondTeacherId = ckbAprroveOnline.Checked && rcbOnlineTeacher.Items[1].Checked
                    ? rcbOnlineTeacher.Items[1].Value.Substring(3)
                    : string.Empty;
            }
            request.RequestEndTime = request.RequestStartTime + _requestHandler.GetDefenceInMeetingLength(Convert.ToInt32(defenceInformation.CollegeId));
            request.AcceptPropDate = defenceInformation.GroupAcceptDate;
            request.IsEdited       = true;
            request.Id             = inCirculationRequest.ID;
            request.Status         = inCirculationRequest.status;
            //sadeghsaryazdi
            request.FlagDoingMeetingOnline = chkDoingOnlineDefence.Checked ? true : false;
            request.IsRequestEducation     = false;
            message = _requestHandler.UpdateStudentRequest(request);

            if (message.Contains("ok"))
            {
                defenceInformation.RequestDate = request.RequestDate;
                defenceInformation.StartTime   = request.RequestStartTime;
                defenceInformation.EndTime     = request.RequestEndTime;

                string scrp = message.Substring(2);
                //PrevPage = ViewState["PrevPage"].ToString();
                //var uri = Request.UrlReferrer.ToString();
                // PrevPage = uri.Replace("StudentAddRequest.aspx", "StudentReview.aspx");
                // var requestRawUrl = Request.RawUrl;

                CommonBusiness CommonBusiness = new CommonBusiness();
                CommonBusiness.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToString("HH:mm"), 11, 41, "ویرایش درخواست رزرو جلسه دفاع توسط دانشجو", request.Id);
                //if (LblLastDate.Value != txtDate.Text || LblLastTime.Value != txtTime.SelectedTime.Value.Ticks.ToString())
                //{

                const bool editMsg = true;

                //DateTime dateTimeEnd = RequestHandler.WorkingDays24h(DateTime.Now);
                DateTime dateTimeEnd = RequestHandler.WorkingDays12h(DateTime.Now);
                SendSmsContactBuisnes.SendSmsOsForOstadsDefence(userId.ToString(), request.IssuerName,
                                                                request.RequestDate, dateTimeEnd.Date.ToPeString(), txtTime.SelectedTime.Value.ToString().Substring(0, 5), dateTimeEnd.Hour + ":" + dateTimeEnd.Minute, editMsg);
                //}

                string address       = "../Forms/StudentReview.aspx";
                string resdirectFunc = "function redirectToLast(){ window.location= '" + address + "' ; }";
                RadWindowManager1.RadAlert(scrp, 500, 100, "پیام سیستم", resdirectFunc);
            }
            else
            {
                RadWindowManager1.RadAlert(message, 500, 100, "خطا", "");
            }
        }