Ejemplo n.º 1
0
        public static void AddLeaveRequest(AddLeaveRequest_EL e)
        {
            using (SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-8HC3KF0;Initial Catalog=ALMS;Integrated Security=True;"))
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = "spAddLeaveRequest",
                    Connection  = con,
                    CommandType = CommandType.StoredProcedure
                };
                //passing values to sql parameter

                cmd.Parameters.AddWithValue("@EmpId", e.EmpId);
                cmd.Parameters.AddWithValue("@ReqStartDate", e.ReqStartDate);
                cmd.Parameters.AddWithValue("@ReqEndDate", e.ReqEndDate);
                cmd.Parameters.AddWithValue("@ReqStatus", default);

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                }


                catch (SqlException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        public static AddLeaveRequest_EL AddLeaveRequestInput()
        {
            Console.WriteLine("Enter: EmpId, Leave Start Date, Leave End Date");
            AddLeaveRequest_EL alr = new AddLeaveRequest_EL()
            {
                EmpId        = int.Parse(Console.ReadLine()),
                ReqStartDate = DateTime.Parse(Console.ReadLine()),
                ReqEndDate   = DateTime.Parse(Console.ReadLine()),
            };

            return(alr);
        }