示例#1
0
 public bool Update(PackageProgram obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
示例#2
0
 public int Add(PackageProgram obj)
 {
     try
     {
         _db.PackagePrograms.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.PackagePrograms.Max(x => x.PackageProgramId));
 }
示例#3
0
        protected void mainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "TempSave":
            case "Request":
                if (IsValid)
                {
                    var cProgram = new CPackageProgram();
                    Erp2016.Lib.PackageProgram packageProgram1 = null;
                    // new
                    if (hfType.Value == "0")
                    {
                        packageProgram1             = new Erp2016.Lib.PackageProgram();
                        packageProgram1.CreatedId   = CurrentUserId;
                        packageProgram1.CreatedDate = DateTime.Now;
                    }
                    // modify
                    else
                    {
                        packageProgram1 = cProgram.GetPackageProgram(Convert.ToInt32(hfId.Value));
                    }

                    packageProgram1.ProgramId          = Convert.ToInt32(RadComboBoxProgram.SelectedValue);
                    packageProgram1.PackageProgramName = RadTextBoxPackageProgramName.Text;
                    packageProgram1.Description        = RadTextBoxDescription.Text;
                    packageProgram1.StartDate          = RadDatePickerStartDate.SelectedDate;
                    packageProgram1.EndDate            = RadDatePickerEndDate.SelectedDate;

                    int packageProgramId;

                    // new
                    if (hfType.Value == "0")
                    {
                        packageProgram1.IsActive = false;
                        packageProgramId         = cProgram.Add(packageProgram1);
                    }
                    // modify
                    else
                    {
                        packageProgram1.UpdatedId   = CurrentUserId;
                        packageProgram1.UpdatedDate = DateTime.Now;

                        //packageProgram.IsActive = btnToggleActive.Checked;
                        cProgram.Update(packageProgram1);

                        packageProgramId = packageProgram1.PackageProgramId;
                    }

                    var cPackageProgramSiteLocation = new CPackageProgramSiteLocation();
                    cPackageProgramSiteLocation.DelPackageProgramSiteLocation(packageProgramId);

                    foreach (var siteLocation in RadComboBoxSiteLocation.CheckedItems)
                    {
                        var packageProgramSiteLocation = new PackageProgramSiteLocation()
                        {
                            CreatedId        = CurrentUserId,
                            PackageProgramId = packageProgramId,
                            SiteLocationId   = Convert.ToInt32(siteLocation.Value),
                            CreatedDate      = DateTime.Now
                        };
                        cPackageProgramSiteLocation.Add(packageProgramSiteLocation);
                    }

                    FileDownloadList1.SaveFile(packageProgramId);

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

                        // approve request
                        var approval = new CApproval().ApproveRequstCreate((int)CConstValue.Approval.Package, CurrentUserId, packageProgramId);
                        if (approval > 0)
                        {
                            var cP             = new CPackageProgram();
                            var packageProgram = cP.GetPackageProgram(packageProgramId);
                            packageProgram.ApprovalStatus = approval;
                            packageProgram.ApprovalId     = CurrentUserId;
                            packageProgram.ApprovalDate   = DateTime.Now;
                            //packageProgram.ApprovalMemo = "";
                            cP.Update(packageProgram);

                            new CMail().SendMail(CConstValue.Approval.Package, CConstValue.MailStatus.ToApproveUser, packageProgram.PackageProgramId, string.Empty, CurrentUserId);

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

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