Пример #1
0
        ///<summary>All fields for all reqs will have already been set.  All except for reqstudent.ReqStudentNum if new.  Now, they just have to be persisted to the database.</summary>
        public static void SynchApt(List <ReqStudent> listReqsAttached, List <ReqStudent> listReqsRemoved, long aptNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), listReqsAttached, listReqsRemoved, aptNum);
                return;
            }
            string command;

            //first, delete all that were removed from this appt
            if (listReqsRemoved.Count(x => x.ReqStudentNum != 0) > 0)
            {
                command = "DELETE FROM reqstudent WHERE ReqStudentNum IN(" + string.Join(",", listReqsRemoved.Where(x => x.ReqStudentNum != 0)
                                                                                         .Select(x => x.ReqStudentNum)) + ")";
                Db.NonQ(command);
            }
            //second, detach all from this appt
            command = "UPDATE reqstudent SET AptNum=0 WHERE AptNum=" + POut.Long(aptNum);
            Db.NonQ(command);
            if (listReqsAttached.Count == 0)
            {
                return;
            }
            for (int i = 0; i < listReqsAttached.Count; i++)
            {
                if (listReqsAttached[i].ReqStudentNum == 0)
                {
                    ReqStudents.Insert(listReqsAttached[i]);
                }
                else
                {
                    ReqStudents.Update(listReqsAttached[i]);
                }
            }
        }
Пример #2
0
        ///<summary>All fields for all reqs will have already been set.  All except for reqstudent.ReqStudentNum if new.  Now, they just have to be persisted to the database.</summary>
        public static void SynchApt(List <ReqStudent> reqsAttached, long aptNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), reqsAttached, aptNum);
                return;
            }
            //first, detach all from this appt
            string command = "UPDATE reqstudent SET AptNum=0 WHERE AptNum=" + POut.Long(aptNum);

            Db.NonQ(command);
            if (reqsAttached.Count == 0)
            {
                return;
            }
            for (int i = 0; i < reqsAttached.Count; i++)
            {
                if (reqsAttached[i].ReqStudentNum == 0)
                {
                    ReqStudents.Insert(reqsAttached[i]);
                }
                else
                {
                    ReqStudents.Update(reqsAttached[i]);
                }
            }
        }