Esempio n. 1
0
 public Leave()
 {
     InitializeComponent();
     admin = new Admin();
     leave = new Leaves();
     //FillComboInstructor();
 }
 public Leave()
 {
     InitializeComponent();
     admin = new Admin();
     leave = new Leaves();
     //FillComboInstructor();
 }
 public void EditRow(Leaves leave, int index)
 {
     DataRow selectedRow = dataSet.Tables["JoinEmployeeLeave"].Rows[index];
     selectedRow["StartDate"] = leave.StartDate;
     selectedRow["EndDate"] = leave.EndDate;
     selectedRow["Reason"] = leave.Reason;
     selectedRow["NoOfDays"] = leave.NoOfDays;
     EditRecord(leave, index);
 }
        public void DeleteRow(Leaves leave, int index)
        {
            DataRow selectedRow = dataSet.Tables["JoinEmployeeLeave"].Rows[index];
            selectedRow.Delete();

            DeleteRecord(leave, index);
        }
 public void AddRecord(Leaves leave)
 {
     connection.Open();
     //set up command
     SqlCommand command = new SqlCommand("gprocedureInsertEmployeeLeave", connection);
     //set up commandType
     command.CommandType = CommandType.StoredProcedure;
     //set up parameters
     command.Parameters.AddWithValue("@EmployeeID", leave.Employee.EmoloyeeID);
     command.Parameters.AddWithValue("@StartDate", leave.StartDate);
     command.Parameters.AddWithValue("@EndDate", leave.EndDate);
     command.Parameters.AddWithValue("@Reason", leave.Reason);
     command.Parameters.AddWithValue("@NoOfDays", leave.NoOfDays);
     command.ExecuteNonQuery();
     connection.Close();
 }
 private void EditRecord(Leaves leave, int index)
 {
     SqlCommand command = new SqlCommand();
     command.Connection = connection;
     command.CommandType = CommandType.StoredProcedure;
     command.CommandText = "gprocedureUpdateEmployeeLeave";
     dataAdapter.UpdateCommand = command;
     command.Parameters.AddWithValue("@LeaveID", leave.LeaveID);
     command.Parameters.AddWithValue("@StartDate", leave.StartDate);
     command.Parameters.AddWithValue("@EndDate", leave.EndDate);
     command.Parameters.AddWithValue("@Reason", leave.Reason);
     command.Parameters.AddWithValue("@NoOfDays", leave.NoOfDays);
     dataAdapter.Update(dataSet, "JoinEmployeeLeave");
 }
        private void DeleteRecord(Leaves leave, int index)
        {
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "gprocedureDeleteEmployeeLeave";
            dataAdapter.DeleteCommand = command;

            command.Parameters.AddWithValue("@LeaveID", leave.LeaveID);
            dataAdapter.Update(dataSet, "JoinEmployeeLeave");
        }