コード例 #1
0
        public string CreateTimeKeeping(TimeKeeping timeKeeping)
        {
            string Results = string.Empty;

            try
            {
                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    connection.Open();
                    string InsertSQL = "insert into TimeKeeping(EmployeeId, [Date], HoursWorked, JobGroup, ReportId) ";
                    InsertSQL += "values(" + timeKeeping.EmployeeId + ", '" + timeKeeping.Date + "', " + timeKeeping.HoursWorked + ", " + timeKeeping.JobGroupId + ", " + timeKeeping.ReportId + ")";

                    SqlCommand sqlCommand = new SqlCommand(InsertSQL, connection);

                    sqlCommand.ExecuteNonQuery();

                    Results = "SUCCESS";
                }
            }
            catch (Exception exception)
            {
                Results = exception.Message;
            }
            return(Results);
        }
コード例 #2
0
        // Phần lấy dữ liệu kíp từ bảng DM_KIP
        #region GetALLDMKip
        public IEnumerable <TimeKeeping> GetAllDMKip()
        {
            List <TimeKeeping> listTimeKeeping = null;
            TimeKeeping        oTimeKeeping    = null;

            try
            {
                using (OracleCommand cm = new OracleCommand())
                {
                    cm.Connection  = Helper.OraDCOracleConnection;
                    cm.CommandText = string.Format("SELECT * FROM DM_KIP WHERE DONVI =1");
                    //cm.CommandText = string.Format("SELECT * FROM DM_KIP WHERE DONVI = " + don_vi);
                    cm.CommandType = CommandType.Text;
                    using (OracleDataReader dr = cm.ExecuteReader())
                    {
                        listTimeKeeping = new List <TimeKeeping>();
                        while (dr.Read())
                        {
                            oTimeKeeping        = new TimeKeeping();
                            oTimeKeeping.MAKIP  = int.Parse(dr["MAKIP"].ToString());
                            oTimeKeeping.TENKIP = dr["TENKIP"].ToString();
                            listTimeKeeping.Add(oTimeKeeping);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogAPI.LogToFile(LogFileType.EXCEPTION, "GetAllDMKip" + ex.Message);
                listTimeKeeping = null;
            }

            return(listTimeKeeping);
        }
コード例 #3
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            SqlDataLayer _dataLayer = new SqlDataLayer(connectionString);

            string fileExtension = Path.GetExtension(FileUpload.FileName); // Get File Extension

            TimeKeeping timeKeepings = new TimeKeeping();

            if (FileUpload.HasFile)          // Check if the file is Uploaded
            {
                if (fileExtension == ".csv") //Check the file Extension
                {
                    string filePath = Server.MapPath(FileUpload.FileName);
                    var    reader   = new StreamReader(File.OpenRead(filePath));

                    string reportString = File.ReadLines(filePath).Last(); //Footer
                    int    ReportId     = Convert.ToInt32(reportString.Split(',')[1]);

                    bool ReportExists = _dataLayer.CheckIfReportIdExists(ReportId);

                    if (!ReportExists)
                    {
                        while (!reader.EndOfStream)
                        {
                            var fileData = reader.ReadLine();
                            if (fileData.IndexOf("date") != 0 && fileData.IndexOf("report") != 0) //Excluding Header and Footer when processing CSV file
                            {
                                var fileRow = fileData.Split(',');

                                CultureInfo ci   = CultureInfo.CreateSpecificCulture("en-GB");
                                var         Date = Convert.ToDateTime(fileRow[0], ci.DateTimeFormat).ToString("d");

                                timeKeepings.EmployeeId  = Convert.ToInt32(fileRow[2]);
                                timeKeepings.HoursWorked = Convert.ToDouble(fileRow[1].ToString());
                                timeKeepings.JobGroupId  = _dataLayer.GetJobGroupIdByCode(fileRow[3].ToString());
                                timeKeepings.Date        = Convert.ToDateTime(Date);
                                timeKeepings.ReportId    = ReportId;

                                //Insert Into Database Table
                                _dataLayer.CreateTimeKeeping(timeKeepings);
                            }
                        }
                    }
                    else
                    {
                        ErrorMessage.Text = "Report has already been uploaded.";
                    }
                }
                else
                {
                    ErrorMessage.Text = "Please Upload .CSV file";
                }
            }
            else
            {
                ErrorMessage.Text = "No File Uploaded.";
            }
        }
コード例 #4
0
 //If birb is hit by Cutter, play the stunned animation as well as update the score and the time
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Cutter")
     {
         wasHit = true;
         hitBirb.Play();
         hitAnimation();
         ScoreScript.increaseScore(100);
         TimeKeeping.birbHitTime();
     }
 }
コード例 #5
0
 //Destroy the pickup object, update the time, health, as well as points, finally update amount of apples to be spawned
 public static void applesPickedUp(Collision2D col)
 {
     Destroy(col.gameObject);
     TimeKeeping.moreTime(5f);
     ScoreScript.increaseScore(50);
     if (Difficulty.mode == "Hard")
     {
         HealthScript.updateHP(5);
     }
     else
     {
         HealthScript.updateHP(10);
     }
     AppleSpawner.applesSpawned -= 1;
 }
コード例 #6
0
 private void Awake()
 {
     _instance = this;
 }
コード例 #7
0
 public bool UpdateTimeKeeping(TimeKeeping timeKeeping)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
 public Task <TimeKeeping> CreateRegister(TimeKeeping time)
 {
     _db.Add(time);
     return(Task.Factory.StartNew(() => time));
 }