Esempio n. 1
0
        /// <summary>
        /// 根據聯繫ID匯出聯繫資料
        /// </summary>
        /// <param name="contactIdList"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string ExportContactSituationDataByContactId(List <string> contactIdList, string path)
        {
            List <ContactSituation> ContactSituationList = new List <ContactSituation>();

            try
            {
                foreach (string contactId in contactIdList)
                {
                    ContactSituation contactSituation = new ContactSituation();
                    DataSet          ds = Talent.GetInstance().SelectContactSituationDataById(contactId);
                    contactSituation.Info   = ds.Tables[0].DBNullToEmpty().DataTableToList <ContactInfo>()[0];
                    contactSituation.Status = ds.Tables[1].DataTableToList <ContactStatus>();
                    string codeList = string.Empty;
                    foreach (DataRow dr in ds.Tables[2].Rows)
                    {
                        codeList += dr[0].ToString() + "\n";
                    }

                    contactSituation.Code = codeList;
                    ContactSituationList.Add(contactSituation);
                }

                string msg = ExcelHelper.GetInstance().ExportMultipleContactSituation(ContactSituationList, path);
                if (msg != "匯出成功")
                {
                    return("匯出失敗");
                }

                return("匯出成功");
            }
            catch (Exception ex)
            {
                LogInfo.WriteErrorInfo(ex);
                return("匯出失敗");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 驗證聯繫狀況基本資料是否正確
        /// </summary>
        /// <param name="name">姓名不可為空</param>
        /// <param name="code">可以有多個代碼,代碼都是唯一值</param>
        /// <param name="sex">值為"男"or"女"</param>
        /// <param name="mail">e-mail格式</param>
        /// <param name="cellPhone">手機格式</param>
        /// <param name="place"><地點</param>
        /// <param name="skill">技能</param>
        /// <param name="cooperationMode">合作模式值為"全職"or"合約"or"皆可"</param>
        /// <param name="states">狀態值為"追蹤"or"保留"</param>
        /// <returns>空值代表沒有錯誤</returns>
        public string ValidContactSituationInfoData(string name, DataTable code, string sex, string mail, string cellPhone, string place, string skill, string cooperationMode, string states)
        {
            string msg      = string.Empty;
            string validMsg = string.Empty;

            if (string.IsNullOrEmpty(name) && code.Rows.Count == 0)
            {
                msg += "姓名或代碼請至少填一個\n";
            }

            validMsg = Valid.GetInstance().ValidSex(sex);
            if (!validMsg.Equals(string.Empty))
            {
                msg += validMsg + "\n";
            }

            validMsg = this.ValidCooperationMode(cooperationMode);
            if (!validMsg.Equals(string.Empty))
            {
                msg += validMsg + "\n";
            }

            validMsg = this.ValidStates(states);
            if (!validMsg.Equals(string.Empty))
            {
                msg += validMsg + "\n";
            }

            validMsg = Talent.GetInstance().ValidCodeIsRepeat(code);
            if (!validMsg.Equals(string.Empty))
            {
                msg += validMsg;
            }

            return(msg);
        }
Esempio n. 3
0
        /// <summary>
        /// 匯入新版資料
        /// </summary>
        /// <param name="path"></param>
        public List <ContactSituation> ImportNewTalent(string path)
        {
            ErrorMessage = string.Empty;
            string                  msg = string.Empty;
            List <string>           checkCodeIsRepeat    = new List <string>(); ////檢查Excel內部的代碼是否有重複
            List <ContactSituation> contactSituationList = new List <ContactSituation>();

            try
            {
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(path);
                Worksheet sheet = workbook.Worksheets[0];
                DataTable dt    = sheet.ExportDataTable();

                //if(!TalentValid.GetInstance().ValidIsNewTalentFormat(dt.Columns))
                if (!TalentValid.GetInstance().ValidTalentFormat(dt.Columns, false))
                {
                    ErrorMessage = "excel格式不符";
                    return(contactSituationList);
                }

                if (dt.Rows.Count == 0)
                {
                    ErrorMessage = "空的excel";
                    return(contactSituationList);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ContactSituation     contactSituation  = new ContactSituation();
                    ContactInfo          contactInfo       = new ContactInfo();
                    List <ContactStatus> contactStatusList = new List <ContactStatus>();
                    for (int j = 0; j < 29; j++)
                    {
                        ////先不處理聯繫狀況
                        if (j == 3 || j == 4 || j == 5)
                        {
                            continue;
                        }

                        switch (dt.Columns[j].ToString().Trim())
                        {
                        case "姓名":
                            contactInfo.Name = dt.Rows[i].ItemArray[j].ToString().Trim();
                            break;

                        case "地點":
                            contactInfo.Place = dt.Rows[i].ItemArray[j].ToString().Trim();
                            break;

                        case "1111/104代碼":
                            ////檢查Excel內部的代碼是否有重複
                            string[] codeList = dt.Rows[i].ItemArray[j].ToString().Trim().Split('\n');
                            foreach (string code in codeList)
                            {
                                if (checkCodeIsRepeat.Contains(code))
                                {
                                    contactSituationList.Clear();
                                    ErrorMessage = "第" + (i + 1) + "行" + code + "重複\n請檢查Excel";
                                    return(contactSituationList);
                                }

                                checkCodeIsRepeat.Add(code);
                            }

                            contactSituation.Code = dt.Rows[i].ItemArray[j].ToString().Trim();
                            break;

                        case "JAVA":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "JSP":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Android APP":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "ASP":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "C/C++":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "C#":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "ASP.NET":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "VB.NET":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "VB6":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "HTML":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Javascript":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Bootstrap":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Delphi":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "PHP":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "研替":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Hadoop":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "ETL":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "R":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "notes":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "UI/UX":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "資料庫":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;

                        case "Linux":
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[j].ToString().Trim()))
                            {
                                contactInfo.Skill += dt.Rows[i].ItemArray[j].ToString().Trim() + ",";
                            }
                            break;
                        }
                    }

                    ////聯繫狀況
                    do
                    {
                        ContactStatus contactStatus = new ContactStatus();
                        for (int z = 3; z <= 5; z++)
                        {
                            switch (dt.Columns[z].ToString().Trim())
                            {
                            case "日期":
                                msg = Valid.GetInstance().ValidDateFormat(dt.Rows[i].ItemArray[z].ToString().Trim());
                                if (msg != string.Empty)
                                {
                                    contactSituationList.Clear();
                                    ErrorMessage = "第" + (i + 1) + "行" + msg + "\n請檢查Excel";
                                    return(contactSituationList);
                                }

                                contactStatus.Contact_Date = dt.Rows[i].ItemArray[z].ToString().Trim();
                                break;

                            case "聯絡狀況":
                                if (string.IsNullOrEmpty(dt.Rows[i].ItemArray[z].ToString().Trim()))
                                {
                                    contactStatus.Contact_Status = "(無)";
                                }
                                else
                                {
                                    msg = TalentValid.GetInstance().ValidContactStatus(dt.Rows[i].ItemArray[z].ToString().Trim());
                                    if (msg != string.Empty)
                                    {
                                        contactSituationList.Clear();
                                        ErrorMessage = "第" + (i + 1) + "行" + msg + "\n請檢查Excel";
                                        return(contactSituationList);
                                    }

                                    contactStatus.Contact_Status = dt.Rows[i].ItemArray[z].ToString().Trim();
                                }
                                break;

                            case "說明":
                                contactStatus.Remarks = dt.Rows[i].ItemArray[z].ToString().Trim();
                                break;
                            }
                        }

                        contactStatusList.Add(contactStatus);

                        i++;
                        if (i >= dt.Rows.Count)
                        {
                            break;
                        }
                    } while (string.IsNullOrEmpty(dt.Rows[i].ItemArray[0].ToString().Trim()) && string.IsNullOrEmpty(dt.Rows[i].ItemArray[1].ToString().Trim()));

                    i--; ////因為在do迴圈有先i++判斷下一列的姓名與代碼是否有值,因此在跳出迴圈時,要把它減回來
                    contactInfo.Skill       = contactInfo.Skill.RemoveEndWithDelimiter(",");
                    contactSituation.Info   = contactInfo;
                    contactSituation.Status = contactStatusList;
                    contactSituationList.Add(contactSituation);
                }

                msg = Talent.GetInstance().ValidCodeIsRepeat(checkCodeIsRepeat);
                if (msg != string.Empty)
                {
                    contactSituationList.Clear();
                    ErrorMessage = msg + "\n請檢查Excel";
                    return(contactSituationList);
                }

                return(contactSituationList);
            }
            catch (Exception ex)
            {
                LogInfo.WriteErrorInfo(ex);
                contactSituationList.Clear();
                ErrorMessage = "讀取Excel發生錯誤";
                return(contactSituationList);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 儲存面談資料
        /// </summary>
        /// <param name="saveData">面談資料</param>
        /// <param name="interviewId">面談ID</param>
        /// <param name="dbPath">資料庫的圖片路徑</param>
        /// <param name="uiPath">UI的圖片路徑</param>
        /// <returns></returns>
        public string SaveInterviewData(DataSet saveData, string interviewId, string dbPath, string uiPath)
        {
            if (!Talent.GetInstance().ValidInterviewIdIsAppear(interviewId))
            {
                return("沒有對應的面試基本資料");
            }

            string path = TalentFiles.GetInstance().UpdateImage(dbPath, uiPath, interviewId);

            if (path.Equals("上傳失敗") || path.Equals("不存在的路徑") || path.Equals("檔案刪除失敗"))
            {
                throw new Exception(path);
            }

            string update = @"update Interview_Info set Vacancies=@vacancies,Interview_Date=@interviewDate,Name=@name,Sex=@sex,Birthday=@birthday
                              ,Married=@married,Mail=@mail,Adress=@adress,CellPhone=@cellPhone,Image=@image,Expertise_Language=@expertiseLanguage
                              ,Expertise_Tools=@expertiseTools,Expertise_Tools_Framwork=@expertiseToolsFramwork,Expertise_Devops=@expertiseDevops
                              ,Expertise_OS=@expertiseOS
                              ,Expertise_BigData=@expertiseBigData,Expertise_DataBase=@expertiseDataBase,Expertise_Certification=@expertiseCertification
                              ,IsStudy=@isStudy,IsService=@IsService,Relatives_Relationship=@relativesRelationship,Relatives_Name=@relativesName
                              ,Care_Work=@careWork,Hope_Salary=@hopeSalary,When_Report=@whenReport,Advantage=@advantage,Disadvantages=@disadvantages
                              ,Hobby=@hobby,Attract_Reason=@attractReason,Future_Goal=@futureGoal,Hope_Supervisor=@hopeSupervisor
                              ,Hope_Promise=@hopePromise,Introduction=@introduction,During_Service=@duringService,Exemption_Reason=@exemptionReason
                              ,Urgent_Contact_Person=@urgentContactPerson,Urgent_Relationship=@urgentRelationship,Urgent_CellPhone=@urgentCellPhone
                              ,Education=@education,Language=@language,Work_Experience=@workExperience
                              where Interview_Id=@interviewId";

            try
            {
                using (SqlCommand cmd = new SqlCommand(update, ScConnection, StTransaction))
                {
                    ////儲存面談基本資料
                    foreach (DataRow dr in saveData.Tables[1].Rows)
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@education", SqlDbType.NVarChar).Value           = dr["Education"].ToString().Trim();
                        cmd.Parameters.Add("@language", SqlDbType.NVarChar).Value            = dr["Language"].ToString().Trim();
                        cmd.Parameters.Add("@workExperience", SqlDbType.NVarChar).Value      = dr["Work_Experience"].ToString().Trim();
                        cmd.Parameters.Add("@vacancies", SqlDbType.NVarChar).Value           = dr["Vacancies"].ToString().Trim();
                        cmd.Parameters.Add("@urgentCellPhone", SqlDbType.VarChar).Value      = dr["Urgent_CellPhone"].ToString().Trim();
                        cmd.Parameters.Add("@urgentRelationship", SqlDbType.NVarChar).Value  = dr["Urgent_Relationship"].ToString().Trim();
                        cmd.Parameters.Add("@urgentContactPerson", SqlDbType.NVarChar).Value = dr["Urgent_Contact_Person"].ToString().Trim();
                        cmd.Parameters.Add("@exemptionReason", SqlDbType.NVarChar).Value     = dr["Exemption_Reason"].ToString().Trim();
                        cmd.Parameters.Add("@duringService", SqlDbType.NVarChar).Value       = dr["During_Service"].ToString().Trim();
                        cmd.Parameters.Add("@introduction", SqlDbType.NVarChar).Value        = dr["Introduction"].ToString().Trim();
                        cmd.Parameters.Add("@hopePromise", SqlDbType.NVarChar).Value         = dr["Hope_Promise"].ToString().Trim();
                        cmd.Parameters.Add("@hopeSupervisor", SqlDbType.NVarChar).Value      = dr["Hope_Supervisor"].ToString().Trim();
                        cmd.Parameters.Add("@futureGoal", SqlDbType.NVarChar).Value          = dr["Future_Goal"].ToString().Trim();
                        cmd.Parameters.Add("@attractReason", SqlDbType.NVarChar).Value       = dr["Attract_Reason"].ToString().Trim();
                        cmd.Parameters.Add("@hobby", SqlDbType.NVarChar).Value                  = dr["Hobby"].ToString().Trim();
                        cmd.Parameters.Add("@disadvantages", SqlDbType.NVarChar).Value          = dr["Disadvantages"].ToString().Trim();
                        cmd.Parameters.Add("@advantage", SqlDbType.NVarChar).Value              = dr["Advantage"].ToString().Trim();
                        cmd.Parameters.Add("@whenReport", SqlDbType.NVarChar).Value             = dr["When_Report"].ToString().Trim();
                        cmd.Parameters.Add("@hopeSalary", SqlDbType.NVarChar).Value             = dr["Hope_salary"].ToString().Trim();
                        cmd.Parameters.Add("@careWork", SqlDbType.NVarChar).Value               = dr["Care_Work"].ToString().Trim();
                        cmd.Parameters.Add("@relativesName", SqlDbType.NVarChar).Value          = dr["Relatives_Name"].ToString().Trim();
                        cmd.Parameters.Add("@relativesRelationship", SqlDbType.NVarChar).Value  = dr["Relatives_Relationship"].ToString().Trim();
                        cmd.Parameters.Add("@isService", SqlDbType.NVarChar).Value              = dr["IsService"].ToString().Trim();
                        cmd.Parameters.Add("@isStudy", SqlDbType.NVarChar).Value                = dr["IsStudy"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseCertification", SqlDbType.NVarChar).Value = dr["Expertise_Certification"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseDataBase", SqlDbType.NVarChar).Value      = dr["Expertise_DataBase"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseBigData", SqlDbType.NVarChar).Value       = dr["Expertise_BigData"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseOS", SqlDbType.NVarChar).Value            = dr["Expertise_OS"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseDevops", SqlDbType.NVarChar).Value        = dr["Expertise_Devops"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseTools", SqlDbType.NVarChar).Value         = dr["Expertise_Tools"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseToolsFramwork", SqlDbType.NVarChar).Value = dr["Expertise_Tools_Framwork"].ToString().Trim();
                        cmd.Parameters.Add("@expertiseLanguage", SqlDbType.NVarChar).Value      = dr["Expertise_language"].ToString().Trim();
                        cmd.Parameters.Add("@image", SqlDbType.NVarChar).Value                  = path.Trim();
                        cmd.Parameters.Add("@interviewDate", SqlDbType.Date).Value              = dr["Interview_Date"].ToString().Trim();
                        cmd.Parameters.Add("@interviewId", SqlDbType.Int).Value                 = interviewId;
                        cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value      = dr["Name"].ToString().Trim();
                        cmd.Parameters.Add("@sex", SqlDbType.NVarChar).Value       = dr["Sex"].ToString().Trim();
                        cmd.Parameters.Add("@birthday", SqlDbType.Date).Value      = Common.GetInstance().ValueIsNullOrEmpty(dr["Birthday"].ToString().Trim());
                        cmd.Parameters.Add("@married", SqlDbType.NVarChar).Value   = dr["Married"].ToString().Trim();
                        cmd.Parameters.Add("@mail", SqlDbType.VarChar).Value       = dr["Mail"].ToString().Trim();
                        cmd.Parameters.Add("@adress", SqlDbType.NVarChar).Value    = dr["Adress"].ToString().Trim();
                        cmd.Parameters.Add("@cellPhone", SqlDbType.NVarChar).Value = dr["CellPhone"].ToString().Trim();
                        cmd.ExecuteNonQuery();
                    }
                    ////儲存專案經驗資料
                    cmd.CommandText = @"delete from [Project_Experience] where Interview_Id=@interviewId";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = @"insert into [Project_Experience] ([Company],[Project_Name],[OS],[Database],[Position],[Language],[Tools],[Description],[Start_End_Date],[Interview_Id])
                                        values (@Company,@Project_Name,@OS,@Database,@Position,@Language,@Tools,@Description,@Start_End_Date,@Interview_Id)";
                    foreach (DataRow dr in saveData.Tables[2].Rows)
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add(@"Company", SqlDbType.NVarChar).Value        = dr["Company"].ToString();
                        cmd.Parameters.Add(@"Project_Name", SqlDbType.NVarChar).Value   = dr["Project_Name"].ToString();
                        cmd.Parameters.Add(@"OS", SqlDbType.NVarChar).Value             = dr["OS"].ToString();
                        cmd.Parameters.Add(@"Database", SqlDbType.NVarChar).Value       = dr["Database"].ToString();
                        cmd.Parameters.Add(@"Position", SqlDbType.NVarChar).Value       = dr["Position"].ToString();
                        cmd.Parameters.Add(@"Language", SqlDbType.NVarChar).Value       = dr["Language"].ToString();
                        cmd.Parameters.Add(@"Tools", SqlDbType.NVarChar).Value          = dr["Tools"].ToString();
                        cmd.Parameters.Add(@"Description", SqlDbType.NVarChar).Value    = dr["Description"].ToString();
                        cmd.Parameters.Add(@"Start_End_Date", SqlDbType.NVarChar).Value = dr["Start_End_Date"].ToString();
                        cmd.Parameters.Add(@"Interview_Id", SqlDbType.Int).Value        = interviewId;
                        cmd.ExecuteNonQuery();
                    }
                    ////儲存面談結果資料
                    cmd.CommandText = @"update Interview_Info set Appointment=@Appointment,Results_Remark=@Results_Remark where Interview_Id=@Interview_Id";
                    foreach (DataRow dr in saveData.Tables[3].Rows)
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add(@"Appointment", SqlDbType.NVarChar).Value    = dr["Appointment"].ToString();
                        cmd.Parameters.Add(@"Results_Remark", SqlDbType.NVarChar).Value = dr["Results_Remark"].ToString();
                        cmd.Parameters.Add(@"Interview_Id", SqlDbType.Int).Value        = interviewId;
                        cmd.ExecuteNonQuery();
                    }

                    cmd.Parameters.Clear();
                    cmd.CommandText = @"delete from [Interview_Comments] where Interview_Id=@interviewId";
                    cmd.Parameters.Add("@interviewId", SqlDbType.Int).Value = interviewId;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = @"insert into [Interview_Comments] ([Interviewer],[Result],[Interview_Id])
                                        values (@Interviewer,@Result,@Interview_Id)";
                    foreach (DataRow dr in saveData.Tables[0].Rows)
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add(@"Interviewer", SqlDbType.NVarChar).Value = dr["Interviewer"].ToString();
                        cmd.Parameters.Add(@"Result", SqlDbType.NVarChar).Value      = dr["Result"].ToString();
                        cmd.Parameters.Add(@"Interview_Id", SqlDbType.Int).Value     = interviewId;
                        cmd.ExecuteNonQuery();
                    }

                    cmd.Parameters.Clear();
                    cmd.CommandText = @"update Contact_Info set UpdateTime = @updateTime where Contact_Id = 
                                       (select Contact_Id from Interview_Info where Interview_Id = @interviewId)";
                    cmd.Parameters.Add("@updateTime", SqlDbType.DateTime).Value = DateTime.Now.ToString();
                    cmd.Parameters.Add("@interviewId", SqlDbType.Int).Value     = interviewId;
                    cmd.ExecuteNonQuery();

                    this.CommitTransaction();
                    return("修改成功");
                }
            }
            catch (Exception ex)
            {
                this.RollbackTransaction();
                LogInfo.WriteErrorInfo(ex);
                return("修改失敗");
            }
            finally
            {
                this.CloseDatabaseConnection();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 根據聯繫ID匯出面談資料
        /// </summary>
        /// <param name="contactIdList"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string ExportInterviewDataByContactId(List <string> contactIdList, string path)
        {
            bool isAllExport = true; ////紀錄是否有資料沒有面談資料

            try
            {
                for (int i = 0; i < contactIdList.Count; i++)
                {
                    List <InterviewData> interviewDataList = new List <InterviewData>(); ///面談資料清單
                    DataSet       ds = Talent.GetInstance().SelectContactSituationDataById(contactIdList[i]);
                    List <string> interviewIdList = new List <string>();
                    foreach (DataRow dr in ds.Tables[4].Rows)
                    {
                        interviewIdList.Add(dr[0].ToString());
                    }

                    ////代表沒有面談資料
                    if (interviewIdList.Count == 0)
                    {
                        isAllExport = false;
                        continue;
                    }

                    foreach (string interviewId in interviewIdList)
                    {
                        InterviewResults         interviewResults      = new InterviewResults();
                        InterviewData            interviewData         = new InterviewData();
                        DataSet                  interviewDataSet      = Talent.GetInstance().SelectInterviewDataById(interviewId);
                        List <InterviewInfo>     interviewInfo         = interviewDataSet.Tables[0].DataTableToList <InterviewInfo>();     ////面談基本資料
                        List <InterviewComments> interviewCommentsList = interviewDataSet.Tables[1].DataTableToList <InterviewComments>(); ////面談評語
                        List <InterviewResult>   interviewResult       = interviewDataSet.Tables[2].DataTableToList <InterviewResult>();   ////面談結果(任用評定與備註)

                        interviewResults.InterviewResult       = interviewResult[0];
                        interviewResults.InterviewCommentsList = interviewCommentsList;

                        List <ProjectExperience> projectExperienceList = interviewDataSet.Tables[3].DataTableToList <ProjectExperience>(); ////專案經驗

                        interviewData.InterviewInfo         = interviewInfo[0];
                        interviewData.InterviewResults      = interviewResults;
                        interviewData.ProjectExperienceList = projectExperienceList;
                        interviewDataList.Add(interviewData);
                    }

                    string msg = ExcelHelper.GetInstance().ExportInterviewData(interviewDataList, path, i + 1);
                    if (msg != "匯出成功")
                    {
                        return("匯出失敗");
                    }
                }

                if (!isAllExport)
                {
                    return("匯出成功,但有些資料沒有面談資料");
                }

                return("匯出成功");
            }
            catch (Exception ex)
            {
                LogInfo.WriteErrorInfo(ex);
                return("匯出失敗");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 根據聯繫ID匯出所有資料
        /// </summary>
        /// <param name="contactIdList"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string ExportAllDataByContactId(List <string> contactIdList, string path)
        {
            try
            {
                for (int i = 0; i < contactIdList.Count; i++)
                {
                    List <ContactSituation> ContactSituationList = new List <ContactSituation>(); ////聯繫狀況資料
                    List <InterviewData>    interviewDataList    = new List <InterviewData>();    ///面談資料清單
                    ContactSituation        contactSituation     = new ContactSituation();
                    DataSet ds = Talent.GetInstance().SelectContactSituationDataById(contactIdList[i]);
                    contactSituation.Info   = ds.Tables[0].DBNullToEmpty().DataTableToList <ContactInfo>()[0];
                    contactSituation.Status = ds.Tables[1].DataTableToList <ContactStatus>();
                    string codeList = string.Empty;
                    foreach (DataRow dr in ds.Tables[2].Rows)
                    {
                        codeList += dr[0].ToString() + "\n";
                    }

                    contactSituation.Code = codeList;
                    ContactSituationList.Add(contactSituation);
                    List <string> interviewIdList = new List <string>();
                    foreach (DataRow dr in ds.Tables[4].Rows)
                    {
                        interviewIdList.Add(dr[0].ToString());
                    }

                    foreach (string interviewId in interviewIdList)
                    {
                        InterviewResults         interviewResults      = new InterviewResults();
                        InterviewData            interviewData         = new InterviewData();
                        DataSet                  interviewDataSet      = Talent.GetInstance().SelectInterviewDataById(interviewId);
                        List <InterviewInfo>     interviewInfo         = interviewDataSet.Tables[0].DataTableToList <InterviewInfo>();     ////面談基本資料
                        List <InterviewComments> interviewCommentsList = interviewDataSet.Tables[1].DataTableToList <InterviewComments>(); ////面談評語
                        List <InterviewResult>   interviewResult       = interviewDataSet.Tables[2].DataTableToList <InterviewResult>();   ////面談結果(任用評定與備註)

                        interviewResults.InterviewResult       = interviewResult[0];
                        interviewResults.InterviewCommentsList = interviewCommentsList;

                        List <ProjectExperience> projectExperienceList = interviewDataSet.Tables[3].DataTableToList <ProjectExperience>(); ////專案經驗

                        interviewData.InterviewInfo         = interviewInfo[0];
                        interviewData.InterviewResults      = interviewResults;
                        interviewData.ProjectExperienceList = projectExperienceList;
                        interviewDataList.Add(interviewData);
                    }

                    string msg = ExcelHelper.GetInstance().ExportAllData(ContactSituationList, interviewDataList, path, i + 1);
                    if (msg != "匯出成功")
                    {
                        return("匯出失敗");
                    }
                }

                return("匯出成功");
            }
            catch (Exception ex)
            {
                LogInfo.WriteErrorInfo(ex);
                return("匯出失敗");
            }
        }