コード例 #1
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        /// <summary>
        /// Called when an Agreements is edited
        /// </summary>
        /// <param name="sender">The grid that is sending the update command</param>
        /// <param name="e">The Command Event Arguments</param>
        protected void rgAgreements_UpdateCommand(object sender, Telerik.Web.UI.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 AgreementID of the Agreement that was edited
            var AgreementID = Convert.ToInt32(editedItem.GetDataKeyValue("AgreementID").ToString());
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordUpdate, "Agreement", String.Format("Updated AgreementID = {0}", AgreementID));

            metric.SubmitChanges();
            //Grab the agreement from the database with the matching ID
            var agreement = siftaDB.Agreements.FirstOrDefault(p => p.AgreementID == AgreementID);
            //Grab Mod 0 associated with that agreement
            var mod = agreement.AgreementMods.FirstOrDefault(p => p.Number == 0);

            //Assign the values from the user control
            GrabValuesFromUserControl(userControl, ref agreement, ref mod);
            //Grab all mods that don't have a null end date
            var mods = agreement.AgreementMods.Where(p => p.EndDate != null).OrderByDescending(p => p.Number).ToList();

            //If a mod meets the criteria of having an end date grab the first one (highest mod number) and assign its end date to the agreement.
            if (mods.Count() != 0)
            {
                agreement.EndDate = mods.FirstOrDefault().EndDate;
            }
            //Submit Changes to the database
            siftaDB.SubmitChanges();
        }
コード例 #2
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        /// <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();
        }
コード例 #3
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            #region Assign Values
            customer.Code = rtbCustomerCd.Text;

            //If the combo box had a selected value convert it to int and store it as the customer agreement type. If not set the agreementtypeID to null
            if (!String.IsNullOrEmpty(rcbAgreementType.SelectedValue))
            {
                customer.CustomerAgreementTypeID = Convert.ToInt32(rcbAgreementType.SelectedValue);
            }
            else
            {
                customer.CustomerAgreementTypeID = null;
            }

            //Convert double to long to store in db
            customer.Number                  = Convert.ToInt64(rntbCustomerNo.Value);
            customer.Name                    = rtbCustomerName.Text;
            customer.Abbreviation            = rtbCustomerAbbrev.Text;
            customer.URL                     = rtbCustomerUrl.Text;
            customer.Remarks                 = rtbRemarks.Text;
            customer.TaxIdentificationNumber = rtbCustomerTin.Text;
            customer.ModifiedDate            = DateTime.Now;
            customer.ModifiedBy              = user.ID;
            #endregion

            #region Customer Image Upload
            //If a file was even uploaded
            if (rauImage.UploadedFiles.Count > 0)
            {
                foreach (UploadedFile file in rauImage.UploadedFiles)
                {
                    var dir = "D:\\siftaroot\\Temp\\";
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    var path = dir + file.FileName;
                    if (File.Exists(path))
                    {
                        customer.IconType = file.ContentType;
                        customer.Icon     = File.ReadAllBytes(path);
                        File.Delete(path);
                    }
                }
            }
            #endregion
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordUpdate, "Customer", String.Format("Updated CustomerID = {0}", CustomerID));
            metric.SubmitChanges();
            siftaDB.SubmitChanges();
            Response.Redirect(Request.Url.AbsoluteUri);
        }
コード例 #4
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        protected void rgCoopFunding_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            UserControl      userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            GridDataItem     parentItem  = (GridDataItem)e.Item.OwnerTableView.ParentItem;
            GridEditableItem editedItem  = (GridEditableItem)e.Item;
            var CooperativeFundingID     = Convert.ToInt32(editedItem.GetDataKeyValue("CooperativeFundingID"));
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordUpdate, "Cooperative Funding", String.Format("Updated CooperativeFundingID = {0}", CooperativeFundingID));

            metric.SubmitChanges();
            var cf = siftaDB.CooperativeFundings.FirstOrDefault(p => p.CooperativeFundingID == CooperativeFundingID);

            GrabCooperativeFundingValuesFromForm(ref cf, userControl);
            siftaDB.SubmitChanges();
        }
コード例 #5
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        protected void rgCoopFunding_InsertCommand(object sender, GridCommandEventArgs e)
        {
            //Add metrics
            var metric = new MetricHandler(customer.OrgCode, customer.CustomerID, null, MetricType.RecordAdded, "Cooperative Funding", "Cooperative Funding Added");

            metric.SubmitChanges();
            UserControl  userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            GridDataItem parentItem  = (GridDataItem)e.Item.OwnerTableView.ParentItem;
            var          AgreementID = Convert.ToInt32(parentItem.GetDataKeyValue("AgreementID"));
            var          cf          = new CooperativeFunding();

            GrabCooperativeFundingValuesFromForm(ref cf, userControl);
            cf.AgreementID = AgreementID;
            cf.CreatedBy   = user.ID;
            cf.CreatedDate = DateTime.Now;
            siftaDB.CooperativeFundings.InsertOnSubmit(cf);
            siftaDB.SubmitChanges();
        }
コード例 #6
0
ファイル: Center.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        protected void rgCustomers_InsertCommand(object sender, GridCommandEventArgs e)
        {
            //Add metrics
            var metric = new MetricHandler(center.OrgCode, null, null, MetricType.RecordAdded, "Customer", "Customer 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 customer
            var customer = new Customer();

            //Takes the user control and puts the values from the form into the customer object
            GrabValuesFromUserControl(userControl, ref customer);
            //Adds the customer to the current center
            siftaDB.Customers.InsertOnSubmit(customer);
            //Submits the changes to the database
            siftaDB.SubmitChanges();
        }
コード例 #7
0
ファイル: Center.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        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();
        }
コード例 #8
0
ファイル: Customer.aspx.cs プロジェクト: PatrickSearcey/SiFTA
        /// <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();
        }