/// <summary> /// Deletes SpecimenBox and SpecimenPosition records when deleting a specimen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SpecimenGridRowDeleted(object sender, GridViewDeletedEventArgs e) { string positionId = e.Values[Specimen.PositionId].ToString(); // Check for existnce of position id in deleted record if (!string.IsNullOrEmpty(positionId)) { SpecimenPosition biz = new SpecimenPosition(); biz.Delete(int.Parse(positionId)); } }
protected void UpdateBtn_Click(object sender, ImageClickEventArgs e) { CurrentSpecimen = new Specimen(); CurrentSpecimen.Get(this.specimenId); if (!string.IsNullOrEmpty(BoxId.Value)) { int boxId = int.Parse(BoxId.Value); // checks for Position & set values in Specimen Position Table if (!string.IsNullOrEmpty(PositionName.Value)) { if (!string.IsNullOrEmpty(this.PositionId.Value)) { // Load Position Record int posId = int.Parse(this.PositionId.Value); pos.Get(posId); } pos[SpecimenPosition.BoxId] = this.BoxId.Value; pos[SpecimenPosition.Position] = this.PositionName.Value; pos[SpecimenPosition.PositionStatus] = "Filled"; pos.Save(); // Update specimens table with boxid and position ids CurrentSpecimen[Specimen.PositionId] = pos[SpecimenPosition.PositionId].ToString(); CurrentSpecimen[Specimen.BoxId] = pos[SpecimenPosition.BoxId].ToString(); } else { string currentPosId = CurrentSpecimen[Specimen.PositionId].ToString(); // Checks for PositionId if already exists // then remove from SpecimenPositions, since a box is choosen instead of a position if (!string.IsNullOrEmpty(currentPosId)) { CurrentSpecimen[Specimen.BoxId] = boxId; CurrentSpecimen[Specimen.PositionId] = string.Empty; pos.Delete(int.Parse(currentPosId)); } else { CurrentSpecimen[Specimen.BoxId] = boxId; CurrentSpecimen[Specimen.PositionId] = string.Empty; } } } CurrentSpecimen[Specimen.SpecimenNotes] = this.SpecimenNotes.Value; CurrentSpecimen[Specimen.SpecimenOriginalQty] = this.SpecimenOriginalQty.Value; CurrentSpecimen[Specimen.SpecimenRemainingQty] = this.SpecimenRemainingQty.Value; CurrentSpecimen[Specimen.SpecimenPreservationType] = this.SpecimenPreservationType.Value; CurrentSpecimen[Specimen.SpecimenReferenceNumber] = this.SpecimenReferenceNumber.Value; CurrentSpecimen[Specimen.SpecimenStatus] = this.SpecimenStatus.Value; CurrentSpecimen[Specimen.ContactId] = this.Contact.Value; CurrentSpecimen[Specimen.SpecimenSubType] = this.SpecimenSubType.Value; CurrentSpecimen[Specimen.SpecimenType] = this.SpecimenType.Value; CurrentSpecimen[Specimen.SpecimenUnits] = this.SpecimenUnits.Value; string specId = CurrentSpecimen[Specimen.SpecimenId].ToString(); string parentspecId = CurrentSpecimen[Specimen.ParentSpecimenId].ToString(); //calculating parent Rem qty based on child Qty if (!string.IsNullOrEmpty(parentspecId)) { Specimen ParentSpecimen = new Specimen(); ParentSpecimen.Get(Int32.Parse(parentspecId.ToString())); string PparentspecId = ParentSpecimen[Specimen.ParentSpecimenId].ToString(); //string specimenRemQty = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); //if (!string.IsNullOrEmpty(specimenRemQty)) //{ // specimenRemQty = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); //} //else //{ // specimenRemQty = ParentSpecimen[Specimen.SpecimenOriginalQty].ToString(); //} //string subspecOrgQty = this.SpecimenOriginalQty.Value; //int specRemQty; //if (!string.IsNullOrEmpty(subspecOrgQty)) //{ // if (Int32.Parse(subspecOrgQty) <= Int32.Parse(specimenRemQty)) // { // specRemQty = Int32.Parse(specimenRemQty) - Int32.Parse(subspecOrgQty); // ParentSpecimen[Specimen.SpecimenRemainingQty] = specRemQty; // } //} //else //{ // specRemQty = Int32.Parse(specimenRemQty) - 0; // ParentSpecimen[Specimen.SpecimenRemainingQty] = specRemQty; //} CurrentSpecimen.Save(); ParentSpecimen.Save(); } else { CurrentSpecimen.Save(); } //Refreshing specimens hierarchy frame of Parent page Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "RefreshParentwindow", "refreshParentwindow();", true); }
protected void Update_Click(object sender, CommandEventArgs e) { SpecimenPosition pos = new SpecimenPosition(); if (!string.IsNullOrEmpty(BoxId.Value)) { int boxId = int.Parse(BoxId.Value); // checks for Position & set values in Specimen Position Table if (!string.IsNullOrEmpty(PositionName.Value)) { if (!string.IsNullOrEmpty(this.PositionId.Value)) { // Load Position Record int posId = int.Parse(this.PositionId.Value); pos.Get(posId); } pos[SpecimenPosition.BoxId] = this.BoxId.Value; pos[SpecimenPosition.Position] = this.PositionName.Value; pos[SpecimenPosition.PositionStatus] = "Filled"; pos.Save(); // Update specimens table with boxid and position ids CurrentSpecimen[Specimen.PositionId] = pos[SpecimenPosition.PositionId].ToString(); CurrentSpecimen[Specimen.BoxId] = pos[SpecimenPosition.BoxId].ToString(); } else { string currentPosId = CurrentSpecimen[Specimen.PositionId].ToString(); // Checks for PositionId if already exists // then remove from SpecimenPositions, since a box is choosen instead of a position if (!string.IsNullOrEmpty(currentPosId)) { CurrentSpecimen[Specimen.BoxId] = boxId; CurrentSpecimen[Specimen.PositionId] = string.Empty; pos.Delete(int.Parse(currentPosId)); } else { CurrentSpecimen[Specimen.BoxId] = boxId; CurrentSpecimen[Specimen.PositionId] = string.Empty; } } } CurrentSpecimen[Specimen.SpecimenNotes] = this.SpecimenNotes.Value; CurrentSpecimen[Specimen.SpecimenOriginalQty] = this.SpecimenOriginalQty.Value; CurrentSpecimen[Specimen.SpecimenRemainingQty] = this.SpecimenRemainingQty.Value; CurrentSpecimen[Specimen.SpecimenPreservationType] = this.SpecimenPreservationType.Value; CurrentSpecimen[Specimen.SpecimenReferenceNumber] = this.SpecimenReferenceNumber.Value; CurrentSpecimen[Specimen.SpecimenStatus] = this.SpecimenStatus.Value; CurrentSpecimen[Specimen.ContactId] = this.Contact.Value; CurrentSpecimen[Specimen.SpecimenSubType] = this.SpecimenSubType.Value; CurrentSpecimen[Specimen.SpecimenType] = this.SpecimenType.Value; CurrentSpecimen[Specimen.SpecimenUnits] = this.SpecimenUnits.Value; CurrentSpecimen.Save(); string specId = CurrentSpecimen[Specimen.SpecimenId].ToString(); string parentspecId = CurrentSpecimen[Specimen.ParentSpecimenId].ToString(); //calculating parent specimen RemQty on updating sub-specimen OrgQty //if (!string.IsNullOrEmpty(parentspecId)) //{ // Specimen ParentSpecimen = new Specimen(); // ParentSpecimen.Get(Int32.Parse(parentspecId.ToString())); // string PparentspecId = ParentSpecimen[Specimen.ParentSpecimenId].ToString(); // string specimenRemQty = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); // if (!string.IsNullOrEmpty(specimenRemQty)) // { // specimenRemQty = ParentSpecimen[Specimen.SpecimenRemainingQty].ToString(); // } // else // { // specimenRemQty = ParentSpecimen[Specimen.SpecimenOriginalQty].ToString(); // } // string subspecOrgQty = this.SpecimenOriginalQty.Value; // int specRemQty; // if (!string.IsNullOrEmpty(subspecOrgQty)) // { // if (Int32.Parse(subspecOrgQty) <= Int32.Parse(specimenRemQty)) // { // specRemQty = Int32.Parse(specimenRemQty) - Int32.Parse(subspecOrgQty); // ParentSpecimen[Specimen.SpecimenRemainingQty] = specRemQty; // } // } // else // { // specRemQty = Int32.Parse(specimenRemQty) - 0; // ParentSpecimen[Specimen.SpecimenRemainingQty] = specRemQty; // } // ParentSpecimen.Save(); //} SetRefreshClientBlock(); }