コード例 #1
0
        } //---------------------------

        //this function returns the remarks details
        private RemarksDetails GetRemarksDetails(String remarks)
        {
            RemarksDetails remarkInfo = new RemarksDetails();

            if (!String.IsNullOrEmpty(remarks))
            {
                remarks = RemoteClient.ProcStatic.TrimStartEndString(remarks);

                Int32 indexCourse = remarks.IndexOf("Course", 0);

                if (indexCourse == -1)
                {
                    remarkInfo.CourseName       = "";
                    remarkInfo.OtherInformation = "";
                }
                else
                {
                    String[] splitString = remarks.Split(":\r\n".ToCharArray());

                    for (Int32 i = 0; i <= splitString.Length - 1; i++)
                    {
                        String strTemp = splitString[i];

                        if (i == 0)
                        {
                            continue;
                        }
                        else if (i == 1)
                        {
                            remarkInfo.CourseName = RemoteClient.ProcStatic.TrimStartEndString(strTemp);
                            continue;
                        }
                        else if (String.Equals("COURSE", strTemp.ToUpper()) ||
                                 String.Equals("YEAR", strTemp.ToUpper()) ||
                                 String.Equals("SEX", strTemp.ToUpper()) ||
                                 String.Equals("STATUS", strTemp.ToUpper()) ||
                                 String.Equals("SECTION", strTemp.ToUpper()) ||
                                 String.Equals("OLD/NEW", strTemp.ToUpper()))
                        {
                            strTemp += ": ";
                        }
                        else if (!String.IsNullOrEmpty(strTemp))
                        {
                            strTemp += "\n";
                        }

                        if (!String.IsNullOrEmpty(strTemp))
                        {
                            remarkInfo.OtherInformation += strTemp;
                        }
                    }
                }
            }


            return(remarkInfo);
        } //------------------------------
コード例 #2
0
        } //------------------------

        //this procedure exports the student data to the sql server
        private void ExportStudentDataToSqlServer()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Int32 deniedCount  = 0;
                Int32 successCount = 0;
                Int32 rowCount     = 0;

                pgbImport.Step    = 1;
                pgbImport.Maximum = this.dgvList.Rows.Count;

                foreach (DataRow studRow in _studentTable.Rows)
                {
                    this.SetDataGridViewBehavior(rowCount);

                    String studentId   = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "ACCESSION", "");
                    String cardNumber  = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "KEYWORDS", "");
                    String studentName = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "TITLE0", "");

                    if (!this.IsExistStudentIdStudentInformation(_userInfo, studentId, "") &&
                        !this.IsExistCardNumberStudentInformation(_userInfo, cardNumber, "") &&
                        !String.Equals("(blank)", studentName) &&
                        !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(cardNumber)) &&
                        !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(studentId)))
                    {
                        String remarks = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "REMARKS", "");

                        CommonExchange.Student studentInfo = new CommonExchange.Student();

                        studentInfo.ObjectState            = DataRowState.Added;
                        studentInfo.PersonInfo.ObjectState = DataRowState.Added;

                        StudentName    studName   = this.GetStudentNameDetails(studentName);
                        RemarksDetails remarkInfo = this.GetRemarksDetails(remarks);

                        studentInfo.StudentId            = RemoteClient.ProcStatic.TrimStartEndString(studentId);
                        studentInfo.PersonInfo.LastName  = studName.LastName;
                        studentInfo.PersonInfo.FirstName = studName.FirstName;
                        studentInfo.CardNumber           = cardNumber;
                        studentInfo.Scholarship          = studName.Scholoarship;
                        studentInfo.CourseInfo.CourseId  = this.GetCourseId(remarkInfo.CourseName);
                        studentInfo.PersonInfo.OtherPersonInformation = remarkInfo.OtherInformation;
                        studentInfo.PersonInfo.BirthDate = String.Empty;

                        if (!String.IsNullOrEmpty(_imagePath) && this.chkImage.Checked)
                        {
                            StudentImage imageInfo = this.GetStudentImageDetails(studentId);

                            if (!String.IsNullOrEmpty(imageInfo.ImagePath))
                            {
                                studentInfo.PersonInfo.FilePath      = imageInfo.ImagePath;
                                studentInfo.PersonInfo.FileData      = RemoteClient.ProcStatic.GetFileArrayBytes(imageInfo.ImagePath);
                                studentInfo.PersonInfo.FileExtension = imageInfo.ImageExtension;
                                studentInfo.PersonInfo.FileName      = Path.GetFileName(imageInfo.ImagePath);

                                this.txtDirectory.Text = imageInfo.ImagePath;
                            }
                        }

                        using (RemoteClient.RemCntStudentManager remClient = new RemoteClient.RemCntStudentManager())
                        {
                            remClient.InsertStudentInformation(_userInfo, ref studentInfo);
                        }

                        using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager())
                        {
                            remClient.UpdateForIdMakerStudentInformation(_userInfo, studentInfo);
                        }

                        successCount++;
                    }
                    else
                    {
                        deniedCount++;
                    }

                    pgbImport.PerformStep();

                    rowCount++;

                    Application.DoEvents();
                    this.Refresh();
                }

                MessageBox.Show("Student data has been successfully exported to the SQL Server" + "\n\nSuccess: " + successCount.ToString() + " Record(s)" +
                                "\nDenied: " + deniedCount.ToString() + " Record(s)", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                pgbImport.Value = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in exporting: " + ex.Message, "Error");
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        } //--------------------------------------