Example #1
0
 /* Author: Wenyu Zhang*/
 public void createLLd_ATS(LLD_ATS ats)
 {
     using (var context = new MockERKSDb())
     {
         context.LLD_ATS.Add(ats);
         context.SaveChanges();
     }
 }
Example #2
0
    //class TempOrg
    //{
    //    public int Organization_ID { get; set; }
    //    public string Organization_Name { get; set; }
    //    public string Phone { get; set; }
    //    public string Email { get; set; }
    //}

    protected void AddFile_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            List <Organization> orgs;

            using (var context = new MockERKSDb())
            {
                orgs = (from org in context.Organizations
                        where org.User_Name.Trim().Equals(User.Identity.Name.Trim(), StringComparison.InvariantCultureIgnoreCase)
                        select org).ToList();
            }

            MessageUserControl.TryRun(() =>
            {
                FileController sysmgr    = new FileController();
                Site_File newSiteFile    = new Site_File();
                newSiteFile.Organization = orgs.FirstOrDefault();
                int i;

                string userName   = Context.User.Identity.GetUserName();
                int orgainztionId = sysmgr.OrganizationId_get(userName);

                newSiteFile.Organization_ID = orgainztionId;
                if (int.TryParse(FileType.SelectedValue, out i))
                {
                    newSiteFile.Type_ID = i;
                }
                else
                {
                    newSiteFile.Type_ID = null;
                }

                if (int.TryParse(Category.SelectedValue, out i))
                {
                    newSiteFile.Category_ID = i;
                }
                else
                {
                    newSiteFile.Category_ID = null;
                }

                if (int.TryParse(SecurityClassification.SelectedValue, out i))
                {
                    newSiteFile.Security_Classification_ID = i;
                }
                else
                {
                    newSiteFile.Security_Classification_ID = null;
                }

                Operation newOperation = new Operation();

                if (sysmgr.checkExist(OperationName.Text) == false)
                {
                    newOperation.Operation_Name = OperationName.Text;
                    //if (int.TryParse(OperationID.Text, out i))
                    //    newSiteFile.Operation_ID = i;
                    //else
                    //    newSiteFile.Operation_ID = null;
                    sysmgr.createOperation(newOperation);
                }
                else
                {
                    newOperation             = sysmgr.findOperation(OperationName.Text);
                    newSiteFile.Operation_ID = newOperation.Operation_ID;
                }
                //newSiteFile.Operation.Operation_Name = OperationName.Text;
                newSiteFile.Operation_ID = newOperation.Operation_ID;

                //Organization newOrganization = new Organization();
                //newOrganization = sysmgr.getOrganzationById(orgainztionId);
                Site_Address newAddress       = new Site_Address();
                newAddress.Location           = Location.SelectedValue;
                newAddress.Address            = Address.Text;
                LLD_ATS newAts                = new LLD_ATS();
                newAts.Meridian_Number        = Meridian.SelectedValue;
                newAts.Range_Number           = Range.SelectedValue;
                newAts.Township_Number        = Township.SelectedValue;
                newAts.Section_Number         = Section.SelectedValue;
                newAts.Quarter_Section_Number = QuarterSection.SelectedValue;
                newAts.LSD         = LSD.SelectedValue;
                LLD_PBL newPbl     = new LLD_PBL();
                newPbl.Plan_Number = Plan.Text;



                if (Block.Text.Trim().Equals(""))
                {
                    newPbl.Block_Number = "<None>";
                }
                else
                {
                    newPbl.Block_Number = Block.Text;
                }

                if (Lot.Text.Trim().Equals(""))
                {
                    newPbl.Lot_Number = "<None>";
                }
                else
                {
                    newPbl.Lot_Number = Lot.Text;
                }

                sysmgr.createLocation(newAddress);
                sysmgr.createLLd_ATS(newAts);
                sysmgr.createLLD_PBL(newPbl);

                if (LINC.Text.Trim().Equals(""))
                {
                    newSiteFile.LINC_Number = "<None>";
                }
                else
                {
                    newSiteFile.LINC_Number = LINC.Text;
                }

                newSiteFile.File_Status = FileStatus.SelectedValue;
                newSiteFile.Closed_Date = ClosedDate.SelectedDate;
                newSiteFile.PBL_ID      = newPbl.PBL_ID;
                newSiteFile.Document_ID = 1;
                sysmgr.File_Add(newSiteFile, orgainztionId);
                sysmgr.file_update(newSiteFile.File_ID, orgainztionId);
            }, "Add File", "File has been successfuly added to the database");

            Response.Redirect("ClientPage.aspx");
        }
    }