예제 #1
0
        public static STO.User AddDetails(string fromTime, string toTime, string description, string empId, string date)
        {
            try
            {
                var        fT  = Convert.ToDateTime(fromTime);
                var        tT  = Convert.ToDateTime(toTime);
                string     qry = "insert into Time_Sheet(Date,FromTime,ToTime,Description,EmpId) values(@date,@fTime,@tTime,@descrption,@eId)";
                SqlCommand cmd = new SqlCommand(qry, con);
                cmd.Parameters.AddWithValue("@date", date);
                cmd.Parameters.AddWithValue("@fTime", fromTime);
                cmd.Parameters.AddWithValue("@tTime", toTime);
                cmd.Parameters.AddWithValue("@descrption", description);
                cmd.Parameters.AddWithValue("@eId", empId);

                con.Open();
                cmd.ExecuteNonQuery();

                var user = new STO.User();
                return(user);
            }
            catch
            {
                throw;
            }
            finally
            {
                con.Close();
            }
        }
예제 #2
0
        public static List <STO.User> ShowGrid(string userName, string gridDate)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("select ts.EmpId,ud.UserName,ts.Date,ts.FromTime,ts.ToTime,ts.TaskId,ts.[Description],ud.First_Name,ud.Last_Name from Time_Sheet ts join User_Details ud on ts.EmpId = ud.EmpId where ud.EmpId=@userName and ts.Date =@gridDate", con);
                cmd.Parameters.AddWithValue("@userName", userName);
                cmd.Parameters.AddWithValue("@gridDate", gridDate);
                con.Open();
                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                DataSet        ds = new DataSet();
                ad.Fill(ds);


                STO.User        user       = new STO.User();
                List <STO.User> listValues = new List <STO.User>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DateTime date   = Convert.ToDateTime(dr["Date"]);
                    var      dateGv = date.ToString("dd/MM/yyyy");

                    DateTime fTime = Convert.ToDateTime(dr["FromTime"]);


                    DateTime tTime = Convert.ToDateTime(dr["ToTime"]);



                    listValues.Add(new STO.User {
                        EmpId = Convert.ToInt16(dr["EmpId"]), UserName = Convert.ToString(dr["UserName"]), Date = dateGv.ToString(), FromTime = fTime, ToTime = tTime, TaskId = Convert.ToInt16(dr["TaskId"]), Description = Convert.ToString(dr["Description"]), FirstName = Convert.ToString(dr["First_Name"]), LastName = Convert.ToString(dr["Last_Name"]),
                    });
                }
                return(listValues);
            }
            catch
            {
                throw;
            }
            finally
            {
                con.Close();
            }
        }