public static void UpdateRecords()
        {
            var siftaDB = new SiftaDBDataContext();

            foreach (var agreement in siftaDB.Agreements.Where(p => p.RecordID == null))
            {
                agreement.RecordID = RecordIdentifier(agreement);
                siftaDB.SubmitChanges();
            }
            foreach (var mod in siftaDB.AgreementMods.Where(p => p.RecordID == null))
            {
                mod.RecordID = RecordIdentifier(mod);
                siftaDB.SubmitChanges();
            }
            foreach (var s in siftaDB.FundingSites.Where(p => p.RecordID == null))
            {
                s.RecordID = RecordIdentifier(s);
                siftaDB.SubmitChanges();
            }
            foreach (var s in siftaDB.FundingStudies.Where(p => p.RecordID == null))
            {
                s.RecordID = RecordIdentifier(s);
                siftaDB.SubmitChanges();
            }
        }
Exemple #2
0
        protected void rgReceiver_InsertCommand(object sender, GridCommandEventArgs e)
        {
            UpdateDifferences();

            //Cast the GridCommandEventArgs item as an editable item
            GridEditableItem editedItem = e.Item as GridEditableItem;
            //Find the user control used by that item save it as a UserControl
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            var         rec         = new AccountFundSource();

            GrabValuesFromUserControl(userControl, ref rec);

            try
            {
                int id = siftaDB.AccountFundSources.Max(p => p.AFSID);
                rec.AFSID = id + 1;
            }
            catch (Exception ex)
            {
                rec.AFSID = 0;
            }

            siftaDB.AccountFundSources.InsertOnSubmit(rec);
            siftaDB.SubmitChanges();
        }
Exemple #3
0
        protected void rgAgreementLog_InsertCommand(object sender, GridCommandEventArgs e)
        {
            //Cast the GridCommandEventArgs item as an editable item
            GridEditableItem editedItem = e.Item as GridEditableItem;
            //Find the user control used by that item save it as a UserControl
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            var         modLog      = new AgreementModLog();

            GrabValuesFromUserControl(userControl, ref modLog);
            siftaDB.AgreementModLogs.InsertOnSubmit(modLog);
            siftaDB.SubmitChanges();
        }
Exemple #4
0
        public static void Delete(this Customer _customer, bool StoreValues = false)
        {
            var siftaDB = new SiftaDBDataContext();

            if (StoreValues)
            {
                var address             = String.Format("http://sifta.water.usgs.gov/Services/REST/Customer/CustomerInformation.ashx?CustomerID={0}&AllRecords=true", _customer.CustomerID);
                System.Net.WebClient wc = new System.Net.WebClient();
                var xml = wc.DownloadString(address);
                siftaDB.Archives.InsertOnSubmit(new Archive()
                {
                    Type = "Customer", CreatedBy = new User().ID, CreatedOn = DateTime.Now, Data = xml
                });
            }
            var customer = siftaDB.Customers.FirstOrDefault(p => p.CustomerID == _customer.CustomerID);

            //Delete all Agreements
            foreach (var agreement in customer.Agreements)
            {
                //Delete the agreement
                Delete(agreement, false);
            }
            //Delete Contacts
            foreach (var contact in customer.CustomerContacts)
            {
                foreach (var address in contact.CustomerContactAddresses)
                {
                    siftaDB.CustomerContactAddresses.DeleteOnSubmit(address);
                }
                siftaDB.CustomerContacts.DeleteOnSubmit(contact);
            }
            siftaDB.Customers.DeleteOnSubmit(customer);
            siftaDB.SubmitChanges();
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var agreements     = siftaDB.Agreements.Where(p => p.RecordID == null);
            var mods           = siftaDB.AgreementMods.Where(p => p.RecordID == null);
            var siteFunding    = siftaDB.FundingSites.Where(p => p.RecordID == null);
            var studiesFunding = siftaDB.FundingStudies.Where(p => p.RecordID == null);

            ltlAgreement.Text      = agreements.Count().ToString();
            ltlMods.Text           = mods.Count().ToString();
            ltlSiteFunding.Text    = siteFunding.Count().ToString();
            ltlStudiesFunding.Text = studiesFunding.Count().ToString();
            foreach (var agreement in agreements)
            {
                agreement.RecordID = agreement.RecordIdentifier();
            }
            foreach (var mod in mods)
            {
                mod.RecordID = mod.RecordIdentifier();
            }
            foreach (var sf in siteFunding)
            {
                sf.RecordID = sf.RecordIdentifier();
            }
            foreach (var sf in studiesFunding)
            {
                sf.RecordID = sf.RecordIdentifier();
            }
            siftaDB.SubmitChanges();
        }
Exemple #6
0
        protected void rgCustomers_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            //Cast the GridCommandEventArgs item as an editable item
            GridEditableItem editedItem = e.Item as GridEditableItem;
            //Find the user control used by that item save it as a UserControl
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            //Grab the CustomerID of the customer you are editing from the edited item
            int CustomerID = Convert.ToInt32(editedItem.GetDataKeyValue("CustomerID"));
            //Add metrics
            var metric = new MetricHandler(center.OrgCode, null, null, MetricType.RecordUpdate, "Customer", String.Format("Updated CustomerID = {0}", CustomerID));

            metric.SubmitChanges();
            //Grabs the customer from the database with the matching ID
            var customer = siftaDB.Customers.FirstOrDefault(p => p.CustomerID == CustomerID);

            //Assigns the values from the user control to the customer
            GrabValuesFromUserControl(userControl, ref customer);
            //Submits the changes to the database
            siftaDB.SubmitChanges();
        }
        public static bool ValidEmployeeID(this string employeeID)
        {
            SiftaDBDataContext siftaDB = new SiftaDBDataContext();

            //Check to see if they aren't being tracked yet.
            if (siftaDB.Employees.FirstOrDefault(p => p.EmployeeID == employeeID) == null)
            {
                //Call the service for Active Directory
                var service = new ActiveDirectoryService();
                //Try to get the employee with the same id
                var employee = service.GetEmployee(employeeID);
                //Check to see that the employee is not null
                if (employee != null)
                {
                    var e = new Employee()
                    {
                        FirstName  = employee.FirstName,
                        MiddleName = employee.MiddleName,
                        LastName   = employee.LastName,
                        OrgCode    = employee.OrgCode,
                        EmployeeID = employee.EmployeeID,
                        StreetOne  = employee.StreetOne,
                        StreetTwo  = employee.StreetTwo,
                        City       = employee.City,
                        State      = employee.State,
                        ZipCode    = employee.ZipCode,
                        Department = employee.Department,
                        Email      = employee.Email,
                        Title      = employee.Title,
                        PhoneFax   = employee.PhoneFax,
                        PhoneWork  = employee.PhoneWork
                    };
                    siftaDB.Employees.InsertOnSubmit(e);
                    siftaDB.SubmitChanges();
                    return(true);
                }
                //Employee is not real return false
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Exemple #8
0
        public static void Delete(this Agreement agreement, bool StoreValues = false)
        {
            var siftaDB    = new SiftaDBDataContext();
            var _agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == agreement.AgreementID);

            if (StoreValues)
            {
                var address             = String.Format("http://sifta.water.usgs.gov/Services/REST/Agreement/AgreementInformation.ashx?AgreementID={0}", _agreement.AgreementID);
                System.Net.WebClient wc = new System.Net.WebClient();
                var xml = wc.DownloadString(address);
                siftaDB.Archives.InsertOnSubmit(new Archive()
                {
                    Type = "Agreement", CreatedBy = new User().ID, CreatedOn = DateTime.Now, Data = xml
                });
            }
            //Go through each mod in the agreement
            foreach (var mod in _agreement.AgreementMods)
            {
                //Delete all teh site funding
                foreach (var site in mod.FundingSites)
                {
                    siftaDB.FundingSites.DeleteOnSubmit(site);
                }
                //Delete all studies funding
                foreach (var study in mod.FundingStudies)
                {
                    siftaDB.FundingStudies.DeleteOnSubmit(study);
                }
                //Delete all logs
                foreach (var log in mod.AgreementModLogs)
                {
                    siftaDB.AgreementModLogs.DeleteOnSubmit(log);
                }
                //Delete all coop funding
                foreach (var coop in mod.CooperativeFundings)
                {
                    siftaDB.CooperativeFundings.DeleteOnSubmit(coop);
                }
                siftaDB.AgreementMods.DeleteOnSubmit(mod);
            }
            siftaDB.Agreements.DeleteOnSubmit(_agreement);
            siftaDB.SubmitChanges();
        }
 protected void rbSubmitAgreementLog_Click(object sender, EventArgs e)
 {
     try
     {
         if (rdtpAgreementLogTime.SelectedDate == null)
         {
             throw new ArgumentException("A Date Was Not Selected.");
         }
         var log = new AgreementModLog()
         {
             CreatedBy    = user.ID,
             ModifiedBy   = user.ID,
             CreatedDate  = DateTime.Now,
             ModifiedDate = DateTime.Now
         };
         log.LoggedDate = Convert.ToDateTime(rdtpAgreementLogTime.SelectedDate);
         log.Remarks    = rtbRemarksAgreementLog.Text;
         if (rcbActionAgreementLog.SelectedIndex != 0)
         {
             log.AgreementLogTypeID = Convert.ToInt32(rcbActionAgreementLog.SelectedValue);
         }
         else
         {
             throw new ArgumentException("An Action Was Not Selected.");
         }
         mod.AgreementModLogs.Add(log);
         siftaDB.SubmitChanges();
         pnlAgreementLog.Visible = false;
         pnlComplete.Visible     = true;
     }
     catch (Exception ex)
     {
         ltlError.Text           = ex.Message;
         pnlAgreementLog.Visible = false;
         pnlError.Visible        = true;
     }
 }
Exemple #10
0
        /// <summary>
        /// Called to copy an agreement 1 fiscal year ahead
        /// </summary>
        /// <param name="agreement">The agreement to be copied</param>
        protected void CopyAgreement(Agreement agreement)
        {
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordCopied, "Agreement", String.Format("Copied AgreemendID = {0}", agreement.AgreementID));

            metric.SubmitChanges();
            //Grabs Mod 0 for the Agreement (the original agreement information is what we are copying over)
            var mod = agreement.AgreementMods.FirstOrDefault(p => p.Number == 0);
            //Grabs the list of Site funding for the original mod
            var siteFunding = mod.FundingSites.ToList();
            //Grab all coop funding for mod 0;
            var coopFunding = mod.CooperativeFundings.ToList();
            //Grabs the list of studies funding for the original mod
            var studiesFunding = mod.FundingStudies.ToList();

            //Grab list of account fund sources
            var accFundSrc = siftaDB.AccountFundSources.Where(x => x.AgreementModID == mod.AgreementModID).ToList();


            //Create a new mod
            var copyMod = new AgreementMod();
            //Create a new Agreement and assign it values from the old one
            var copy = new Agreement()
            {
                BillingCycleFrequency = agreement.BillingCycleFrequency,
                PurchaseOrderNumber   = agreement.PurchaseOrderNumber + "_Copy",
                FundsType             = agreement.FundsType,
                Remarks = agreement.Remarks,
                CustomerBillingContact   = agreement.CustomerBillingContact,
                CustomerTechnicalContact = agreement.CustomerTechnicalContact,
                Customer2Group           = agreement.Customer2Group,
                USGSBillingContact       = agreement.USGSBillingContact,
                USGSTechnicalContact     = agreement.USGSTechnicalContact,
                CreatedBy    = user.ID,
                CreatedDate  = DateTime.Now,
                ModifiedBy   = user.ID,
                ModifiedDate = DateTime.Now
            };

            //The Start date needs to be pushed up a year if it isn't null
            if (mod.StartDate != null)
            {
                //Set the start date for the agreement to 1 year after the previous agreements start date
                copy.StartDate = Convert.ToDateTime(mod.StartDate).AddYears(1);
            }
            else
            {
                copy.StartDate = null;
            }
            //The End date needs to be pushed up a year if it isn't null
            if (mod.EndDate != null)
            {
                //Set the end date for the agreement to 1 year after the previous agreements end date
                copy.EndDate = Convert.ToDateTime(mod.EndDate).AddYears(1);
            }
            else
            {
                copy.EndDate = null;
            }
            //Set the Mods Start and End Date to be the one from the copied Agreement
            copyMod.StartDate = copy.StartDate;
            copyMod.EndDate   = copy.EndDate;

            //Assign values from old mod to new mod
            copyMod.FundingUSGSCMF     = mod.FundingUSGSCMF;
            copyMod.FundingCustomer    = mod.FundingCustomer;
            copyMod.FundingOther       = mod.FundingOther;
            copyMod.FundingOtherReason = mod.FundingOtherReason;
            copyMod.Number             = 0;
            copyMod.Remarks            = mod.Remarks;
            copyMod.CreatedBy          = copyMod.ModifiedBy = user.ID;
            copyMod.CreatedDate        = copyMod.ModifiedDate = DateTime.Now;

            //Add Site Funding to copy mod
            foreach (var siteF in siteFunding)
            {
                copyMod.FundingSites.Add(new FundingSite()
                {
                    AgencyCode             = siteF.AgencyCode,
                    CollectionCodeID       = siteF.CollectionCodeID,
                    DifficultyFactor       = siteF.DifficultyFactor,
                    DifficultyFactorReason = siteF.DifficultyFactorReason,
                    FundingCustomer        = siteF.FundingCustomer,
                    FundingUSGSCMF         = siteF.FundingUSGSCMF,
                    CollectionUnits        = siteF.CollectionUnits,
                    SiteNumber             = siteF.SiteNumber,
                    StartDate    = siteF.StartDate?.AddYears(1),
                    EndDate      = siteF.EndDate?.AddYears(1),
                    Remarks      = siteF.Remarks,
                    CreatedBy    = user.ID,
                    CreatedDate  = DateTime.Now,
                    ModifiedBy   = user.ID,
                    ModifiedDate = DateTime.Now
                });
            }
            //Add Studies Funding to the copyMod
            foreach (var studiesF in studiesFunding)
            {
                copyMod.FundingStudies.Add(new FundingStudy()
                {
                    BasisProjectNumber = studiesF.BasisProjectNumber,
                    ResearchCodeID     = studiesF.ResearchCodeID,
                    Units           = studiesF.Units,
                    Remarks         = studiesF.Remarks,
                    FundingCustomer = studiesF.FundingCustomer,
                    FundingUSGSCMF  = studiesF.FundingUSGSCMF,
                    StartDate       = studiesF.StartDate?.AddYears(1),
                    EndDate         = studiesF.EndDate?.AddYears(1),
                    CreatedBy       = user.ID,
                    CreatedDate     = DateTime.Now,
                    ModifiedBy      = user.ID,
                    ModifiedDate    = DateTime.Now
                });
            }

            //Add Copied Mod to the copied agreement
            copy.AgreementMods.Add(copyMod);
            //Add copied agreement to the customer
            customer.Agreements.Add(copy);
            //Submit changes to the database
            siftaDB.SubmitChanges();
            //Add the cooperative funding to the new agreement mod
            foreach (var cfunding in coopFunding)
            {
                copyMod.CooperativeFundings.Add(new CooperativeFunding()
                {
                    AccountNumber   = cfunding.AccountNumber,
                    AgreementID     = copy.AgreementID,
                    CreatedBy       = user.ID,
                    CreatedDate     = DateTime.Now,
                    ModifiedBy      = user.ID,
                    ModifiedDate    = DateTime.Now,
                    Remarks         = cfunding.Remarks,
                    Status          = "LOW",
                    ModNumber       = cfunding.ModNumber,
                    FiscalYear      = Convert.ToInt32(cfunding.FiscalYear) + 1,
                    FundingCustomer = cfunding.FundingCustomer,
                    FundingUSGSCMF  = cfunding.FundingUSGSCMF
                });
            }
            siftaDB.SubmitChanges();

            foreach (var accFund in accFundSrc)
            {
                var newFund = new AccountFundSource();
                newFund.AgreementModID     = copyMod.AgreementModID;
                newFund.FundSourceFY       = accFund.FundSourceFY + 1;
                newFund.AccountNumber      = accFund.AccountNumber;
                newFund.CustomerClass      = accFund.CustomerClass;
                newFund.MatchPair          = accFund.MatchPair;
                newFund.ProgramElementCode = accFund.ProgramElementCode;
                newFund.Funding            = accFund.Funding;
                newFund.FundStatus         = "LOW";
                newFund.Remarks            = accFund.Remarks;
                newFund.CreatedBy          = user.ID;
                newFund.CreatedDate        = DateTime.Now;
                newFund.ModifiedBy         = user.ID;
                newFund.ModifiedDate       = DateTime.Now;

                siftaDB.AccountFundSources.InsertOnSubmit(newFund);
            }
            siftaDB.SubmitChanges();

            //Update Records with Unique Record ID's
            RecordIdentifiers.UpdateRecords();
            //Rebind the agreement grid
            rgAgreements.Rebind();
        }
Exemple #11
0
 protected void rbSubmitCenterInformation_Click(object sender, EventArgs e)
 {
     center.Address       = rtbAddress.Text;
     center.City          = rtbCity.Text;
     center.State         = rtbState.Text;
     center.ZipCode       = rtbZipCode.Text;
     center.DUNS          = rtbDUNS.Text;
     center.ProjectNumber = rtbProjectNumber.Text;
     center.ProjectName   = rtbProjectName.Text;
     siftaDB.SubmitChanges();
 }
Exemple #12
0
 public void SubmitChanges()
 {
     siftaDB.SubmitChanges();
 }