public new int Update(SqlTransaction trans) { ControlCardGroup cardGroup = new ControlCardGroup(trans, ID, UserName); foreach (ControlCardBlank card in cardGroup.Group) { bool exist = false; foreach (ControlCardBlank newCard in Group) { if (card.ID == newCard.ID) { exist = true; } } if (exist == false) { ControlCard.Delete(trans, card.ID, UserName); } } foreach (ControlCardBlank controlCardBlank in Group) { controlCardBlank.UserName = UserName; if (controlCardBlank.ID == 0) { InsertGroup(trans, controlCardBlank); } else { controlCardBlank.Update(trans); } } ChangeDocumentControlled(trans, DocumentID); return(ID); }
private void Init(SqlTransaction trans, int id) { if (!CanView(UserName)) { throw new AccessException(UserName, "Init"); } SqlParameter[] prms = new SqlParameter[1]; prms[0] = new SqlParameter("@ControlCardID", SqlDbType.Int); prms[0].Value = id; DataTable cTable; if (trans == null) { cTable = SPHelper.ExecuteDataset("usp_ControlCard_GetGroup", prms).Tables[0]; } else { cTable = SPHelper.ExecuteDataset(trans, "usp_ControlCard_GetGroup", prms).Tables[0]; } Group = new List <ControlCardBlank>(); foreach (DataRow row in cTable.Rows) { ControlCardGroup card = new ControlCardGroup(); card.ID = (int)row["ControlCardID"]; card.DocumentID = (int)row["DocumentID"]; card.HeadID = (int)row["HeadID"]; card.WorkerID = (int)row["WorkerID"]; card.CardNumber = (int)row["CardNumber"]; card.StartDate = (DateTime)row["StartDate"]; card.EndDate = (DateTime)row["EndDate"]; card.ControlResponseDate = row["ControlResponseDate"] != DBNull.Value ? (DateTime)row["ControlResponseDate"] : DateTime.MinValue; card.ControlResponse = (string)row["ControlResponse"]; card.HeadResponseID = (int)row["HeadResponseID"]; card.FixedWorkerID = (int)row["FixedWorkerID"]; card.CardStatusID = (int)row["CardStatusID"]; card.IsSpeciallyControlled = (bool)row["IsSpeciallyControlled"]; card.Notes = (string)row["Notes"]; card.Resolution = (string)row["Resolution"]; card.IsDecisionOfSession = (bool)row["IsDecisionOfSession"]; card.IsDecisionOfExecutiveCommittee = (bool)row["IsDecisionOfExecutiveCommittee"]; card.IsOrderOfHeader = (bool)row["IsOrderOfHeader"]; card.IsActionWorkPlan = (bool)row["IsActionWorkPlan"]; card.IsSendResponse = (bool)row["IsSendResponse"]; card.IsSendInterimResponse = (bool)row["IsSendInterimResponse"]; card.IsLeftToWorker = (bool)row["IsLeftToWorker"]; card.IsAcquaintedWorker = (bool)row["IsAcquaintedWorker"]; card.ExecutiveDepartmentID = (int)row["ExecutiveDepartmentID"]; card.IsContinuation = (bool)row["IsContinuation"]; card.ParentControlCardID = row["ParentControlCardID"] != DBNull.Value ? (int)row["ParentControlCardID"] : 0; card.InnerNumber = row["InnerNumber"] != DBNull.Value ? (string)row["InnerNumber"] : String.Empty; card.DepartmentID = (int)row["DepartmentID"]; card.GroupID = row["GroupID"] != DBNull.Value ? (int)row["GroupID"] : 0; card.InitSubObjects(trans, UserName); Group.Add(card); if (card.ID == id) { ID = (int)row["ControlCardID"]; DocumentID = (int)row["DocumentID"]; HeadID = (int)row["HeadID"]; WorkerID = (int)row["WorkerID"]; CardNumber = (int)row["CardNumber"]; StartDate = (DateTime)row["StartDate"]; EndDate = (DateTime)row["EndDate"]; ControlResponseDate = row["ControlResponseDate"] != DBNull.Value ? (DateTime)row["ControlResponseDate"] : DateTime.MinValue; ControlResponse = (string)row["ControlResponse"]; HeadResponseID = (int)row["HeadResponseID"]; FixedWorkerID = (int)row["FixedWorkerID"]; CardStatusID = (int)row["CardStatusID"]; IsSpeciallyControlled = (bool)row["IsSpeciallyControlled"]; Notes = (string)row["Notes"]; Resolution = (string)row["Resolution"]; IsDecisionOfSession = (bool)row["IsDecisionOfSession"]; IsDecisionOfExecutiveCommittee = (bool)row["IsDecisionOfExecutiveCommittee"]; IsOrderOfHeader = (bool)row["IsOrderOfHeader"]; IsActionWorkPlan = (bool)row["IsActionWorkPlan"]; IsSendResponse = (bool)row["IsSendResponse"]; IsSendInterimResponse = (bool)row["IsSendInterimResponse"]; IsLeftToWorker = (bool)row["IsLeftToWorker"]; IsAcquaintedWorker = (bool)row["IsAcquaintedWorker"]; ExecutiveDepartmentID = (int)row["ExecutiveDepartmentID"]; IsContinuation = (bool)row["IsContinuation"]; ParentControlCardID = row["ParentControlCardID"] != DBNull.Value ? (int)row["ParentControlCardID"] : 0; InnerNumber = row["InnerNumber"] != DBNull.Value ? (string)row["InnerNumber"] : String.Empty; DepartmentID = (int)row["DepartmentID"]; GroupID = row["GroupID"] != DBNull.Value ? (int)row["GroupID"] : 0; } } }