public TrServicemasterEntity GetSingleTrServicemasterRecordById(object param)
 {
     Database db = DatabaseFactory.CreateDatabase();
     string sql = "SELECT ID, ServiceName, Description FROM TR_ServiceMaster WHERE Id=@Id";
     DbCommand dbCommand = db.GetSqlStringCommand(sql);
     db.AddInParameter(dbCommand, "Id", DbType.String, param);
     TrServicemasterEntity trServicemasterEntity = null;
     using (IDataReader dataReader = db.ExecuteReader(dbCommand))
     {
         if (dataReader.Read())
         {
             trServicemasterEntity = new TrServicemasterEntity();
             if (dataReader["ID"] != DBNull.Value)
             {
                 trServicemasterEntity.Id = dataReader["ID"].ToString();
             }
             if (dataReader["ServiceName"] != DBNull.Value)
             {
                 trServicemasterEntity.Servicename = dataReader["ServiceName"].ToString();
             }
             if (dataReader["Description"] != DBNull.Value)
             {
                 trServicemasterEntity.Description = dataReader["Description"].ToString();
             }
         }
     }
     return trServicemasterEntity;
 }
        public JsonResult AddUpdateServiceName(TrServicemasterEntity _Model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." });
                }

                bool isUpdate = false;
                if (_Model.Id == null)
                    isUpdate = (bool)ExecuteDB(ERPTask.AG_SaveTrServicemasterInfo, _Model);
                else
                    isUpdate = (bool)ExecuteDB(ERPTask.AG_UpdateTrServicemasterInfo, _Model);
                if (isUpdate)
                {
                    var addedModel = _Model;
                    return Json(new { Result = "OK", Record = addedModel });
                }
                else
                    return Json(new { Result = "ERROR", Message = "Information failed to save" });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }
        public bool UpdateTrServicemasterInfo(TrServicemasterEntity trServicemasterEntity, Database db, DbTransaction transaction)
        {
            string sql = "UPDATE TR_ServiceMaster SET ServiceName= @Servicename, Description= @Description WHERE Id=@Id";
            DbCommand dbCommand = db.GetSqlStringCommand(sql);
            db.AddInParameter(dbCommand, "Id",DbType.String, trServicemasterEntity.Id);
            db.AddInParameter(dbCommand, "Servicename", DbType.String, trServicemasterEntity.Servicename);
            db.AddInParameter(dbCommand, "Description", DbType.String, trServicemasterEntity.Description);

            db.ExecuteNonQuery(dbCommand, transaction);
            return true;
        }
        public bool SaveTrServicemasterInfo(TrServicemasterEntity trServicemasterEntity, Database db, DbTransaction transaction)
        {
            string sql = "INSERT INTO TR_ServiceMaster ( ServiceName, Description) VALUES (  @Servicename,  @Description )";
            DbCommand dbCommand = db.GetSqlStringCommand(sql);

            db.AddInParameter(dbCommand, "Servicename", DbType.String, trServicemasterEntity.Servicename);
            db.AddInParameter(dbCommand, "Description", DbType.String, trServicemasterEntity.Description);

            db.ExecuteNonQuery(dbCommand, transaction);
            return true;
        }