示例#1
0
        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            SpecialtyMaster_spm_Info info = null;

            try
            {
                info = KeyObject as SpecialtyMaster_spm_Info;
                using (VPMSDBDataContext db = new VPMSDBDataContext())
                {
                    SpecialtyMaster_spm spm = db.SpecialtyMaster_spms.Single <SpecialtyMaster_spm>(i => i.spm_iRecordID == info.spm_iRecordID);

                    for (int i = 0; i < spm.SpecialtyMasterCourse_smcs.Count; i++)
                    {
                        SpecialtyMasterCourse_smc sta = spm.SpecialtyMasterCourse_smcs[i];
                        db.SpecialtyMasterCourse_smcs.DeleteOnSubmit(sta);
                    }

                    db.SpecialtyMaster_spms.DeleteOnSubmit(spm);

                    db.SubmitChanges();
                }


                return(true);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
示例#2
0
        public bool UpdateRecord(SpecialtyMaster_spm_Info infoObject)
        {
            using (VPMSDBDataContext db = new VPMSDBDataContext())
            {
                SpecialtyMaster_spm spm = new SpecialtyMaster_spm();
                try
                {
                    spm = db.SpecialtyMaster_spms.SingleOrDefault(t => t.spm_iRecordID == infoObject.spm_iRecordID);
                    for (int i = 0; i < spm.SpecialtyMasterCourse_smcs.Count; i++)
                    {
                        SpecialtyMasterCourse_smc sta = spm.SpecialtyMasterCourse_smcs[i];
                        db.SpecialtyMasterCourse_smcs.DeleteOnSubmit(sta);
                    }
                    if (spm != null)
                    {
                        spm.spm_cName     = infoObject.spm_cName;
                        spm.spm_cNumber   = infoObject.spm_cNumber;
                        spm.spm_cRemark   = infoObject.spm_cRemark;
                        spm.spm_cLast     = infoObject.spm_cLast;
                        spm.spm_dLastDate = infoObject.spm_dLastDate.Value;

                        db.SubmitChanges();
                    }

                    return(true);
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }