Пример #1
0
        public int Add(Scholarship obj)
        {
            try
            {
                var nowYear = DateTime.Now.ToString("yy");

                var last = (from q in _db.Scholarships
                            where q.ScholarshipMasterNo.Substring(0, 2) == nowYear
                            orderby q.ScholarshipIndex descending
                            select q).FirstOrDefault();

                if (last == null)
                {
                    obj.ScholarshipIndex = 1;
                }
                else
                {
                    obj.ScholarshipIndex = last.ScholarshipIndex + 1;
                }

                obj.ScholarshipMasterNo = nowYear + '-' + new Random().Next(9999).ToString("D4") + '-' + obj.ScholarshipIndex.ToString("D6");
                obj.CreatedDate         = DateTime.Now;

                _db.Scholarships.InsertOnSubmit(obj);
                _db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(-1);
            }
            return(_db.Scholarships.Max(x => x.ScholarshipId));
        }
Пример #2
0
 public bool Update(Scholarship obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Пример #3
0
        //protected void LoadSite()
        //{
        //    var global = new CGlobal();

        //    RadComboBoxSite.DataSource = global.GetSiteId();
        //    RadComboBoxSite.DataTextField = "Name";
        //    RadComboBoxSite.DataValueField = "Value";
        //    RadComboBoxSite.DataBind();
        //    RadComboBoxSite.Items.Insert(0, new RadComboBoxItem("- Select Site - "));
        //}

        protected void StudentButtonClicked(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "TempSave":
            case "Request":
                var cScholarshipReg = new CScholarship();
                var scholarshipReg  = new Erp2016.Lib.Scholarship();
                // new
                if (Request["type"] == "0")
                {
                    scholarshipReg             = new Erp2016.Lib.Scholarship();
                    scholarshipReg.CreatedId   = CurrentUserId;
                    scholarshipReg.CreatedDate = DateTime.Now;
                }
                // modify
                else
                {
                    scholarshipReg = cScholarshipReg.Get(Id);
                }

                scholarshipReg.AgencyId = Convert.ToInt32(ddlAgencyName.SelectedValue);
                if (rbAmount.Checked)
                {
                    scholarshipReg.Amount = Convert.ToDecimal(RadNumericTextBoxAmount.Text == string.Empty ? "0" : RadNumericTextBoxAmount.Text);
                }
                if (rbWeeks.Checked)
                {
                    scholarshipReg.Weeks = Convert.ToInt32(tbWeeks.Text);
                }

                scholarshipReg.ExpireDate = Convert.ToDateTime(tbExpireDate.SelectedDate);
                scholarshipReg.MininumRegistrationWeeks = Convert.ToInt32(RadComboBoxMinimum.SelectedValue);
                scholarshipReg.Memo      = tbComment.Text;
                scholarshipReg.CreatedId = CurrentUserId;
                scholarshipReg.IsActive  = false;

                int scholarshipId;

                // new
                if (Request["type"] == "0")
                {
                    scholarshipReg.IsActive = false;
                    scholarshipId           = cScholarshipReg.Add(scholarshipReg);
                }
                // modify
                else
                {
                    scholarshipReg.UpdatedId   = CurrentUserId;
                    scholarshipReg.UpdatedDate = DateTime.Now;
                    cScholarshipReg.Update(scholarshipReg);

                    scholarshipId = scholarshipReg.ScholarshipId;
                }

                var cScholarshipSiteLocation = new CScholarshipSiteLocation();
                cScholarshipSiteLocation.DelScholarshipSiteLocation(scholarshipId);

                foreach (var siteLocation in RadComboBoxSiteLocation.CheckedItems)
                {
                    var scholarshipSiteLocation = new ScholarshipSiteLocation()
                    {
                        CreatedId      = CurrentUserId,
                        ScholarshipId  = scholarshipId,
                        SiteLocationId = Convert.ToInt32(siteLocation.Value),
                        CreatedDate    = DateTime.Now
                    };
                    cScholarshipSiteLocation.Add(scholarshipSiteLocation);
                }

                if (e.Item.Text == "TempSave")
                {
                    RunClientScript("Close();");
                }
                else
                {
                    var cApprovalHistory = new CApprovalHistory();
                    cApprovalHistory.DelApprovalHistory((int)CConstValue.Approval.Scholarship, scholarshipId);

                    var approval = new CApproval().ApproveRequstCreate((int)CConstValue.Approval.Scholarship, CurrentUserId, scholarshipId);
                    if (approval > 0)
                    {
                        var cScholar = new CScholarship();
                        var scholar  = cScholar.Get(scholarshipId);
                        scholar.ApprovalStatus = approval;
                        scholar.ApprovalId     = CurrentUserId;
                        scholar.ApprovalDate   = DateTime.Now;
                        cScholar.Update(scholar);

                        new CMail().SendMail(CConstValue.Approval.Scholarship, CConstValue.MailStatus.ToApproveUser, scholar.ScholarshipId, scholar.ScholarshipMasterNo, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    else
                    {
                        ShowMessage("error requesting");
                    }
                }
                break;

            case "Close":
                RunClientScript("Close();");
                break;
            }
        }