public Estimate CreateEstimate()
    {
        Estimate temp = new Estimate();
        DateTime? nullDate = null;

        temp.JobName = this.currentProspect.Id;

        var giggles = DAL.User.GetUserFromLogin(Page.User.Identity.Name);

        temp.Estimator = giggles.Id;
        temp.EstimateNumber = Estimate.GetNextEstimateNumberForJob(currentProspect.Id);
        temp.Received = DateTime.Now;
        temp.Priority = Estimate.GetNextPriority();
        temp.ReadyForEstimating = true;
        temp.Received = DateTime.Now;
        temp.CurrentStatus = DateTime.Now.ToString("d") + " - Received by Estimating.";
        temp.EstimateSent = false;
        temp.EstimateSentDate = nullDate;
        temp.EstimatesDirectory = currentProspect.DirectoryPathExec;
        temp.ProspectDirectory = currentProspect.DirectoryPath;

        temp.Save();

        DAL.User estimator = new DAL.User(temp.Estimator);

        EstimateTimeline tempStep = new EstimateTimeline();
        tempStep.EstimateID = temp.Id;
        tempStep.WorkflowStepID = 131;
        tempStep.StepX = 0;
        tempStep.ResponsibleUserID = temp.Estimator;
        tempStep.DateTimeStamp = DateTime.Now;
        tempStep.DisplayText = DateTime.Now.ToString("d") + " - Received by Estimating.  Assigned to " + estimator.Name;

        tempStep.Save();

        CreateEstNumberDir(temp.EstimateNumber);

        BindControls(Estimate.Filter.Active);

        return temp;
    }
    private void CreateProject()
    {
        Project proj = new Project();

        proj.ProjectLead = "Lead";

        proj.ProjectName = txtAddProjName.Text;
        proj.ProjectNumber = txtAddProjNumber.Text;
        proj.PMUserID = int.Parse(ddlAddProjMgr.SelectedItem.Value);
        proj.PMAssigned = ddlAddProjMgr.SelectedItem.Text;
        proj.Region = ddlProspectRegion.SelectedItem.Text;
        proj.SalespersonID = int.Parse(ddlSalesperson.SelectedItem.Value);
        proj.ProjectActivity = "Active";
        proj.Created = DateTime.Now;
        proj.CreatedBy = Utils.GetFormattedUserNameInternal(User.Identity.Name);
        proj.Updated = DateTime.Now;
        proj.UpdatedBy = Utils.GetFormattedUserNameInternal(User.Identity.Name);
        proj.DesignDraftsmanID = 128;
        proj.EngineeringConsultant = "Unassigned";
        proj.PhysicistID = 137;

        if (chkCreateExec.Checked)
            proj.DirectoryPathExec = CreateDir(Estimate.DirType.Exec);
        if (chkCreateProspect.Checked)
            proj.DirectoryPath = CreateDir(Estimate.DirType.Prospect);
        if (chkCreateOutlook.Checked)
            CreateOutlookFolder(proj.ProjectNumber + " - " + proj.ProjectName, "Not Sent");

        proj.Save();
        currentProspect = proj;

        Estimate temp = new Estimate();
        temp.JobName = proj.Id;
        var giggles = DAL.User.GetUserFromLogin(Page.User.Identity.Name);

        if(giggles != null)
            temp.Estimator = DAL.User.GetUserFromLogin(Page.User.Identity.Name).Id;

        temp.EstimateNumber = Estimate.GetNextEstimateNumberForJob(proj.Id);
        temp.Received = DateTime.Now;
        temp.Priority = 0;
        temp.CurrentStatus = DateTime.Now.ToString("d") + " - Added to Sales Queue.";
        temp.StepID = 135;
        temp.StatusID = 0;

        temp.Save();

        activeSalesQueueItem = temp;

        if (chkCreateExec.Checked)
        {
            temp.EstimatesDirectory = CreateDir(Estimate.DirType.EstimateNumber);
        }

        if (chkCreateProspect.Checked)
            temp.ProspectDirectory = proj.DirectoryPath;

        temp.Save();
        activeSalesQueueItem = temp;
    }
        public void Insert(int? Priority,int JobName,string EstimateNumber,bool ReadyForEstimating,DateTime? EstimateDate,string Contact,string ContactEmail,DateTime? Received,DateTime? BidDueDate,int? Estimator,string EstimatesDirectory,string ProspectDirectory,DateTime? ResponseRequestedBy,bool EstimateSent,DateTime? EstimateSentDate,decimal? EstimateTotal,decimal? DoorsTotal,decimal? InteriorsTotal,decimal? BunkerTotal,int StatusID,int StepID,string CurrentStatus,string DoorScope,string InteriorScope,string BunkerScope,string BunkerTitle,string DesignBasis,string LaborType,string PhysicsBasis,string BunkerClarifications,bool? Drawings,bool? Prospectus,bool? TxParameters,string EstimateDescription,int? SupplementalBlockCount,int? InteriorsQty)
        {
            Estimate item = new Estimate();

            item.Priority = Priority;

            item.JobName = JobName;

            item.EstimateNumber = EstimateNumber;

            item.ReadyForEstimating = ReadyForEstimating;

            item.EstimateDate = EstimateDate;

            item.Contact = Contact;

            item.ContactEmail = ContactEmail;

            item.Received = Received;

            item.BidDueDate = BidDueDate;

            item.Estimator = Estimator;

            item.EstimatesDirectory = EstimatesDirectory;

            item.ProspectDirectory = ProspectDirectory;

            item.ResponseRequestedBy = ResponseRequestedBy;

            item.EstimateSent = EstimateSent;

            item.EstimateSentDate = EstimateSentDate;

            item.EstimateTotal = EstimateTotal;

            item.DoorsTotal = DoorsTotal;

            item.InteriorsTotal = InteriorsTotal;

            item.BunkerTotal = BunkerTotal;

            item.StatusID = StatusID;

            item.StepID = StepID;

            item.CurrentStatus = CurrentStatus;

            item.DoorScope = DoorScope;

            item.InteriorScope = InteriorScope;

            item.BunkerScope = BunkerScope;

            item.BunkerTitle = BunkerTitle;

            item.DesignBasis = DesignBasis;

            item.LaborType = LaborType;

            item.PhysicsBasis = PhysicsBasis;

            item.BunkerClarifications = BunkerClarifications;

            item.Drawings = Drawings;

            item.Prospectus = Prospectus;

            item.TxParameters = TxParameters;

            item.EstimateDescription = EstimateDescription;

            item.SupplementalBlockCount = SupplementalBlockCount;

            item.InteriorsQty = InteriorsQty;

            item.Save(UserName);
        }