private void LoadInfoToControls()
        {
            int       codeostad = Convert.ToInt32(Session[sessionNames.userID_StudentOstad]);
            DataTable dtResult  = FRB.GetOstadInfoFromHR(codeostad);

            if (dtResult.Rows.Count == 0)
            {
                string msg = "کد استادی شما در هیچ کدام از سامانه ها فعال نیست. لطفا جهت فعال سازی با کارشناس مربوطه تماس حاصل فرمایید";
                RadWindowManager1.RadAlert(msg, 400, 200, "پیام سیستم", "RedirectToMain");
                return;
            }
            Session.Add("hrInfoPeopleId", dtResult.Rows[0]["Id"]);

            ListItem itmSelect = new ListItem("انتخاب کنید", "");
            ListItem itmOther  = new ListItem("سایر", "0");

            DTO.University.Faculty.editInfoStruct editInfo = FRB.getOstadInf(codeostad);

            //Session.Add("hrInfoPeopleId", editInfo.hrId);



            DataTable dtControlToSidaList = FRB.GetAllControlToSidaFields();

            DataRow        existsDrp  = null;
            ChangedInfoDTO oChangeDrp = new ChangedInfoDTO();


            existsDrp = dtControlToSidaList.AsEnumerable()
                        .Where(x => x.Field <string>("ControlName") == drpProvince1.ID + "Value")
                        .FirstOrDefault();
            oChangeDrp                  = new ChangedInfoDTO();
            oChangeDrp.Code_Ostad       = codeostad;
            oChangeDrp.ControlToFieldId = Convert.ToInt32(existsDrp["Id"]);
            oChangeDrp.ControlId        = drpProvince1.ID + "value";
            oChangeDrp.OldValue         = getOldValue(existsDrp["id"].ToString(), editInfo);// as string;
            ChangeList.Add(oChangeDrp);

            existsDrp = dtControlToSidaList.AsEnumerable()
                        .Where(x => x.Field <string>("ControlName") == drpLivingCity.ID + "Value")
                        .FirstOrDefault();
            oChangeDrp                  = new ChangedInfoDTO();
            oChangeDrp.Code_Ostad       = codeostad;
            oChangeDrp.ControlToFieldId = Convert.ToInt32(existsDrp["Id"]);
            oChangeDrp.ControlId        = drpLivingCity.ID + "value";
            oChangeDrp.OldValue         = getOldValue(existsDrp["id"].ToString(), editInfo);// as string;
            ChangeList.Add(oChangeDrp);


            existsDrp = dtControlToSidaList.AsEnumerable()
                        .Where(x => x.Field <string>("ControlName") == drpProvince2.ID + "Value")
                        .FirstOrDefault();
            oChangeDrp                  = new ChangedInfoDTO();
            oChangeDrp.Code_Ostad       = codeostad;
            oChangeDrp.ControlToFieldId = Convert.ToInt32(existsDrp["Id"]);
            oChangeDrp.ControlId        = drpProvince2.ID + "value";
            oChangeDrp.OldValue         = getOldValue(existsDrp["id"].ToString(), editInfo);// as string;
            ChangeList.Add(oChangeDrp);
            existsDrp = dtControlToSidaList.AsEnumerable()
                        .Where(x => x.Field <string>("ControlName") == drpWorkingCity.ID + "Value")
                        .FirstOrDefault();
            oChangeDrp                  = new ChangedInfoDTO();
            oChangeDrp.Code_Ostad       = codeostad;
            oChangeDrp.ControlToFieldId = Convert.ToInt32(existsDrp["Id"]);
            oChangeDrp.ControlId        = drpWorkingCity.ID + "value";
            oChangeDrp.OldValue         = getOldValue(existsDrp["id"].ToString(), editInfo);// as string;
            ChangeList.Add(oChangeDrp);

            foreach (Control item in dvAddressFileds.Controls)
            {
                DataRow exists = null;
                if (item is TextBox)
                {
                    exists = dtControlToSidaList.AsEnumerable()
                             .Where(x => x.Field <string>("ControlName") == item.ID)
                             .FirstOrDefault();
                }

                if (exists != null)
                {
                    ChangedInfoDTO oChange = new ChangedInfoDTO();
                    oChange.Code_Ostad       = codeostad;
                    oChange.ControlToFieldId = Convert.ToInt32(exists["Id"]);
                    oChange.ControlId        = item.ID;
                    oChange.OldValue         = getOldValue(exists["id"].ToString(), editInfo);// as string;
                    ChangeList.Add(oChange);
                }
            }

            ViewState.Add("ChangeList", ChangeList);

            txtHomePhone.Text = editInfo.telHome.ToString();

            txtWorkPhone.Text      = editInfo.telKar.ToString();
            txtMobileNumber.Text   = editInfo.telMobile.ToString();
            txtLivingAddress.Text  = editInfo.addressHome.ToString();
            txtWorkingAddress.Text = editInfo.addressKar.ToString();
            txtLivingZipCode.Text  = editInfo.codePosti.ToString();
            txtEmail.Text          = editInfo.email.ToString();

            setDropDownOstanSource(drpProvince1, editInfo.ostanHome);
            setDropDownOstanSource(drpProvince2, editInfo.ostanKar);
            setDropDownShahrSource(drpLivingCity, editInfo.ostanHome, editInfo.shahrHome);
            setDropDownShahrSource(drpWorkingCity, editInfo.ostanKar, editInfo.shahrKar);
        }
        protected void btnSubmitCooperation_Click(object sender, EventArgs e)
        {
            var isChanged = false;
            ProfessorEditRequestDTO oEditDTO = new ProfessorEditRequestDTO();

            oEditDTO.Code_Ostad       = Convert.ToInt32(Session[sessionNames.userID_StudentOstad]);
            oEditDTO.Createdate       = DateTime.Now.ToPeString();
            oEditDTO.RequestTypeID    = (int)RequestTypeId.EditCooperation; // درخواست ویرایش مشخصات فردی
            oEditDTO.RequestLogID     = (int)RequestLogId.submitted;        // در حال بررسی
            oEditDTO.HR_InfoPeople_Id = Convert.ToInt32(Session["hrInfoPeopleId"]);
            oEditDTO.ChangeSet        = 1;
            oEditDTO.ChangeList       = new List <ChangedInfoDTO>();

            if (IsValid && CheckDaneshkadeAndGroupsRelation() && checkChangesInCooperation())
            {
                int NewCooperation = 0;
                if ((chbkCooperation.Items.Cast <ListItem>().Count(li => li.Selected)) > 1)
                {
                    NewCooperation = 3;
                }
                else
                {
                    NewCooperation = Convert.ToInt32(chbkCooperation.SelectedValue);
                }
                if (CheckInfo(NewCooperation))
                {
                    updateGroupOstad();
                    if (NewCooperation != 0)
                    {
                        int OldCoopertaion = Convert.ToInt32(ViewState["cooperation"]);
                        if (OldCoopertaion != NewCooperation)
                        {
                            ChangedInfoDTO oChange = new ChangedInfoDTO();
                            oChange.Code_Ostad       = oEditDTO.Code_Ostad;
                            oChange.ControlId        = chbkCooperation.ID;
                            oChange.ControlToFieldId = 42;//in Tbl_TextBoxToSidaField chbkCooperation
                            oChange.NewValue         = NewCooperation.ToString();
                            oChange.OldValue         = OldCoopertaion.ToString();
                            oEditDTO.ChangeList.Add(oChange);

                            isChanged = true;
                        }
                    }
                }
                else
                {
                    string msg = "به دلیل  نقص اطلاعات شما، امکان ثبت در سامانه آموزش جهت تدریس وجود ندارد، لطفا ابتدا " + errorMsg + " خود را تکمیل فرمائید..";
                    showMessage(msg, true);
                    return;
                }

                //var dNewValue = string.Join(",", chbkDaneshkade.Items.Cast<ListItem>().Where(li => li.Selected).Select(li => li.Value).ToList());
                //string dOldValue = ViewState["idDanesh"].ToString();
                //if (dNewValue != dOldValue)
                //{
                //    ChangedInfoDTO dChange = new ChangedInfoDTO();
                //    dChange.Code_Ostad = oEditDTO.Code_Ostad;
                //    dChange.ControlId = chbkDaneshkade.ID;
                //    dChange.ControlToFieldId = 53;
                //    dChange.NewValue = dNewValue;
                //    dChange.OldValue = dOldValue;
                //    oEditDTO.ChangeList.Add(dChange);

                //    isChanged = true;
                //}

                var    gNewValue = string.Join(",", chbkGroup.Items.Cast <ListItem>().Where(li => li.Selected).Select(li => li.Value).ToList());
                string gOldValue = ViewState["idGroup"].ToString();
                if (gNewValue != gOldValue)
                {
                    ChangedInfoDTO gChange = new ChangedInfoDTO();
                    gChange.Code_Ostad       = oEditDTO.Code_Ostad;
                    gChange.ControlId        = chbkGroup.ID;
                    gChange.ControlToFieldId = 54;
                    gChange.NewValue         = gNewValue;
                    gChange.OldValue         = gOldValue;
                    oEditDTO.ChangeList.Add(gChange);

                    isChanged = true;
                }

                if (isChanged)
                {
                    int    Id  = ProfReqBuss.AddNewEditRequest(oEditDTO);
                    string msg = null;
                    if (Id > 0)
                    {
                        CB.InsertIntoStudentLog(oEditDTO.HR_InfoPeople_Id.ToString(), DateTime.Now.ToString("HH:mm"), 13, 36, Id.ToString());
                        msg = "درخواست شما با شماره " + Id.ToString() + "با موفقیت ثبت گردید.";
                        Session["hrInfoPeopleId"] = null;
                    }
                    else
                    {
                        msg = "خطا در هنگام ثبت درخواست ، لطفا مجددا تلاش کنید.";
                    }

                    showMessage(msg, true);
                }
            }
            else if (!string.IsNullOrEmpty(errorMsg))
            {
                showMessage(errorMsg);
            }
        }
        protected void btnSubmitChanges_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                string msg = "";
                if (!isInformationValid())
                {
                    return;
                }
                if (ProfReqBuss.HasPendingRequest(Convert.ToInt32(Session[sessionNames.userID_StudentOstad]), (int)RequestTypeId.EditContactInfo))
                {
                    msg = "شما به دلیل وجود درخواست تایید نشده از این نوع درخواست نمی توانید درخواست جدید ثبت کنید.";
                    RadWindowManager1.RadAlert(msg, 400, 200, "پیام سیستم", "RedirectToMain");
                    return;
                }
                List <ChangedInfoDTO> oFullChangeList = (List <ChangedInfoDTO>)ViewState["ChangeList"];
                foreach (Control item in dvAddressFileds.Controls)
                {
                    if (item is TextBox)
                    {
                        TextBox        txt    = (TextBox)item;
                        ChangedInfoDTO result = oFullChangeList.Find(i => i.ControlId == txt.ID);
                        if (result.OldValue != txt.Text)
                        {
                            result.NewValue = txt.Text;
                            result.State    = FieldChangeState.Submitted;
                        }
                    }
                }

                ChangedInfoDTO resultDrp;
                resultDrp = oFullChangeList.Find(i => i.ControlId == drpLivingCity.ID + "value");

                if (resultDrp?.OldValue != drpLivingCity.SelectedValue && drpLivingCity.SelectedItem.Value != "0")
                {
                    resultDrp.NewValue = drpLivingCity.SelectedValue;
                    resultDrp.State    = FieldChangeState.Submitted;
                }

                //------------------------------
                resultDrp = oFullChangeList.Find(i => i.ControlId == drpProvince1.ID + "value");

                if (resultDrp?.OldValue != drpProvince1.SelectedValue && drpProvince1.SelectedItem.Value != "0")
                {
                    resultDrp.NewValue = drpProvince1.SelectedValue;
                    resultDrp.State    = FieldChangeState.Submitted;
                }

                //------------------------------

                resultDrp = oFullChangeList.Find(i => i.ControlId == drpProvince2.ID + "value");

                if (resultDrp?.OldValue != drpProvince2.SelectedValue && drpProvince2.SelectedItem.Value != "0")
                {
                    resultDrp.NewValue = drpProvince2.SelectedValue;
                    resultDrp.State    = FieldChangeState.Submitted;
                }
                //------------------------------

                resultDrp = oFullChangeList.Find(i => i.ControlId == drpWorkingCity.ID + "value");

                if (resultDrp?.OldValue != drpWorkingCity.SelectedValue && drpWorkingCity.SelectedItem.Value != "0")
                {
                    resultDrp.NewValue = drpWorkingCity.SelectedValue;
                    resultDrp.State    = FieldChangeState.Submitted;
                }

                //------------------------------

                ProfessorEditRequestDTO oEditDTO = new ProfessorEditRequestDTO();
                oEditDTO.Code_Ostad       = Convert.ToInt32(Session[sessionNames.userID_StudentOstad]);
                oEditDTO.Createdate       = DateTime.Now.ToPeString();
                oEditDTO.RequestTypeID    = (int)RequestTypeId.EditContactInfo; // درخواست ویرایش اطلاعات تماس
                oEditDTO.RequestLogID     = (int)RequestLogId.submitted;        // در حال بررسی
                oEditDTO.HR_InfoPeople_Id = Convert.ToInt32(Session["hrInfoPeopleId"]);
                oEditDTO.ChangeSet        = 1;
                oEditDTO.ChangeList       = new List <ChangedInfoDTO>();
                foreach (ChangedInfoDTO item in oFullChangeList)
                {
                    if (!string.IsNullOrWhiteSpace(item.NewValue) && item.NewValue != item.OldValue)
                    {
                        item.State = FieldChangeState.Submitted;
                        oEditDTO.ChangeList.Add(item);
                    }
                }
                if (oEditDTO.ChangeList.Count == 0)
                {
                    msg = "شما هیچ تغییری در این بخش به وجود نیاورده اید.";
                    RadWindowManager1.RadAlert(msg, 400, 100, "پیام سیستم", "");
                    return;
                }
                int Id = ProfReqBuss.AddNewEditRequest(oEditDTO);
                msg = null;
                if (Id > 0)
                {
                    CB.InsertIntoStudentLog(oEditDTO.HR_InfoPeople_Id.ToString(), DateTime.Now.ToString("HH:mm"), 13, 32, Id.ToString());
                    msg = "درخواست شما با شماره " + Id.ToString() + "با موفقیت ثبت گردید.";
                    Session["hrInfoPeopleId"] = null;
                }
                else
                {
                    msg = "خطا در هنگام ثبت درخواست ، لطفا مجددا تلاش کنید.";
                }

                RadWindowManager1.RadAlert(msg, 400, 100, "پیام سیستم", "RedirectToMain");
            }
        }
Пример #4
0
        private void getScansAreNotInDB()
        {
            int       hrId   = Convert.ToInt32(Session["hrInfoPeopleId"]);
            DataTable dtScan = FRB.GetRequestScanDocID(hrId);

            if (dtScan.Rows.Count > 0 && dtScan.Select("status=1").Length > 0)
            {
                dtScan = dtScan.Select("status=1").CopyToDataTable();
            }
            else
            {
                dtScan.Clear();
            }
            ChangedInfoDTO cid = new ChangedInfoDTO();

            ViewState[listOfRequiredScans] = "";
            if (dtScan.Rows.Count > 0)
            {
                if (dtScan.Select("doc_type=" + 1).Length == 0)
                {
                    ViewState[listOfRequiredScans] = "49,";
                    enableScan(49);
                }
                if (dtScan.Select("doc_type=" + 4).Length == 0)
                {
                    ViewState[listOfRequiredScans] += "7,";
                    enableScan(7);
                }
                if (dtScan.Select("doc_type=" + 6).Length == 0)
                {
                    cid = ChangeList.Where(i => i.ControlToFieldId == 43).First();
                    if (cid.OldValue == "1")
                    {
                        ViewState[listOfRequiredScans] += "40,";
                        enableScan(40);
                    }
                }
                if (dtScan.Select("doc_type=" + 7).Length == 0)
                {
                    cid = ChangeList.Where(i => i.ControlToFieldId == 53).First();
                    if (cid.OldValue == "1")
                    {
                        cid = ChangeList.Where(i => i.ControlToFieldId == 30).First();
                        if (Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.برگ_اعزام &&
                            Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.مشمول &&
                            Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.درحين_خدمت &&
                            Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.غير_مشمول)
                        {
                            ViewState[listOfRequiredScans] += "30,";
                            enableScan(30);
                        }
                    }
                }
                if (dtScan.Select("doc_type=" + 14).Length == 0)
                {
                    cid = ChangeList.Where(i => i.ControlToFieldId == 15).First();
                    if (cid.OldValue != "27" && cid.OldValue != "")
                    {
                        ViewState[listOfRequiredScans] += "15,";
                        enableScan(15);
                    }
                }
                if (dtScan.Select("doc_type=" + 18).Length == 0)
                {
                    cid = ChangeList.Where(i => i.ControlToFieldId == 44).First();
                    if (cid.OldValue == "True")
                    {
                        ViewState[listOfRequiredScans] += "44,";
                        enableScan(44);
                    }
                }
                if (dtScan.Select("doc_type=" + 10).Length == 0)
                {
                    ViewState[listOfRequiredScans] += "1000,";
                    enableScan(1000);
                }
                if (dtScan.Select("doc_type=" + 5).Length == 0)
                {
                    ViewState[listOfRequiredScans] += "500";
                    enableScan(500);
                }
            }
            else
            {
                enableScan(49);
                enableScan(7);
                enableScan(1000);
                enableScan(500);

                ViewState[listOfRequiredScans] = "49,7,";
                if (lbloptionalPersonelly.Visible)
                {
                    ViewState[listOfRequiredScans] += "1000,";
                }
                if (lblOptionalMelli.Visible)
                {
                    ViewState[listOfRequiredScans] += "500,";
                }
                cid = ChangeList.Where(i => i.ControlToFieldId == 43).First();
                if (cid.OldValue != null)
                {
                    if (cid.OldValue != "0")
                    {
                        enableScan(40);
                        ViewState[listOfRequiredScans] += "40,";
                    }
                }
                cid = ChangeList.Where(i => i.ControlToFieldId == 53).First();
                if (cid.OldValue == "1")
                {
                    cid = ChangeList.Where(i => i.ControlToFieldId == 30).First();
                    if (Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.برگ_اعزام &&
                        Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.مشمول &&
                        Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.درحين_خدمت &&
                        Convert.ToInt32(cid.OldValue) != (int)Hire.Hire.militaryStatus.غير_مشمول)
                    {
                        ViewState[listOfRequiredScans] += "30,";
                        enableScan(30);
                    }
                }
                cid = ChangeList.Where(i => i.ControlToFieldId == 15).First();
                if (cid.OldValue != "27" && cid.OldValue != "")
                {
                    ViewState[listOfRequiredScans] += "15,";
                    enableScan(15);
                }
                cid = ChangeList.Where(i => i.ControlToFieldId == 44).First();
                if (cid.OldValue == "True")
                {
                    ViewState[listOfRequiredScans] += "44";
                    enableScan(44);
                }
            }
        }