public HolidayCollection FillHolidayByID(Int32 LeaveID) { HolidayCollection vc = new HolidayCollection(); NewDAL.DBManager objDB = new DBManager(); objDB.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FeesManagementConn"].ConnectionString; objDB.DBManager(DataAccessLayer.DataProvider.SqlServer, objDB.ConnectionString); objDB.Open(); objDB.CreateParameters(1); objDB.AddParameters(0, "InstituteID", 0, DbType.Int32); objDB.AddParameters(1, "SessionID", "", DbType.String); objDB.AddParameters(2, "LeaveID", LeaveID, DbType.Int32); IDataReader dr = (IDataReader)objDB.ExecuteReader(CommandType.StoredProcedure, "GetVenueForTTable"); while (dr.Read()) { TimeTableDM.HolidayDM objDM = new TimeTableDM.HolidayDM(); objDM.LeaveID = Education.DataHelper.GetInt(dr, "LeaveID"); objDM.LeaveName = Education.DataHelper.GetString(dr, "LeaveName"); objDM.Type = Education.DataHelper.GetString(dr, "Type"); objDM.Date = Education.DataHelper.GetDateTime(dr, "Date"); vc.Add(objDM); } objDB.Connection.Close(); objDB.Dispose(); return(vc); }
public string InsertHoliday(TimeTableDM.HolidayDM objTDM, Admin.AdministratorData.AuditDM audit) { NewDAL.DBManager objDB = new DBManager(); objDB.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FeesManagementConn"].ConnectionString; objDB.DBManager(DataAccessLayer.DataProvider.SqlServer, objDB.ConnectionString); objDB.Open(); objDB.BeginTransaction(); string retv = ""; string flag = ""; try { TimeSpan ts = Convert.ToDateTime(objTDM.ToDate) - Convert.ToDateTime(objTDM.Date); int diffindays = ts.Days + 1; if (diffindays > 0) { System.Array smid = objTDM.SemesterID.Split(','); System.Array specid = objTDM.specID.Split(','); for (int i = 0; i < smid.Length; i++) { for (int s = 0; s < specid.Length; s++) { DateTime dt = objTDM.Date; for (int k = 1; k <= diffindays; k++) { objDB.CreateParameters(17); //LeaveName,Day,Month,Year,Date,Type,Description,instituteID,sessionID,YearID,SemesterID,Aflag objDB.AddParameters(0, "LeaveID", objTDM.LeaveID, DbType.Int32); objDB.AddParameters(1, "LeaveName", objTDM.LeaveName, DbType.String); //objDB.AddParameters(2, "Day", objTDM.Day, DbType.String); //objDB.AddParameters(3, "Month", objTDM.Month, DbType.String); //objDB.AddParameters(4, "Year", objTDM.Year, DbType.String); objDB.AddParameters(2, "Day", Convert.ToDateTime(dt).Day.ToString(), DbType.String); objDB.AddParameters(3, "Month", Convert.ToDateTime(dt).Month.ToString(), DbType.String); objDB.AddParameters(4, "Year", Convert.ToDateTime(dt).Year.ToString(), DbType.String); objDB.AddParameters(5, "Date", dt, DbType.DateTime); objDB.AddParameters(6, "Type", objTDM.Type, DbType.String); objDB.AddParameters(7, "Description", objTDM.Description, DbType.String); objDB.AddParameters(8, "instituteID", objTDM.instituteID, DbType.Int32); objDB.AddParameters(9, "sessionID", objTDM.sessionID, DbType.String); objDB.AddParameters(10, "YearID", smid.GetValue(i).ToString(), DbType.String); objDB.AddParameters(11, "SemesterID", Int32.Parse(smid.GetValue(i).ToString()), DbType.Int32); objDB.AddParameters(12, "Aflag", objTDM.Aflag, DbType.String); objDB.AddParameters(13, "flag", objTDM.Flag, DbType.Int32); //objDB.AddParameters(14, "DayName", objTDM.DayName, DbType.String); objDB.AddParameters(14, "DayName", Convert.ToDateTime(dt).ToString("ddd"), DbType.String); objDB.AddParameters(15, "courseID", objTDM.courseID, DbType.Int32); objDB.AddParameters(16, "specID", Int32.Parse(specid.GetValue(s).ToString()), DbType.Int32); objDB.ExecuteNonQuery(CommandType.StoredProcedure, "Holiday_Insert"); dt = dt.AddDays(1); }//888 } } } else { System.Array smid = objTDM.SemesterID.Split(','); for (int i = 0; i < smid.Length; i++) { objDB.CreateParameters(17); //LeaveName,Day,Month,Year,Date,Type,Description,instituteID,sessionID,YearID,SemesterID,Aflag objDB.AddParameters(0, "LeaveID", objTDM.LeaveID, DbType.Int32); objDB.AddParameters(1, "LeaveName", objTDM.LeaveName, DbType.String); //objDB.AddParameters(2, "Day", objTDM.Day, DbType.String); //objDB.AddParameters(3, "Month", objTDM.Month, DbType.String); //objDB.AddParameters(4, "Year", objTDM.Year, DbType.String); objDB.AddParameters(2, "Day", Convert.ToDateTime(objTDM.Date).Day.ToString(), DbType.String); objDB.AddParameters(3, "Month", Convert.ToDateTime(objTDM.Date).Month.ToString(), DbType.String); objDB.AddParameters(4, "Year", Convert.ToDateTime(objTDM.Date).Year.ToString(), DbType.String); objDB.AddParameters(5, "Date", objTDM.Date, DbType.DateTime); objDB.AddParameters(6, "Type", objTDM.Type, DbType.String); objDB.AddParameters(7, "Description", objTDM.Description, DbType.String); objDB.AddParameters(8, "instituteID", objTDM.instituteID, DbType.Int32); objDB.AddParameters(9, "sessionID", objTDM.sessionID, DbType.String); objDB.AddParameters(10, "YearID", smid.GetValue(i).ToString(), DbType.String); objDB.AddParameters(11, "SemesterID", Int32.Parse(smid.GetValue(i).ToString()), DbType.Int32); objDB.AddParameters(12, "Aflag", objTDM.Aflag, DbType.String); objDB.AddParameters(13, "flag", objTDM.Flag, DbType.Int32); //objDB.AddParameters(14, "DayName", objTDM.DayName, DbType.String); objDB.AddParameters(14, "DayName", Convert.ToDateTime(objTDM.Date).ToString("ddd"), DbType.String); objDB.AddParameters(15, "courseID", objTDM.courseID, DbType.Int32); objDB.AddParameters(16, "specID", objTDM.specID, DbType.Int32); objDB.ExecuteNonQuery(CommandType.StoredProcedure, "Holiday_Insert"); } } objDB.CreateParameters(9); objDB.AddParameters(0, "ID", 0, DbType.Int32); objDB.AddParameters(1, "Form_Name", audit.Form_Name, DbType.String); objDB.AddParameters(2, "Action", audit.Action, DbType.String); objDB.AddParameters(3, "User_ID", audit.User_ID, DbType.String); objDB.AddParameters(4, "Entry_Date", audit.Entry_Date, DbType.String); objDB.AddParameters(5, "Record_ID", audit.Record_ID, DbType.String); objDB.AddParameters(6, "Entry_Time", audit.Entry_Time, DbType.String); objDB.AddParameters(7, "InstituteID", audit.InstituteID, DbType.Int32); objDB.AddParameters(8, "SessionID", audit.SessionID, DbType.String); objDB.ExecuteNonQuery(CommandType.StoredProcedure, "Audit_Insert"); objDB.Transaction.Commit(); if (objTDM.Flag == 1) { retv = "Record saved."; } else if (objTDM.Flag == 2) { retv = "Record Updated Successfully."; } else { retv = "Record deleted Successfully."; } } catch (Exception ex) { objDB.Transaction.Rollback(); retv = "Unable to save record :-" + ex.Message.ToString(); } finally { objDB.Connection.Close(); objDB.Dispose(); } return(retv); }