Esempio n. 1
0
        /// <summary>
        /// Called when an Agreement is being added
        /// </summary>
        /// <param name="sender">The grid that is sending the insert command</param>
        /// <param name="e">The Command Event Arguments</param>
        protected void rgAgreements_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordAdded, "Agreement", "Agreement Added");

            metric.SubmitChanges();
            //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);
            //Create a new Agreement object
            var agreement = new Agreement();
            //Create a new mod object
            var mod = new AgreementMod();

            //Assign the values from the user control
            GrabValuesFromUserControl(userControl, ref agreement, ref mod);
            //Set Agreement End date equal to that from the mod 0
            agreement.EndDate = mod.EndDate;
            //Add the mod to the agreement
            agreement.AgreementMods.Add(mod);
            //Add the Agreement to the Customer
            customer.Agreements.Add(agreement);
            //Add the agreement to the agreements table
            siftaDB.Agreements.InsertOnSubmit(agreement);
            //Submit changes to the database
            siftaDB.SubmitChanges();
            //Update Records with Unique Record ID's
            RecordIdentifiers.UpdateRecords();
        }
Esempio n. 2
0
        public static string RecordIdentifier(this AgreementMod am)
        {
            SiftaDBDataContext siftaDB = new SiftaDBDataContext();
            string             id;

            do
            {
                id = String.Format("SIFTA-{0}M{1}", am.AgreementModID, RandomNumbers).Substring(0, RecordIDSize);
            } while (siftaDB.AgreementMods.FirstOrDefault(p => p.RecordID == id) != null);
            return(id);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     AgreementModID = Convert.ToInt32(Request.QueryString["AgreementModID"]);
     mod            = siftaDB.AgreementMods.FirstOrDefault(p => p.AgreementModID == AgreementModID);
     if (mod == null)
     {
         Response.Redirect("closePage.html");
     }
     agreement = mod.Agreement;
     BindAgreementLogInformation();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Grab the AgreementID from the URL
            AgreementID = Convert.ToInt32(Request.QueryString["AgreementID"]);
            var agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID);

            mod = siftaDB.AgreementMods.FirstOrDefault(p => p.AgreementID == AgreementID);
            if (rcbType.Items.Count <= 1)
            {
                //Set the Types to be the Look up table of research codes
                rcbType.DataSource = siftaDB.lutResearchCodes.OrderBy(p => p.Description);
            }
            //Insert
            if (DataItem is GridInsertionObject)
            {
                //Set research to be a new instance of studies funding
                research = new vStudiesFundingInformation();
                //Bind the data for the Comboboxes
                BindComboBoxes();
                //Set the Mod to be the most recent mod
                rcbMod.SelectedIndex = rcbMod.Items.Count - 1;
                //Show the Insert Button
                btnInsert.Visible = true;
                var customer = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID.ToString() == Request.QueryString["AgreementID"]).Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSCMFFunding.ReadOnly  = true;
                    rntbUSGSCMFFunding.BackColor = System.Drawing.Color.LightGray;
                }
            }
            //Update
            else if (DataItem != null && DataItem.GetType() == typeof(vStudiesFundingInformation))
            {
                //Cast the DataItem as a StudiesFunding item and set research to be that item
                research = (vStudiesFundingInformation)DataItem;
                //Bind the Data for the Comboboxes
                BindComboBoxes();
                //Set the Mod to be that from the Dataitem we are editing
                rcbMod.SelectedValue = research.AgreementModID.ToString();
                //Set the Type Combo Box to be that from the DataItem we are editing
                rcbType.SelectedValue = research.ResearchCodeID.ToString();
                //Show the update button
                btnUpdate.Visible = true;
                var customer = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID.ToString() == Request.QueryString["AgreementID"]).Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSCMFFunding.ReadOnly  = true;
                    rntbUSGSCMFFunding.BackColor = System.Drawing.Color.LightGray;
                }
            }
        }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Insert
     if (DataItem is GridInsertionObject)
     {
         //Set agreement variable to a new Agreement object
         agreement = new Agreement();
         //Set the mod to a new AgreementMod object
         mod = new AgreementMod();
         //Show the Insert Button
         btnInsert.Visible = true;
         var customer = siftaDB.Customers.FirstOrDefault(p => p.CustomerID.ToString() == Request.QueryString["CustomerID"]);
         //Check to see if it is a JFA 1=JFA
         if (customer.CustomerAgreementTypeID == 1)
         {
             rntbUSGSFunding.ReadOnly  = true;
             rntbUSGSFunding.BackColor = System.Drawing.Color.LightGray;
         }
         AddItemsToAT();
     }
     //Update
     else if (DataItem != null && DataItem.GetType() == typeof(vAgreementInformation))
     {
         //Show the Update Button
         btnUpdate.Visible = true;
         //Cast dataitem as a vAgreementInformation
         var a = DataItem as vAgreementInformation;
         //Grab the agreement matching the ID passed in the dataitem
         agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == a.AgreementID);
         //Set mod to be the Mod 0 for this agreement
         mod = agreement.AgreementMods.FirstOrDefault(p => p.Number == 0);
         //Set Funds Type ComboBox to agreement funds type
         rcbFundsType.SelectedValue = agreement.FundsType;
         //Set Billing Cycle Frequency ComboBox to agreement billing cycle frequency
         rcbBillingCycle.SelectedValue = agreement.BillingCycleFrequency;
         var customer = siftaDB.Customers.FirstOrDefault(p => p.CustomerID.ToString() == Request.QueryString["CustomerID"]);
         //Check to see if it is a JFA 1=JFA
         if (customer.CustomerAgreementTypeID == 1)
         {
             rntbUSGSFunding.ReadOnly  = true;
             rntbUSGSFunding.BackColor = System.Drawing.Color.LightGray;
         }
         AddItemsToAT();
         rcbAType.SelectedValue = agreement.Customer2Group;
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Takes a user control and maps the values from it to an Agreement and Mod object.
        /// The user control being used is the Agreement.ascx.
        /// Found at Controls/Agreement.ascx
        /// </summary>
        /// <param name="uc">The User Control for editing agreement information</param>
        /// <param name="a">The Agreement Object</param>
        /// <param name="m">The Agreement Mod Object</param>
        private void GrabValuesFromUserControl(UserControl uc, ref Agreement a, ref AgreementMod m)
        {
            #region User Controls
            //Grab the controls from the user controls
            var rtbPurchaseOrderNumber = (uc.FindControl("rtbPurchaseOrderNumber") as RadTextBox);
            var rtbSalesDocument       = (uc.FindControl("rtbSalesDocument") as RadTextBox);
            var rdpStartDate           = (uc.FindControl("rdpStartDate") as RadDatePicker);
            var rdpEndDate             = (uc.FindControl("rdpEndDate") as RadDatePicker);
            var rdpCustomerSigned      = (uc.FindControl("rdpCustomerSigned") as RadDatePicker);
            var rdpUSGSSigned          = (uc.FindControl("rdpUSGSSigned") as RadDatePicker);
            var rcbFundsType           = (uc.FindControl("rcbFundsType") as RadComboBox);

            var rcbAType = (uc.FindControl("rcbAType") as RadComboBox);

            var rcbBillingCycle       = (uc.FindControl("rcbBillingCycle") as RadComboBox);
            var rntbCustomerFunding   = (uc.FindControl("rntbCustomerFunding") as RadNumericTextBox);
            var rntbOtherFunding      = (uc.FindControl("rntbOtherFunding") as RadNumericTextBox);
            var rntbUSGSFunding       = (uc.FindControl("rntbUSGSFunding") as RadNumericTextBox);
            var rtbOtherFundingReason = (uc.FindControl("rtbOtherFundingReason") as RadTextBox);
            //Removed 11/4/2014 for to remove tags var racbTags = (uc.FindControl("racbTags") as RadAutoCompleteBox);
            #endregion

            #region Assign Values
            //Agreement Info
            a.BillingCycleFrequency = rcbBillingCycle.SelectedValue;
            a.FundsType             = rcbFundsType.SelectedValue;
            a.SalesDocument         = rtbSalesDocument.Text;
            a.PurchaseOrderNumber   = rtbPurchaseOrderNumber.Text;
            a.Customer2Group        = rcbAType.SelectedValue;
            //Mod Info
            a.StartDate = m.StartDate = rdpStartDate.SelectedDate;
            a.EndDate   = m.EndDate = rdpEndDate.SelectedDate;
            //Check to see if the usgs sign date has changed and it isn't null
            if (m.SignUSGSDate != rdpUSGSSigned.SelectedDate && rdpUSGSSigned.SelectedDate != null)
            {
                //Create USGS Signed Log
                var log = new AgreementModLog()
                {
                    AgreementLogTypeID = 6,
                    CreatedBy          = user.ID,
                    ModifiedBy         = user.ID,
                    CreatedDate        = DateTime.Now,
                    ModifiedDate       = DateTime.Now,
                    LoggedDate         = Convert.ToDateTime(rdpUSGSSigned.SelectedDate),
                    Remarks            = "Auto generated from changing or adding a USGS Sign date to the agreement or agreement mod."
                };
                m.AgreementModLogs.Add(log);
            }
            m.SignUSGSDate     = rdpUSGSSigned.SelectedDate;
            m.SignCustomerDate = rdpCustomerSigned.SelectedDate;
            m.FundingUSGSCMF   = rntbUSGSFunding.Value;
            m.FundingCustomer  = rntbCustomerFunding.Value;
            m.FundingOther     = rntbOtherFunding.Value;
            a.ModifiedBy       = m.ModifiedBy = user.ID;
            if (m.CreatedDate == null || a.CreatedDate == null)
            {
                //Set all of the created dates to be the current one
                a.CreatedDate = a.ModifiedDate = m.CreatedDate = m.ModifiedDate = DateTime.Now;
            }
            else
            {
                //Set modified fields for tracking purposes
                a.ModifiedDate = m.ModifiedDate = DateTime.Now;
                a.ModifiedBy   = m.ModifiedBy = user.ID;
            }
            #endregion
        }
Esempio n. 7
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();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            AddAgTypeToComboBox();

            //Insert
            if (DataItem is GridInsertionObject)
            {
                rcbFundsTypeDiv.Visible = false;

                var AgreementID = Convert.ToInt32(Request.QueryString["AgreementID"]);
                agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID);
                //create a new AgreementMod
                mod = new AgreementMod();
                //Show the Insert Button
                btnInsert.Visible = true;
                BindComboBoxes();
                GrayOutAgreementSections();
                var customer = agreement.Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSFunding.ReadOnly  = true;
                    rntbUSGSFunding.BackColor = System.Drawing.Color.LightGray;
                }
            }
            //Update
            else if (DataItem != null && DataItem.GetType() == typeof(vAgreementModInformation))
            {
                //grab the agreement mod information
                var agreementMod = (vAgreementModInformation)DataItem;
                //Grab the mod ID for the mod being edited
                mod = siftaDB.AgreementMods.FirstOrDefault(p => p.AgreementModID == agreementMod.AgreementModID);
                //Grab the agreement information from the agreement tied to the mod
                agreement = mod.Agreement;
                //Show the Update Button
                btnUpdate.Visible = true;
                BindComboBoxes();
                //If it isn't the original Agreement Gray Out the Sections they can't edit
                if (mod.Number != 0)
                {
                    GrayOutAgreementSections();
                }
                var customer = agreement.Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSFunding.ReadOnly  = true;
                    rntbUSGSFunding.BackColor = System.Drawing.Color.LightGray;
                }

                rdpStartDate.SelectedDate = mod.StartDate;
                if (mod.StartDate != null)
                {
                    rdpEndDate.MinDate = Convert.ToDateTime(mod.StartDate);
                }

                if (mod.EndDate > mod.StartDate)
                {
                    rdpEndDate.SelectedDate = mod.EndDate;
                }

                if (mod.Number == 0)
                {
                    var c2g = agreement.Customer2Group;
                    if (c2g == "#")
                    {
                        rcbAgType.SelectedIndex = 0;
                    }
                    else
                    {
                        rcbAgType.SelectedValue = c2g;
                    }
                }
                else
                {
                    rcbFundsTypeDiv.Visible = false;
                }

                if (mod.SignUSGSDate != null)
                {
                    rdpUSGSSigned.SelectedDate = mod.SignUSGSDate;
                }
                if (mod.SignCustomerDate != null)
                {
                    rdpCustomerSigned.SelectedDate = mod.SignCustomerDate;
                }
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Grab the AgreementID from the URL
            AgreementID = Convert.ToInt32(Request.QueryString["AgreementID"]);
            var agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID);

            mod = siftaDB.AgreementMods.FirstOrDefault(p => p.AgreementID == AgreementID);
            //Insert
            if (DataItem is GridInsertionObject)
            {
                //Set the site funding equal to a new site funding object
                siteFunding = new vSiteFundingInformation();
                //Make the insert button visible
                btnInsert.Visible = true;
                //Binds the Mod Numbers
                rcbModNumber_DataBind();
                //Set the index to be the most recent mod
                rcbMod.SelectedIndex = rcbMod.Items.Count() - 1;
                //Set the collection codes
                rcbCollectionCode_DataBind();
                var customer = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID).Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSCMFFunding.ReadOnly  = true;
                    rntbUSGSCMFFunding.BackColor = System.Drawing.Color.LightGray;
                }
            }
            //Update
            else if (DataItem != null && DataItem.GetType() == typeof(vSiteFundingInformation))
            {
                //Cast the DataItem as a SiteFunding Item and set siteFunding to be that item.
                siteFunding = (vSiteFundingInformation)DataItem;
                //Make the Update button visible
                btnUpdate.Visible = true;
                //Binds the Mod Numbers
                rcbModNumber_DataBind();
                //Set it to the mods default value
                rcbMod.SelectedValue = siteFunding.AgreementModID.ToString();
                //Get the Collection Code
                var code = siftaDB.lutCollectionCodes.FirstOrDefault(p => p.CollectionCodeID == siteFunding.CollectionCodeID);
                //Set the collection code category = to the one for the site
                rcbCollectionCodeCategory.SelectedValue = code.Category;
                //Databind the collection codes
                rcbCollectionCode_DataBind();
                //Set the selected value to be the one from the site funding
                if (rcbCollectionCode.Items.FirstOrDefault(p => p.Value == siteFunding.CollectionCodeID.ToString()) != null)
                {
                    //The selected value is in the list
                    rcbCollectionCode.SelectedValue = siteFunding.CollectionCodeID.ToString();
                }
                else
                {
                    //The selected value is an inactive collection code so it must be added to the list before a value is assigned
                    var cc   = siftaDB.lutCollectionCodes.FirstOrDefault(p => p.CollectionCodeID == siteFunding.CollectionCodeID);
                    var item = new RadComboBoxItem()
                    {
                        Value = siteFunding.CollectionCodeID.ToString(), Text = String.Format("{0} - {1}", cc.Code, cc.Description)
                    };
                    rcbCollectionCode.Items.Add(item);
                    rcbCollectionCode.SelectedValue = siteFunding.CollectionCodeID.ToString();
                }
                var customer = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID).Customer;
                //Check to see if it is a JFA 1=JFA
                if (agreement.Customer2Group != "23A")
                {
                    rntbUSGSCMFFunding.ReadOnly  = true;
                    rntbUSGSCMFFunding.BackColor = System.Drawing.Color.LightGray;
                }
            }
        }