public string SaveWorkday(WorkdayModels workdayModel) { WorkdayDTO workday = new WorkdayDTO(); MessageDTO message = new MessageDTO(); workday.Company = new CompanyDTO { CompanyId = Convert.ToInt32(workdayModel.CompanyId) }; workday.User = new UserDTO { UserId = Convert.ToInt32(workdayModel.UserId) }; workday.WorkdayDescription = workdayModel.WorkdayDescription; workday.WorkdayId = Convert.ToInt32(workdayModel.Id); workday.WorkdayShortName = workdayModel.WorkdayShortName; workday.WorkdayStatus = workdayModel.WorkdayStatus; if (String.Compare(workdayModel.Operation, "add", StringComparison.Ordinal) == 0) { message = business.SaveWorkday(workday, "I"); } else if (String.Compare(workdayModel.Operation, "edit", StringComparison.Ordinal) == 0) { message = business.SaveWorkday(workday, "U"); } JavaScriptSerializer oSerializer = new JavaScriptSerializer(); string sJSON = oSerializer.Serialize(message); return(sJSON); }
/// <summary> /// /// </summary> /// <param name="whereClause"></param> /// <param name="dataTable"></param> /// <returns></returns> public List <WorkdayDTO> GetWorkdays(Dictionary <string, string> whereClause, ref DataTable dataTable) { DataSet dataSet = new DataSet(); IUniversalConnector connector = new UniversalConnectorImpl(ServerEnumType.SqlServer, connectionString); var workdays = new List <WorkdayDTO>(); int companyId = Convert.ToInt32(whereClause["companyId"]); int pageSize = Convert.ToInt32(whereClause["pageSize"]); int pageNumber = Convert.ToInt32(whereClause["pageNumber"]); string sortColumn = whereClause["sortColumn"].ToString(); string sortOrder = whereClause["sortOrder"].ToString(); try { //Todos los registros object[] parameters = new object[] { companyId, pageSize, pageNumber, sortColumn, sortOrder }; connector.FillDataSet(dataSet, CommandType.StoredProcedure, "GetWorkdays", parameters); if (dataSet.Tables[1].Rows.Count > 0) { dataTable = dataSet.Tables[0]; foreach (DataRow row in dataSet.Tables[1].Rows) { WorkdayDTO workday = new WorkdayDTO { Company = new CompanyDTO { CompanyId = Convert.ToInt32(row["COMPANY_ID"]) }, WorkdayDescription = row["WORKDAY_DESCRIPTION"].ToString(), WorkdayId = Convert.ToInt32(row["WORKDAY_ID"]), WorkdayShortName = row["WORKDAY_SHORT_NAME"].ToString(), WorkdayStatus = row["WORKDAY_STATUS"].ToString() }; workdays.Add(workday); } } else { workdays = null; } } catch (Exception exception) { workdays = null; } finally { connector.Dispose(); } return(workdays); }
//string connectionString = ConfigurationManager.ConnectionStrings["ConnectionTA"].ToString(); #endregion #region Workday /// <summary> /// /// </summary> /// <param name="workday"></param> /// <param name="operation"></param> /// <returns></returns> public MessageDTO SaveWorkday(WorkdayDTO workday, string operation) { DataTable dataTable = new DataTable(); IUniversalConnector connector = new UniversalConnectorImpl(ServerEnumType.SqlServer, connectionString); MessageDTO message = new MessageDTO(); try { connector.BeginTransaction(); //Todos los registros object[] parameters = new object[] { workday.Company.CompanyId, workday.WorkdayId, workday.User.UserId, workday.WorkdayDescription, workday.WorkdayShortName, workday.WorkdayStatus, operation }; //connector.ExecuteNonQuery(CommandType.StoredProcedure, "SaveWorkdaye", parameters); dataTable = connector.ExecuteDataTable(CommandType.StoredProcedure, "SaveWorkday", parameters); foreach (DataRow row in dataTable.Rows) { message.ErrorCode = row["ERROR_NUMBER"].ToString(); message.ErrorMessage = row["ERROR_DESCRIPTION"].ToString(); } if (message.ErrorCode == "0") { connector.Commit(); } else { connector.RollBack(); } } catch (Exception exception) { message.ErrorCode = "-1"; message.ErrorMessage = exception.ToString(); connector.RollBack(); } finally { connector.Dispose(); } return(message); }
public string DeleteWorkday(int workdayId, int companyId, int userId) { WorkdayDTO workday = new WorkdayDTO(); MessageDTO message = new MessageDTO(); workday.Company = new CompanyDTO { CompanyId = companyId }; workday.User = new UserDTO { UserId = userId }; workday.WorkdayDescription = ""; workday.WorkdayId = workdayId; workday.WorkdayShortName = ""; workday.WorkdayStatus = ""; message = business.SaveWorkday(workday, "D"); JavaScriptSerializer oSerializer = new JavaScriptSerializer(); string sJSON = oSerializer.Serialize(message); return(sJSON); }
/// <summary> /// /// </summary> /// <param name="workday"></param> /// <param name="operation"></param> /// <returns></returns> public MessageDTO SaveWorkday(WorkdayDTO workday, string operation) { return(workdayDao.SaveWorkday(workday, operation)); }