예제 #1
0
        /// <summary>
        /// Update child details
        /// </summary>
        /// <returns></returns>
        public WorkerUpdateResponse Update(WorkerUpdateRequest workerAddRequest)
        {
            WorkerUpdateResponse workerUpdateResponse = new WorkerUpdateResponse();

            workerUpdateResponse.XResponseStatus = new ResponseStatus();

            // Check record version. Do not allow update if version is different

            if (!CommonDB.IsTheSameRecordVersion(tablename: "Worker",
                                                 inputUID: UID,
                                                 recordVersion: RecordVersion,
                                                 responseStatus: workerUpdateResponse.XResponseStatus))
            {
                return(workerUpdateResponse);
            }

            string commandString = (
                "UPDATE Worker " +
                " SET  " +
                FieldName.UID + "= @" + FieldName.UID + ", " +
                FieldName.FirstName + "= @" + FieldName.FirstName + ", " +
                FieldName.Surname + "= @" + FieldName.Surname + ", " +
                FieldName.WLVL_Level + "= @" + FieldName.WLVL_Level + ", " +
                FieldName.UpdateDateTime + "= @" + FieldName.UpdateDateTime + ", " +
                FieldName.UserIdUpdatedBy + "= @" + FieldName.UserIdUpdatedBy + ", " +
                FieldName.RecordVersion + "= @" + FieldName.RecordVersion + ", " +
                FieldName.IsVoid + "= @" + FieldName.IsVoid +

                "    WHERE UID = @UID "
                );



            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                using (var command = new MySqlCommand(cmdText: commandString, connection: connection))
                {
                    RecordVersion++;
                    AddSqlParameters(command);

                    try
                    {
                        command.Parameters.AddWithValue("@" + FieldName.IsVoid, "N");

                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), workerAddRequest.XHeaderInfo.UserID);

                        workerUpdateResponse.XResponseStatus.ReturnCode = -0020;
                        workerUpdateResponse.XResponseStatus.ReasonCode = 0001;
                        workerUpdateResponse.XResponseStatus.Message    = "Error saving client. " + ex;
                        return(workerUpdateResponse);
                    }
                }
            }

            return(workerUpdateResponse);
        }
예제 #2
0
        /// <summary>
        /// Add Worker
        /// </summary>
        public WorkerAddResponse Add(WorkerAddRequest workerAddRequest)
        {
            var workerAddResponse = new WorkerAddResponse();

            workerAddResponse.XResponseStatus = new ResponseStatus();

            this.UserIdCreatedBy = workerAddRequest.XHeaderInfo.UserID;
            this.UserIdUpdatedBy = workerAddRequest.XHeaderInfo.UserID;

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                UID           = GetLastUID() + 1;
                RecordVersion = 1;

                var commandString =
                    (
                        "INSERT INTO Worker (" +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.UID +
                        " ,@" + FieldName.FirstName +
                        " ,@" + FieldName.Surname +
                        " ,@" + FieldName.WLVL_Level +
                        ", @" + FieldName.UpdateDateTime +
                        ", @" + FieldName.UserIdUpdatedBy +
                        ", @" + FieldName.CreationDateTime +
                        ", @" + FieldName.UserIdCreatedBy +
                        ", @" + FieldName.RecordVersion +
                        ", @" + FieldName.IsVoid +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    AddSqlParameters(command);

                    command.Parameters.Add("@" + FieldName.CreationDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                    command.Parameters.Add("@" + FieldName.UserIdCreatedBy, MySqlDbType.VarChar).Value   = this.UserIdCreatedBy;
                    command.Parameters.Add("@" + FieldName.IsVoid, MySqlDbType.VarChar).Value            = "N";

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), workerAddRequest.XHeaderInfo.UserID);

                        workerAddResponse.XResponseStatus.ReturnCode = -0025;
                        workerAddResponse.XResponseStatus.ReasonCode = 0001;
                        workerAddResponse.XResponseStatus.Message    = "Error adding child. " + ex;
                        return(workerAddResponse);
                    }

                    return(workerAddResponse);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Update child details
        /// </summary>
        /// <returns></returns>
        public ResponseStatus Update(string userID)
        {
            // Check record version. Do not allow update if version is different

            if (!IsTheSameRecordVersion(this.UID, this.RecordVersion))
            {
                return(new ResponseStatus()
                {
                    ReturnCode = -0010,
                    ReasonCode = 0001,
                    Message = "Record updated previously by another user."
                });
            }

            string commandString = (
                "UPDATE Child " +
                " SET  " +
                FieldName.UID + "= @" + FieldName.UID + ", " +
                FieldName.CurrentRoom + "= @" + FieldName.CurrentRoom + ", " +
                FieldName.FirstName + "= @" + FieldName.FirstName + ", " +
                FieldName.Surname + "= @" + FieldName.Surname + ", " +
                FieldName.DateOfBirth + "= @" + FieldName.DateOfBirth + ", " +
                FieldName.AddressStreetName + "= @" + FieldName.AddressStreetName + ", " +
                FieldName.AddressStreetNumber + "= @" + FieldName.AddressStreetNumber + ", " +
                FieldName.AddressSuburb + "= @" + FieldName.AddressSuburb + ", " +
                FieldName.AddressCity + "= @" + FieldName.AddressCity + ", " +
                FieldName.AddressPostCode + "= @" + FieldName.AddressPostCode + ", " +
                FieldName.UpdateDateTime + "= @" + FieldName.UpdateDateTime + ", " +
                FieldName.UserIdUpdatedBy + "= @" + FieldName.UserIdUpdatedBy + ", " +
                FieldName.RecordVersion + "= @" + FieldName.RecordVersion + ", " +
                FieldName.IsVoid + "= @" + FieldName.IsVoid +

                "    WHERE UID = @UID "
                );



            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                using (var command = new MySqlCommand(cmdText: commandString, connection: connection))
                {
                    RecordVersion++;
                    AddSqlParameters(command);

                    try
                    {
                        //command.Parameters.Add("@" + FieldName.UpdateDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                        //command.Parameters.Add("@" + FieldName.UserIdUpdatedBy, MySqlDbType.VarChar).Value = userID;

                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        return(new ResponseStatus()
                        {
                            ReturnCode = -0020, ReasonCode = 0001, Message = "Error saving client. " + ex
                        });
                    }
                }
            }

            return(new ResponseStatus());
        }
예제 #4
0
        /// <summary>
        /// Add Learning Story
        /// </summary>
        public ChildRoomAddResponse Add(ChildRoomAddRequest childRoomAddRequest)
        {
            this.UserIdCreatedBy = childRoomAddRequest.headerInfo.UserID;
            this.UserIdUpdatedBy = childRoomAddRequest.headerInfo.UserID;

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                UID           = CommonDB.GetLastUID("ChildRoom") + 1;
                RecordVersion = 1;

                var commandString =
                    (
                        "INSERT INTO LearningStory (" +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.UID +
                        " ,@" + FieldName.FKChildUID +
                        " ,@" + FieldName.FKRoomUID +
                        " ,@" + FieldName.StartDate +
                        " ,@" + FieldName.EndDate +

                        ", @" + CommonDB.FieldName.UpdateDateTime +
                        ", @" + CommonDB.FieldName.UserIdUpdatedBy +
                        ", @" + CommonDB.FieldName.CreationDateTime +
                        ", @" + CommonDB.FieldName.UserIdCreatedBy +
                        ", @" + CommonDB.FieldName.RecordVersion +
                        ", @" + CommonDB.FieldName.IsVoid +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    AddSqlParameters(command);

                    command.Parameters.Add("@" + LearningStory.FieldName.CreationDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                    command.Parameters.Add("@" + LearningStory.FieldName.UserIdCreatedBy, MySqlDbType.VarChar).Value   = this.UserIdCreatedBy;
                    command.Parameters.Add("@" + LearningStory.FieldName.IsVoid, MySqlDbType.VarChar).Value            = "N";

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        return(new ChildRoomAddResponse
                        {
                            responseStatus =
                            {
                                ReturnCode = -0025,
                                ReasonCode =  0001,
                                Message    = "Error adding Learning Story. " + ex
                            }
                        });
                    }

                    return(new ChildRoomAddResponse
                    {
                        responseStatus = { ReturnCode = 0001, ReasonCode = 0001 }
                    });
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Add child
        /// </summary>
        public ResponseStatus Add(string userID)
        {
            this.UserIdCreatedBy = userID;
            this.UserIdUpdatedBy = userID;

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                UID           = GetLastUID() + 1;
                RecordVersion = 1;

                var commandString =
                    (
                        "INSERT INTO child (" +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.UID +
                        " ,@" + FieldName.CurrentRoom +
                        " ,@" + FieldName.FirstName +
                        " ,@" + FieldName.Surname +
                        " ,@" + FieldName.DateOfBirth +
                        " ,@" + FieldName.AddressStreetName +
                        " ,@" + FieldName.AddressStreetNumber +
                        " ,@" + FieldName.AddressSuburb +
                        " ,@" + FieldName.AddressCity +
                        " ,@" + FieldName.AddressPostCode +
                        ", @" + FieldName.UpdateDateTime +
                        ", @" + FieldName.UserIdUpdatedBy +
                        ", @" + FieldName.CreationDateTime +
                        ", @" + FieldName.UserIdCreatedBy +
                        ", @" + FieldName.RecordVersion +
                        ", @" + FieldName.IsVoid +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    AddSqlParameters(command);

                    command.Parameters.Add("@" + FieldName.CreationDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                    command.Parameters.Add("@" + FieldName.UserIdCreatedBy, MySqlDbType.VarChar).Value   = this.UserIdCreatedBy;
                    command.Parameters.Add("@" + FieldName.IsVoid, MySqlDbType.VarChar).Value            = "N";

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        return(new ResponseStatus()
                        {
                            ReturnCode = -0025, ReasonCode = 0001, Message = "Error adding child. " + ex
                        });
                    }

                    return(new ResponseStatus());
                }
            }
        }