当前位置: 首页>>代码示例>>C#>>正文


C# AccessHelper.SaveAll方法代码示例

本文整理汇总了C#中AccessHelper.SaveAll方法的典型用法代码示例。如果您正苦于以下问题:C# AccessHelper.SaveAll方法的具体用法?C# AccessHelper.SaveAll怎么用?C# AccessHelper.SaveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AccessHelper的用法示例。


在下文中一共展示了AccessHelper.SaveAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getConf

        private static UDT.AbsenceConfiguration getConf(string key, string defaultValue)
        {
            AccessHelper ah = new AccessHelper();

            List<UDT.AbsenceConfiguration> configs = ah.Select<UDT.AbsenceConfiguration>(string.Format("conf_name='{0}'", key));

            if (configs.Count < 1)
            {
                UDT.AbsenceConfiguration conf = new AbsenceConfiguration();
                conf.Name = key;
                conf.Content = defaultValue;
                List<ActiveRecord> recs = new List<ActiveRecord>();
                recs.Add(conf);
                ah.SaveAll(recs);
                configs = ah.Select<UDT.AbsenceConfiguration>(string.Format("conf_name='{0}'", key));
            }

            return configs[0];
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:19,代码来源:AbsenceConfiguration.cs

示例2: OnSaveData

        protected override void OnSaveData()
        {
            if (!IsValidate())
            {
                MessageBox.Show("請先修正錯誤再儲存。", "錯誤");
                return;
            }
            K12.Data.StudentRecord stud = K12.Data.Student.SelectByID(this.PrimaryKey);
            StringBuilder sb = new StringBuilder();
            sb.Append(string.Format("學生『{0}』的課程成績變動如下:\n", stud.Name));

            //Deleted Records
            List<ActiveRecord> recs = new List<ActiveRecord>();
            foreach (UDT.SubjectSemesterScore scr in this.deletedScores)
            {
                sb.Append(string.Format("刪除:{0}  \n",this.makeScoreMsg(scr)));
                scr.Deleted = true;
                recs.Add(scr);
            }

            //Inserted Or Updated Records
            foreach (DataGridViewRow row in this.dataGridViewX1.Rows)
            {
                if (!row.IsNewRow)
                {
                    UDT.SubjectSemesterScore scr = (UDT.SubjectSemesterScore)row.Tag;
                    if (row.Tag == null)
                    {
                        scr = new UDT.SubjectSemesterScore();
                        scr.StudentID = int.Parse(this.PrimaryKey);
                    }
                    else
                    {
                        //如果不存在 updatedScores ,則跳下一筆
                        if (!this.updatedScores.ContainsKey(scr.UID))
                            continue;
                    }

                    if (row.Cells[0].Value == null)
                        scr.SchoolYear = null;
                    else
                        scr.SchoolYear =  int.Parse(row.Cells[0].Value.ToString());

                    if (row.Cells[1].Value == null)
                        scr.Semester = null;
                    else
                        scr.Semester =  this.dicSemester[row.Cells[1].Value.ToString()];

                    scr.NewSubjectCode = row.Cells[2].Value.ToString();
                    scr.SubjectID = int.Parse(this.dicSubjects[scr.NewSubjectCode].UID);
                    scr.SubjectName = row.Cells[3].Value.ToString();
                    scr.IsRequired = bool.Parse(row.Cells[5].Value.ToString());
                    scr.Credit = int.Parse(row.Cells[6].Value.ToString());
                    scr.Score = (row.Cells[8].Value == null ? "" : row.Cells[8].Value.ToString());
                    scr.IsPass = (row.Cells[9].Value==null) ? false : bool.Parse(row.Cells[9].Value.ToString());
                    scr.OffsetCourse = (row.Cells[10].Value == null ? "" : row.Cells[10].Value.ToString());
                    scr.Remark = (row.Cells[11].Value == null ? "" : row.Cells[11].Value.ToString());

                    if (string.IsNullOrWhiteSpace(scr.UID))
                        sb.Append(string.Format("新增:{0}  \n", this.makeScoreMsg(scr)));
                    else
                        sb.Append(string.Format("修改:{0}  \n", this.makeScoreMsg(scr)));

                    recs.Add(scr);
                }
            }

            AccessHelper ah = new AccessHelper();
            //delete
            //if (this.deletedList.Count > 0)
            ah.SaveAll(recs);

            FISCA.LogAgent.ApplicationLog.Log("課程學期成績.學生", "修改", "student", this.PrimaryKey, sb.ToString());

            this.OnPrimaryKeyChanged(EventArgs.Empty);

            ResetDirtyStatus();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:78,代码来源:Student_SubjectScore.cs

示例3: getUrl

        private static UDT.WebUrls getUrl(string name, string defaultValue = "", string defaultTitle = "")
        {
            AccessHelper ah = new AccessHelper();

            List<UDT.WebUrls> configs = ah.Select<UDT.WebUrls>(string.Format("name='{0}'", name));

            if (configs.Count < 1)
            {
                UDT.WebUrls conf = new WebUrls();
                conf.Name = name;
                conf.Url = defaultValue;
                conf.Title = defaultTitle;
                List<ActiveRecord> recs = new List<ActiveRecord>();
                recs.Add(conf);
                ah.SaveAll(recs);
                configs = ah.Select<UDT.WebUrls>(string.Format("name='{0}'", name));
            }

            return configs[0];
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseSelection,代码行数:20,代码来源:WebUrls.cs

示例4: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ValidateData())
                return;

            this.GatherData();

            List<ActiveRecord> recs = new List<ActiveRecord>();
            recs.Add(this._target);
            FISCA.UDT.AccessHelper ah = new AccessHelper();
            try
            {
                List<string> ids = ah.SaveAll(recs);

                if (this.AfterSaved != null)
                {
                    this.AfterSaved(this, ids.ToArray<string>());
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "儲存資料時發生錯誤!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBAUDTDetailContentBase,代码行数:25,代码来源:UDTSingleForm.cs

示例5: btnImport_Click

        private void btnImport_Click(object sender, EventArgs e)
        {
            Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
            try
            {
                wb.Open(this.textBoxX1.Text);

                Aspose.Cells.Worksheet ws = wb.Worksheets[0];

                int rowIndex = 1;
                int totalCount = 0;

                while (ws.Cells[rowIndex, 0].Value != null && !string.IsNullOrWhiteSpace(ws.Cells[rowIndex, 0].Value.ToString()))
                {
                    rowIndex += 1;
                    totalCount += 1;
                }

                this.progressBarX1.Maximum = totalCount;

                rowIndex = 1;
                AccessHelper ah = new AccessHelper();
                while (ws.Cells[rowIndex, 0].Value != null && !string.IsNullOrWhiteSpace(ws.Cells[rowIndex, 0].Value.ToString()))
                {
                    string ntu_sys_no = GetCellValue(ws.Cells[rowIndex, 0]);
                    string tea_name = GetCellValue(ws.Cells[rowIndex, 1]);
                    string tea_eng_name = GetCellValue(ws.Cells[rowIndex, 2]);
                    string tea_account = GetCellValue(ws.Cells[rowIndex, 7]);
                    string tea_email = GetCellValue(ws.Cells[rowIndex, 8]);
                    string tea_office_telno = GetCellValue(ws.Cells[rowIndex, 12]);
                    string unit = GetCellValue(ws.Cells[rowIndex, 15]);

                    //string emp_no = ws.Cells[rowIndex, 5].Value.ToString();

                    K12.Data.TeacherRecord tea = new K12.Data.TeacherRecord();
                    tea.Name = tea_name;
                    tea.TALoginName = tea_account;
                    tea.Email = tea_email;

                    string newTID = K12.Data.Teacher.Insert(tea);

                    //K12.Data.Teacher.Update(tea);

                    UDT.TeacherExtVO udtTe = new UDT.TeacherExtVO();
                    udtTe.EnglishName = tea_eng_name;
                    udtTe.TeacherID = int.Parse(newTID);
                    udtTe.NtuSystemNo = ntu_sys_no;
                    //udtTe.EmployeeNo = emp_no;
                    udtTe.OtherPhone = tea_office_telno;
                    udtTe.MajorWorkPlace = unit;

                    List<ActiveRecord> rec = new List<ActiveRecord>();
                    rec.Add(udtTe);
                    ah.SaveAll(rec);

                    rowIndex += 1;

                    this.labelX1.Text = string.Format("{0} / {1} ", rowIndex.ToString(), totalCount.ToString());

                    this.progressBarX1.Value = rowIndex;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:69,代码来源:ImportTeacher.cs

示例6: OnSaveData

        protected override void OnSaveData()
        {
            //Save To UDT
            UDT.CourseExt c = this.Course2;
            if (this.Course2 == null)
                c = new UDT.CourseExt() ;
            c.CourseID = int.Parse(this.PrimaryKey);
            string subjCode = this.cboSubject.Text ;
            UDT.Subject subj = this.dicSubjectsBySubjectIdentifier[subjCode];

            c.SubjectID = int.Parse(subj.UID);
            c.SubjectCode = subjCode;
            //c.NewSubjectCode = this.txtNewSubjectCode.Text;
            c.NewSubjectCode = this.cboNewSubjectCode.Text;
            c.CourseType = this.cboCategory.SelectedItem.ToString();
            c.IsRequired = this.swb.Value;

            int capacity = 0;
            int.TryParse(this.nudCountLimit.Text, out capacity);

            int serial = 0;
            int.TryParse(this.nudSerialNo.Text, out serial);

            c.Capacity = capacity;
            c.SerialNo = serial;
            c.ClassName = this.cboClass.SelectedValue.ToString();

            c.Classroom = this.txtClassroom.Text.Trim();
            c.CourseTimeInfo = this.txtCourseTimeInfo.Text.Trim();
            c.Syllabus = this.txtOutline.Text.Trim();
            c.Memo = this.txtMemo.Text.Trim();

            List<ActiveRecord> recs = new List<ActiveRecord>();
            recs.Add(c);
            AccessHelper ah = new AccessHelper();
            ah.SaveAll(recs);

            //Save to DB
            this.Record.Name = this.txtCourseName.Text;
            this.Record.SchoolYear = (int)this.nudSchoolYear.Value;
            this.Record.Semester = int.Parse(this.cboSemester.SelectedValue.ToString());
            //this.Record.RefClassID = this.cboClass.SelectedValue.ToString();
            this.Record.Subject = this.cboSubject.Text;

            decimal credit = 0;
            decimal.TryParse(this.nudCredit.Text, out credit);
            this.Record.Credit = credit;

            //this.Record.Required = this.swb.Value;
            SHCourse.Update(this.Record);

            /* Log */
            this.AddLog(this.Record, c);
            this.logAgent.ActionType = Log.LogActionType.Update;
            this.logAgent.Save("課程.資料項目.基本資料", "", "", Log.LogTargetCategory.Course, this.Record.ID);

            /* */
            //K12.Presentation.NLDPanels.Course.RefillListPane();

            ResetDirtyStatus();
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:61,代码来源:Course_BasicInfo.cs

示例7: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            int course_ID = int.Parse(this.dicCourses[this.cboCourse.SelectedItem.ToString()]);
            foreach (DataGridViewRow row in this.dg.Rows)
            {
                if (row.IsNewRow)
                    continue;

                string StudentID = row.Tag + "";
                bool bChecked = false;
                bool.TryParse(row.Cells[4].Value + "", out bChecked);
                if (!this.dicChecks.ContainsKey(course_ID + "-" + StudentID))
                    this.dicChecks.Add(course_ID + "-" + StudentID, bChecked);
                else
                    this.dicChecks[course_ID + "-" + StudentID] = bChecked;
            }
            if (this.updatedRecs.Count > 0)
            {
                AccessHelper ah = new AccessHelper();
                List<ActiveRecord> recs = new List<ActiveRecord>();
                foreach (UDT.Absence abs in this.updatedRecs.Values)
                {
                    recs.Add(abs);
                }

                bool isSaveOK = false;
                try
                {
                    ah.SaveAll(recs);
                    isSaveOK = true;

                    //add log
                    foreach (UDT.Absence abs in this.updatedRecs.Values)
                    {
                        string studName = this.dicStudents[abs.StudentID.ToString()];
                        string courseName = this.cboCourse.Text;
                        DataRow section = this.dicCourseSections[abs.SectionID.ToString()];
                        string start_time = section["starttime"].ToString();
                        if (abs.Deleted)
                        {
                            if (!string.IsNullOrWhiteSpace(abs.UID))
                            {
                                //紀錄刪除此筆缺曠紀錄
                                string msg = string.Format("刪除缺課紀錄: \n 學生:{0} \n 課程:{1}  \n 上課時間 : {2} \n   補課描述:\"{3}\" ", studName, courseName, start_time, abs.MakeUpDescription);
                                FISCA.LogAgent.ApplicationLog.Log("缺課紀錄.課程", "刪除", "course", abs.CourseID.ToString(), msg);
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrWhiteSpace(abs.UID))
                            {
                                //紀錄修改此筆缺曠紀錄
                                string msg = string.Format("修改缺課紀錄: \n 學生:{0} \n 課程:{1}   \n 上課時間  : {2} \n   補課描述:\"{3}\" ", studName, courseName, start_time, abs.MakeUpDescription);
                                FISCA.LogAgent.ApplicationLog.Log("缺課紀錄.課程", "修改", "course", abs.CourseID.ToString(), msg);
                            }
                            else
                            {
                                //紀錄新增此筆缺曠紀錄
                                string msg = string.Format("新增缺課紀錄: \n 學生:{0} \n 課程:{1}   \n 上課時間  : {2} \n   補課描述:\"{3}\" ", studName, courseName, start_time, abs.MakeUpDescription);
                                FISCA.LogAgent.ApplicationLog.Log("缺課紀錄.課程", "新增", "course", abs.CourseID.ToString(), msg);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowMsg("儲存缺課紀錄時發生錯誤", "注意");
                }

                if (isSaveOK)
                    this.refreshData();
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:73,代码来源:CourseAttendance.cs

示例8: OnSaveData

        protected override void OnSaveData()
        {
            if (!this.is_validated())
            {
                MessageBox.Show("請先修正錯誤再儲存。");
                return;
            }
            //Delete All Records
            List<ActiveRecord> deleteRecs = new List<ActiveRecord>();
            foreach (UDT.CourseInstructor ci in this.records)
            {
                deleteRecs.Add(ci);
            }

            //Save new Record
            List<ActiveRecord> insertRecs = new List<ActiveRecord>();

            foreach (DataGridViewRow row in this.dataGridViewX1.Rows)
            {
                if (!row.IsNewRow)
                {
                    UDT.CourseInstructor ins = new UDT.CourseInstructor();
                    //SHSchool.Data.SHTCInstructRecord tcr = new SHTCInstructRecord();
                    ins.CourseID = int.Parse(this.PrimaryKey);
                    ins.TeacherID = int.Parse(row.Cells[1].Value.ToString());
                    ins.TagID = int.Parse(row.Cells[0].Value.ToString());
                    //ins.Role = row.Cells[1].Value.ToString(); //此欄位已不再使用。2012/3/16, kevin.
                    ins.IsScored = (row.Cells["IsScored"].Value != null && (bool)row.Cells["IsScored"].Value);
                    /*
                    if (row.Cells["IsScored"].Value != null && (bool)row.Cells["IsScored"].Value)
                    {
                        // item is checked
                        ins.IsScored = true;
                    }
                    else
                    {
                        // item is null
                        ins.IsScored = false;
                    }
                    */
                    insertRecs.Add(ins);
                }
            }

            AccessHelper ah = new AccessHelper();
            //delete
            //if (this.deletedList.Count > 0)
            ah.DeletedValues(deleteRecs);

            //insert
            if (insertRecs.Count > 0)
                ah.SaveAll(insertRecs);

            this.OnPrimaryKeyChanged(EventArgs.Empty);

            ResetDirtyStatus();

            /* ====  Log  for deleted records =====*/
            /*
            foreach (UDT.CourseInstructor ci in this.records)
            {
                Log.LogAgent agt = new Log.LogAgent();
                agt.ActionType = Log.LogActionType.Delete;
                this.AddLog(ci, agt);
               agt.Save("授課教師.課程", "刪除","", Log.LogTargetCategory.Course, ci.CourseID.ToString());
            }
             * */
            /* ====  Log  for inserted records =====*/
            K12.Data.CourseRecord course = K12.Data.Course.SelectByID(this.PrimaryKey);
            StringBuilder sb = new StringBuilder(string.Format("課程「{0}」,學年度「{1}」,學期「{2}」 \n", course.Name, course.SchoolYear, EMBACore.DataItems.SemesterItem.GetSemesterByCode(course.Semester + "").Name));
            sb.Append("授課教師更改為: \n");
            foreach (UDT.CourseInstructor ci in insertRecs)
            {
                string teacherName = this.dicTeachers[ci.TeacherID.ToString()].Name;
                string role = this.dicTags[ci.TagID.ToString()].TagFullName;
                sb.Append(string.Format("教師:{0} , 角色:{1} , 成績管理:{2} \n ", teacherName, role, ci.IsScored ? "是" : "否"));

                //Log.LogAgent agt = new Log.LogAgent();
                //agt.ActionType = Log.LogActionType.AddNew;
                //this.AddLog(ci, agt);
                //agt.Save("授課教師.課程", "新增", "", Log.LogTargetCategory.Course, ci.CourseID.ToString());
            }

            FISCA.LogAgent.ApplicationLog.Log("課程.資料項目.教授 / 助教 / 助理", "修改", "course", this.PrimaryKey, sb.ToString());
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:85,代码来源:Course_Instructor.cs

示例9: SaveData

        private bool SaveData()
        {
            //先確定所有分數格式都正確
            bool scoreAllRight = true;
            foreach (DataGridViewRow row in this.dataGridViewX1.Rows)
            {
                if (row.IsNewRow) continue;
                SubjectScoreWrapper ssw = (SubjectScoreWrapper)row.Tag;
                if (ssw.IsDirty)
                {
                    string Score = (row.Cells["colScore"].Value == null) ? "" : row.Cells["colScore"].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(Score) )  //有輸入分數
                    {
                        if (!Util.IsValidScore(Score, this.inputRule))  //但不是有效分數
                        {
                            scoreAllRight = false;
                            break;
                        }
                    }
                }
            }
            if (!scoreAllRight)
            {
                Util.ShowMsg("有些分數的格式不正確,請修正。", "");
                return false ;
            }

            //prepare log message
            StringBuilder sb = new StringBuilder(string.Format("更改 {0} 學年度 {1} 『{2}』的學生成績如下:\n",  this.nudSchoolYear.Value.ToString(), this.cboSemester.Text , this.currentCourseName));

            //找出所有需要儲存的成績紀錄
            bool result = true;
            List<ActiveRecord> recs = new List<ActiveRecord>();
            foreach (DataGridViewRow row in this.dataGridViewX1.Rows)
            {
                if (row.IsNewRow) continue;
                SubjectScoreWrapper ssw = (SubjectScoreWrapper)row.Tag;
                if (ssw.IsDirty)
                {
                    UDT.SubjectSemesterScore score = ssw.GetScoreObject();
                    score.Score = (row.Cells["colScore"].Value == null) ? "" : row.Cells["colScore"].Value.ToString();
                    score.SubjectID = this.currentSubjectID;
                    score.SubjectCode = this.currentSubjectCode;
                    score.SubjectName = this.currentSubjectName;
                    score.IsPass = (row.Cells["colIsPass"].Value == null) ? false : bool.Parse(row.Cells["colIsPass"].Value.ToString());
                    score.Credit = this.currentCredit;
                    score.IsRequired = this.currentIsRequired;

                    string studName = this.dicStudents[score.StudentID.ToString()];

                    if (string.IsNullOrWhiteSpace(score.Score))
                    {
                        if (!string.IsNullOrWhiteSpace(score.UID))
                        {
                            score.Deleted = true;
                            recs.Add(score);
                            sb.Append(string.Format("刪除成績 ->  學生:{0} , 分數 : {1} \n ", studName, score.Score));
                        }
                    }
                    else
                    {
                        recs.Add(score);
                        if (string.IsNullOrWhiteSpace(score.UID))
                            sb.Append(string.Format("新增成績 ->  學生:{0} , 分數 : {1} \n ", studName, score.Score));
                        else
                            sb.Append(string.Format("修改成績 ->  學生:{0} , 分數由 {1} 改為 {2}  \n ", studName, ssw.OldScore, score.Score));
                    }
                }
            }

            try
            {
                if (recs.Count > 0)
                {
                    AccessHelper ah = new AccessHelper();
                    ah.SaveAll(recs);

                    //Refresh
                    SubjectScoreWrapper ssw = (SubjectScoreWrapper)this.dataGridViewX1.Rows[0].Tag;
                    this.isDirty = false;
                    this.reloadStudents(ssw.CourseID, ssw.SchoolYear, ssw.Semester);

                    FISCA.LogAgent.ApplicationLog.Log("學期科目成績", "修改", "course", this.currentCourseID.ToString(), sb.ToString());

                    Util.ShowMsg("儲存成功", "管理科目成績");
                }
            }
            catch (Exception ex)
            {
                Util.ShowMsg("儲存成績時發生錯誤!", "管理科目成績");
                result = false;
            }
            this.enableSaveButton();
            return result;
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:95,代码来源:SubjectScore.cs


注:本文中的AccessHelper.SaveAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。