public string[] createExternalTeacherWorkDataBase(ExternalWorkData SearchTeacher)
 {
     string[] returnValue = new string[2]; ;
     DataBase Base = new DataBase();
     StaffDataBase sDB = new StaffDataBase();
     List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
     using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
     {
         try
         {
             Sqlconn.Open();
             string sql = "INSERT INTO ExternalTeacherWorkRecordData (ExternalID, WorkDate1, WorkDate2, CourseName, WorkReward, CreateFileBy, CreateFileDate, UpFileBy, UpFileDate) " +
                         "VALUES (@ExternalID, @WorkDate1, @WorkDate2, @CourseName, @WorkReward, @CreateFileBy, getDate(), @UpFileBy, getDate())";
             SqlCommand cmd = new SqlCommand(sql, Sqlconn);
             cmd.Parameters.Add("@ExternalID", SqlDbType.BigInt).Value = Chk.CheckStringtoIntFunction(SearchTeacher.ExternalID);
             cmd.Parameters.Add("@WorkDate1", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(SearchTeacher.CourseDate1);
             cmd.Parameters.Add("@WorkDate2", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(SearchTeacher.CourseDate2);
             cmd.Parameters.Add("@CourseName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(SearchTeacher.Course);
             cmd.Parameters.Add("@WorkReward", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(SearchTeacher.CoursePrice);
             cmd.Parameters.Add("@CreateFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
             cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
             returnValue[0] = cmd.ExecuteNonQuery().ToString();
             Sqlconn.Close();
         }
         catch (Exception e)
         {
             string item = e.Message.ToString();
             returnValue[0] = "-1";
             returnValue[1] = item;
         }
     }
     return returnValue;
 }
 public string[] createExternalTeacherWorkDataBase(ExternalWorkData SearchTeacher)
 {
     SalaryManagement smDB = new SalaryManagement();
     if (int.Parse(smDB._StaffhaveRoles[2]) == 1)
     {
         return smDB.createExternalTeacherWorkDataBase(SearchTeacher);
     }
     else
     {
         return new string[2] { _noRole, _errorMsg };
     }
 }
    private List<ExternalWorkData> GetExternalTeacherWorkData(string staffID)
    {
        List<ExternalWorkData> returnValue = new List<ExternalWorkData>();
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                Sqlconn.Open();
                string sql = "SELECT * FROM ExternalTeacherWorkRecordData WHERE isDeleted=0 AND ExternalID=@ExternalID ";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@ExternalID", SqlDbType.BigInt).Value = Chk.CheckStringtoIntFunction(staffID);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    ExternalWorkData addValue = new ExternalWorkData();
                    addValue.ID = dr["WorkID"].ToString();
                    addValue.CourseDate1 = DateTime.Parse(dr["WorkDate1"].ToString()).ToString("yyyy-MM-dd");
                    addValue.CourseDate2 = DateTime.Parse(dr["WorkDate2"].ToString()).ToString("yyyy-MM-dd");
                    addValue.Course = dr["CourseName"].ToString();
                    addValue.CoursePrice = dr["WorkReward"].ToString();
                    returnValue.Add(addValue);

                }
                dr.Close();
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                ExternalWorkData addValue = new ExternalWorkData();
                addValue.ID = "-1";
                addValue.Course = e.Message.ToString();
                returnValue.Add(addValue);
            }
        }
        return returnValue;
    }